Thursday, 29 September 2022

Steam not starting from Cinnamon launcher

 Just upgraded to 22.04.1 LTS and of course that broke a lot of stuff.


In this case it was Steam (installed via apt repository)


Steam would start successfully from a terminal but would fail if launched from a launcher in Cinnamon. Further investigation showed that the steam process would be marked "defunct" after such a failure.

My initial workaround was to change the launcher to "Run in terminal" which worked OK but is kind of messy.

A better "fix" is to edit this file;

<code>sudo vi /usr/share/applications/steam.desktop</code>

and find this line;

<code>Exec=/usr/games/steam %U</code>

and change it to;

<code>Exec=bash -c "LD_PRELOAD='/usr/$LIB/libstdc++.so.6' DISPLAY=:0 steam</code>



Monday, 17 June 2019

Some ffmpeg usage examples

Here are a few ffmpeg examples I have used on occasion:

Basic mkv to mp4 conversion
 ffmpeg -i original.mkv -vcodec copy -acodec copy new.mp4


Advanced mkv to mp4 conversion (copy multiple streams) 
 ffmpeg -i original.mkv -map 0:a -map 0:v -map 0:s -c:v copy -c:a copy -c:a copy -c:s mov_text new.mp4


Transcode to huffyuv + flac
 ffmpeg -i original.avi -f avi -c:v huffyuv -c:a flac new.avi


Copy video section (with audio)
 ffmpeg -i original.avi -c:v copy -c:a copy -ss 00:00:03.000 -t 00:00:26.000 new.part.avi


Reverse video
 ffmpeg -i original.avi -vf reverse -c:v huffyuv new.avi


Insert subtitles
 ffmpeg -i original.mp4 -i subtitles.srt -c:v copy -c:a copy -c:s mov_text new.mp4


Concat multiple files
 # cat part.list.txt
   file old.01.mp4
   file old.02.mp4
   file old.03.mp4

 ffmpeg -safe 0 -f concat -i part.list.txt -c:v copy -c:a copy new.mp4


Convert DVD without transcoding
 ffmpeg -i concat:VTS_07_1.VOB\|VTS_07_2.VOB\|VTS_07_3.VOB -map 0:v -map 0:a -c:v copy -c:a copy new.avi


Slow down video
 ffmpeg -i input.avi -filter:v "setpts=2.0*PTS" -c:v huffyuv output.avi


Speed up video
 ffmpeg -i input.avi -filter:v "setpts=0.5*PTS" -c:v huffyuv output.avi

Monday, 6 May 2019

Create and install an SSL certificate in Apache

Lets create a SSL encrypted website using apache.

Prequisites:
A working unsecured website on port 80
If your server is behind a firewall you will need to open/forward port 443
A publicly accessible FQDN is configured for the site.

Enable ssl on apache;
sudo a2ensite default-ssl.conf

Installing certbot;
sudo apt install certbot python-certbot-apache

Use certbot to create a free certificate;
sudo certbot --apache certonly

Follow the prompts, they are self explanatory.
Note: This will break if the certbot cannot resolve your domain name properly. I have used the --certonly flag to stop certbot from editing apache configs because I prefer to do it myself. Apparently if you drop that flag you can skip the next step.

Once you are done you should have a shiny new certificate in /etc/letsencrypt/live/www.example.com/

Now, if you did not allow certbot to modify your apache configs you will need tell apache to use your new certificate.

Edit the file that contains the virtualhost configuration for your web site. The virtualhost section should look like this;

        ServerName www.example.com
        ServerAdmin brettg@tuxnetworks.com
        DocumentRoot /var/www/html

        (...)


Modify it to look like this;

        ServerName www.example.com
        ServerAdmin admin@example.com
        DocumentRoot /var/www/html
        SSLEngine on
        SSLCertificateFile /etc/letsencrypt/live/www.example.com/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/www.example.com/privkey.pem
  
        (...)



Restart your apache server and you should now be able to browse your site using https.

Note: If you want your site to work in both encrypted (SSL) mode as well as unsecured mode then when you are modifying the virtualhost config in apache copy that entire section to the end of the file and make the changes shown above in the new section

Tuesday, 19 March 2019

Cleaning up df output

I use df a lot on ubuntu. Unfortunately with advent of snap devices df output has become increasingly cluttered with various devices mounted by the system that I generally don' have an interest in seeing.

For example:

# /bin/df
Filesystem      1K-blocks       Used Available Use% Mounted on
udev              8121812          0   8121812   0% /dev
tmpfs             1630708       1888   1628820   1% /run
/dev/sda1        30627388   15252072  13796484  53% /
tmpfs             8153528      68012   8085516   1% /dev/shm
tmpfs                5120          4      5116   1% /run/lock
tmpfs             8153528          0   8153528   0% /sys/fs/cgroup
/dev/loop1          93184      93184         0 100% /snap/core/6405
/dev/loop2          93184      93184         0 100% /snap/core/6350
/dev/loop4          35456      35456         0 100% /snap/gtk-common-themes/818
/dev/loop7          35712      35712         0 100% /snap/gtk-common-themes/1122
/dev/sda2        76766240   26915652  45927952  37% /home
/dev/sdb       7814026584 7137072996 674941212  92% /mnt/library
/dev/sdc       3907018584 3436394816 467552000  89% /mnt/archive
tmpfs             1630704         16   1630688   1% /run/user/132
tmpfs             1630704         80   1630624   1% /run/user/1000
/dev/loop8          36224      36224         0 100% /snap/gtk-common-themes/1198
/dev/loop9          93312      93312         0 100% /snap/core/6531
/dev/loop0       48768594   48768594         0 100% /mnt/loop/Archive.TV.01
/dev/loop3       48628258   48628258         0 100% /mnt/loop/Archive.TV.02
/dev/loop5       48845728   48845728         0 100% /mnt/loop/Archive.TV.03


So that you don't have to visually hunt through that junk to see what you need add this to your users .bashrc file:

function df
{
  /bin/df "$@" | grep -v loop | grep -v tmpfs | grep -v udev
}

Now your df output just lists the actual mounted drives:

#df
Filesystem      1K-blocks       Used Available Use% Mounted on
/dev/sda1        30627388   15252080  13796476  53% /
/dev/sda2        76766240   26915652  45927952  37% /home
/dev/sdb       7814026584 7137072996 674941212  92% /mnt/library
/dev/sdc       3907018584 3436700752 467246064  89% /mnt/archive
/dev/loop0       48768594   48768594         0 100% /mnt/loop/Archive.TV.01
/dev/loop3       48628258   48628258         0 100% /mnt/loop/Archive.TV.02
/dev/loop5       48845728   48845728         0 100% /mnt/loop/Archive.TV.03

If you want see the full output use the full path /bin/df

autofs: keep devices permanently mounted

I have some ISO images which I use autofs to mount as loop devices.

For reasons that are not important I want them to stay mounted permanently.

I couldn't find any information online on how to do this so I poked around in the related autofs man pages.

I noticed that there is a time out option which is set by default to 600 seconds.

I wondered what would happen if I set that to 0 seconds so I tried it.

So far the devices in question have stayed mounted for 15 minutes

Here's how to do it:

/etc/auto.master
/mnt/loop /etc/auto.loops -t 0

/etc/auto.loops
* -fstype=iso9660,loop     :/store/ISO.archives/&.iso


The -t 0 is where we set the time out to 0 (infinite)
   
In case you are wondering the * at the beginning and the &.iso at the end of auto.loops will mount all of the iso files found in the /store/ISO.archives/ directory.

Friday, 2 November 2018

Monday, 3 September 2018

Steam controller doesn't work in Ubuntu 18.04

After upgrading or fresh install of Ubuntu 18.04 your previously working Steam controller will no longer be detected.

To fix this you must install a new package;

sudo apt install steam-devices

Friday, 22 December 2017

Extract subtitles as SRT from mkv


mkvextract tracks source.mkv track_number:file.srt

You can obtain the track number using mkvtoolnix-gui or mkvinfo

Friday, 6 October 2017

Querying video file metadata with mediainfo

I am working on a script that will query media files (mp4/mkv videos) to obtain metadata that can be subsequently used to rename the file to enforce a naming convention. I use the excellent mediainfo tool (available in the standard repositories) to do this.

mediainfo has a metric tonne of options and functions that you can use for various purposes. In my case I want to know the aspect ratio, vertical height and video codec for the file. This can be done in a single command;

mediainfo --Inform="Video;%DisplayAspectRatio%,%Height%,%Format%"

This works fine and returns something like this;

1.85,720p,AVC

When I say it works fine I mean it works fine in 99% of cases. The other 1% are made up of files that contain more than one video stream. Sometimes people package a JPEG image inside the container which is designated internally as "Video#2". In such cases the above command will also return values relating to the JPEG image producing something like this;

1.85,720p,AVC1.85,720p,JPEG

When this happens my script breaks. The workaround for that is to pipe the results through some unix tools to massage the output;

mediainfo --Inform="Video;%DisplayAspectRatio%,%Height%,%Format%\n" "${_TARGET}" | xargs | awk '{print $1;}'

Things to note in the revised command. There is a carriage return ("\n") at the end of the --Inform parameters which will put the unwanted data on a new line like this;

1.85,720p,AVC
1.85,720p,JPEG

xargs will remove that line feed and replace it with a space;

1.85,720p,AVC 1.85,720p,JPEG

And finally awk will produce only the first "word" (space delimited) from the result, which produces the desired output.

1.85,720p,AVC

Now obviously this method assumes that the first video stream in the container is the one we are interested in. I'm struggling to imagine a scenario where this would not be the case so at this point I am OK with that. If I find a file that doesn't work I might have to revise my script, but for now I will stick with this solution.

Saturday, 26 August 2017

Virtualbox remote desktop

I just had a frustrating couple of hours trying to get remote desktop working for a Virtualbox guest.

First, even though the settings screen implies that you merely need to turn remote support on you must also have the virtualbox extension pack installed.

Secondly, if you get "connection refused" or similar errors from the rdesktop client then you are probably using virtualbox 5.0.40

It wasn't until I upgraded virtualbox to 5.1.16 that it just magically started working. grrr


Friday, 21 July 2017

Booting Windows as either dual-boot physical machine or as a Virtual machine

How to boot Windows as either dual-boot physical machine or as a Virtual machine

Here is a scenario.

You have a Linux PC that you want to also dual boot to Windows. That's not hard to do right?

Unfortunately though, we all know dual booting is a bit of a pain when you just want to do something quick in Windows. You need to close everything you are doing in Linux just to boot into Windows.

One solution to that is to run Windows in a VM, that's been possible for years now right? Well the problem with that is that sometimes you need to run native Windows to say, play a 3D game.

You could maintain 2 Windows systems, one via dual-booting and the other as a VM but who wants to maintain two copies of Windows?

This is what I do.

Our starting point is a Linux system on one disk (/dev/sda). We will be installing Windows on to a separate disk that is currently empty (/dev/sdb)

WARNING: If you muck this up you can destroy all the data on your Linux system. Make sure you have backups of everything and you are abso-fricking-lutely sure you have identified the correct drive devices

You can check your disks using this command:
sudo fdisk -l
For the remainder of this tutorial I will be using /dev/sdb for the drive that will host Windows 7.

Let's get started!

In your Linux installation you want to add your user to the "disk" group:
sudo usermod -a -G disk brettg
This allows your user to access the physical drive that Windows 7 is installed on.

Note: You will need to logoff and log back in again for this change to take effect.

Install Virtualbox:
sudo apt install virtualbox
Create a place for your Virtualbox disk images:
mkdir -p $HOME/VirtualboxImages/
Create a new virtual disk that references the physical drive that Windows 7 will be installed on:
VBoxManage internalcommands createrawvmdk -filename $HOME/VirtualboxImages/Windows7.vmdk" -rawdisk /dev/sdb
Open up Virtualbox and create a new virtual machine selecting "Use an existing virtual harddisk file" when you are setting it up.

Insert your Windows CD into the virtual machine (either as a physical CD or an ISO image).

Start the VM and go through the normal Windows installation process, then log into Windows.

Open the registry editor. Edit the following keys and set them all to 0:
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\atapi\Start
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\intelide\Start
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\pciide\Start
This forces Windows to install and load three types of disk drivers at boot. (I don't know why you need to set these to zero). By default it just installs the driver that was needed at install time. This is requireed because when we try and boot Windows later it will not be able to read the disk because it doesn't have the proper driver for it.

Shutdown the VM

You will need to add your Windows disk to grub:
sudo update-grub
Now, hopefully if everything went according to plan you should be able to reboot and find Windows listed in your grub menu. Select that and boot into Windows.

Once you are in Windows, you will have to do all the usual driver installs etc but you already knew that right?

Have fun!

Note: Tested with Ubuntu 16.04.1 host and Windows 7/10 guests

Tuesday, 24 January 2017

Using H.265 (HEVC) on Ubuntu

If you google search how to install H.265 on ubuntu you get a a bunch of posts that describe how to add a PPA for the necessary files.

However the repository hasn't been updated since 2015 (vivid vervet)

If you try to use the vivid repo then things fail because of dependency issues.

But not to worry as it seems that H.265 is now included in the standard xenial repository.

apt-cache search x265
libx265-79 - H.265/HEVC video stream encoder (shared library)
libx265-dev - H.265/HEVC video stream encoder (development files)
libx265-doc - H.265/HEVC video stream encoder (documentation)
x265 - H.265/HEVC video stream encoder

So, all you need to do is;

sudo apt-get install x265

and you are good to go.





Thursday, 31 December 2015

Descreen images in Gimp

I needed to remove the moire patterns of a scan. After a quick search on google I found this descreen plugin.

Unfortunately this plugin also requires the FFT gimp plugin, which is old and requires compiling and that page describes installing it for Windows.

This in turn was a bit of a problem because the FFT plugin has a few dependencies that aren't adequately documented.

To successfully build the plugin you need to first install libgimp-dev and libfftw3-lib packages from the standard repositories (debian/ubuntu)

# sudo apt-get install libfftw3-dev libgimp2.0-dev

Follow this by extracting the tar archive somewhere and doing

# make && make install 

Once this is done, grab the descreen.scm file from the first link and plop it into ~/.gimp2.8/scripts

After starting gimp up there should be a "descreen" option under Filters->Enhance

Monday, 29 June 2015

Wordpress Warning

Just a warning about Wordpress. If you create a Wordpress account you cannot delete it.

Their "delete your account" webpage only tells you how to remove a blog. The best advice they can give you is to make your account inactive. You can't delete it.

Find open files on a filesystem in FreeBSD

I had a problem on an archaic FreeBSD machine whose /var filesystem had tipped over the 80% threshold of our monitoring system.

A brief investigation showed that there was a vast discrepancy between the output of the du and df  commands.

The df command showed that the file system was 81% full where the du command showed it was around 5% full.

This situation is caused when a file is deleted but a process keeps it open. The difference is due to the different ways that the df and du commands calculate free space vs used space. This means that the disk space will still be reserved and therefore seen by df, but since du will no longer see a reference to that file in the directory tree, it cannot see those reserved blocks resulting in a difference between reported disk usage.

So, the next step is to find what process is holding a deleted open. Unfortunately, I would normally use something like lsof to do this but on this ancient version of freebsd that is not an option, so a new option is required.


# fstat -f /var 

USER     CMD          PID   FD MOUNT      INUM MODE         SZ|DV R/W
root     fstat      13839   wd /var      94208 drwxr-xr-x     512  r
root     csh        13582   wd /var      94208 drwxr-xr-x     512  r
operator csh         6713   wd /var     188489 dr-xr-xr-x     512  r
nobody   snmpd      83626    3 /var     259076 -rw-r--r--  2766247084  w
root     cron        1287   wd /var     376832 drwxr-x---     512  r
root     cron        1287    3 /var     164874 -rw-------       4  w
_bgpd    bgpd        1251 root /var      47104 dr-xr-xr-x     512  r
_bgpd    bgpd        1251   wd /var      47104 dr-xr-xr-x     512  r
_bgpd    bgpd        1251 jail /var      47104 dr-xr-xr-x     512  r
_bgpd    bgpd        1250 root /var      47104 dr-xr-xr-x     512  r
_bgpd    bgpd        1250   wd /var      47104 dr-xr-xr-x     512  r
_bgpd    bgpd        1250 jail /var      47104 dr-xr-xr-x     512  r
dhcpd    dhcpd       1213    6 /var     400402 -rw-r--r--   45998  w
root     syslogd      930    3 /var     164883 -rw-------       3  w
root     syslogd      930   12 /var     259338 -rw-r--r--   12844  w
root     syslogd      930   13 /var     259324 -rw-------      78  w
root     syslogd      930   14 /var     259278 -rw-------   40072  w
root     syslogd      930   15 /var     259083 -rw-------      62  w
root     syslogd      930   16 /var     259301 -rw-------   83687  w
root     syslogd      930   17 /var     259077 -rw-r-----    1953  w
root     syslogd      930   18 /var     259079 -rw-r--r--      62  w
root     syslogd      930   19 /var     259085 -rw-------      62  w
root     syslogd      930   20 /var     259087 -rw-------  103292  w
root     syslogd      930   21 /var     259284 -rw-------      78  w
root     syslogd      930   22 /var     259084 -rw-r-----      62  w
root     syslogd      930   23 /var     259082 -rw-r-----      62  w


We can see from the output of the fstat command that the snmp daemon has a 2.7Gb file open.

I killed and restarted snmpd and file system usage dropped down to 3% 


Note: You could limit that output to only show files that are deleted (unowned) by grepping for "nobody"

# fstat -f /var 
nobody   snmpd      83626    3 /var     259076 -rw-r--r--  2766247084  w

Thursday, 9 April 2015

Configuration management: Salt vs Puppet

I've spent some time experimenting with puppet and I have come to the conclusion that I don't much like it.

There are several reasons why this is the case but the main ones are the module system that it uses and the way it abstracts away the configuration details on the client.

 Note: I gave up on puppet after only a couple of days after reaching a point where there was an error somewhere which was impossible to understand because it had no logical behaviour. Therefore I don't profess to be an expert on puppet to any degree at all so any comments from here on are merely my opinion and will definitely include liberal amounts of my misunderstanding of how Puppet works. That is another one of the problems I had with Puppet. The errors it produces are cryptic and there are so many things going on in the box of smoke and mirrors that you can't see the workings of that it is extremely hard to comprehend and debug things. Especially as a n00b. 

From what I have managed to partially understand, Puppet ships with a bunch of pre-installed modules for common applications (such as apache) so you don't need to find and download the appropriate module.

This is all good of course until you need to do something that is not included by default. In that case you need to get on the Internet and find the module you need and install it. Sometimes there will be an "official" puppetlabs module and sometimes you need to trawl through many community provided modules of varying degrees of quality to find one that looks like it might do what you want. This in itself is not terrible but it does involve a lot more mucking about than I think should be required.

Once you have all your modules in order you need to start configuring stuff and this is where the frustration really kicks in.

Puppet uses a bunch of "manifest" files that must be created for each service, host, or groups of hosts. Manifests can include other manifests and everything must be carefully declared in the right places or else things just don't work, and most of the time you will get an obtuse error message that doesn't help a great deal in tracking things down.

Circular dependencies can be common without due care being taken.

For example, the straw that broke the proverbial camels back for me and turned me away from Puppet was where I had two similar hosts with two identical manifests that despite that would produce different results when trying to update them.

One would fail with "Error: Failed to apply catalog: Could not find dependency File[/etc/postfix/main.cf]" while the other one worked fine. This was strange to me because

    a) the file it was complaining about existed on both hosts and

    b) nowhere was I even trying to manage postfix.

I even went to the length of creating two completely empty manifests for the two hosts that still produced the same dissimilar results.

Somewhere in the "box of smoke and mirrors" something was going on but I could not for the life of me figure it out. I even posted a question on serverfault (I rarely need to go to that extreme) but the kind folks there were unable to help either.

So I just gave up because life is too short for that crap.

There are other reasons that I dislike puppet.

A major one is how it abstracts out configuration details for the hosts it manages.

To explain what I mean I will return to the example of apache from before. Now, I am fairly familiar with apache, and I know my way around the apache config files reasonably well. Consider this snippet:

ServerName webserver01.tuxnetworks.com

<VirtualHost first.example.com:80>
    ServerAdmin brett@mydomain.com
    DocumentRoot /var/www/first
</VirtualHost>

That is a pretty simple config for a global server name and a virtual host in apache.

Now, let's look at how you configure that in puppet.

class { 'apache':
default_mods   => true,
}

apache:servername { 'webserver01.tuxnetworks.com' }

apache::vhost { 'first.example.com':
  port    => '80',
  docroot => '/var/www/first',
}

Now this is just a really simple example, but you will note the syntax that you are required to learn and use is totally different to how the target application would normally be configured. Things get even more excitingly confusing when you are trying to configure a service that you are not familiar with. In such cases you are not only required to first figure out what the native settings you need to put in the config file should be but then you must also figure out the correct Puppet syntax for getting there.

I had to do that just yesterday to add another domain to a haproxy server.

You will also note that the ServerAdmin variable has not been set in the puppet example because the 5 minutes that I spent searching the Internet on how to do it came up with nothing. I'm sure with more time I could find the answer (and there is a good chance just adding "serveradmin => brett@mydomain.com'" in there would work) but the point is that I really don't want to have to deal with this level of abstraction for something that I already know how to do.

So, given that you already think that the concept of configuration management systems is great but you are not prepared to devote the rest of your life wrestling with puppet then what do you do?

 Well, another popular system is Chef, but after doing some research I concluded that Chef had almost as many idiocyncracies as Puppet so I have decided to explore the possibilities of saltstack.

So far I've managed to do most of what I want to do with salt and it has been far easier to get my head around it than I found with puppet, although there are still some conceptual things to understand as well as some gotchas that can stall things early on.

Come back later for a post on getting things up and running if you are interested.

The first good thing is that Salt does not require modules.

Another good thing is that Salt does not abstract away configuration details for most use cases.

Note: Salt has something called "pillars" that I have no understanding of. From what I have read these can get a bit more complex but for my purposes (installing packages & pushing configuration files) I have not yet needed to use those. If my requirements get more complex then I may have to visit them but the point is that as a new salt user you don't need to use them) 
Anyway, on a salt server, you would simply copy a working apache.conf over to a directory on the salt-master and the minions will just use it as is. Simples!

But what if you need to set some of those details on a per host basis I hear you ask? For example maybe I want to set the ServerName directive to be whatever the hostname of the server is?

In that case all I need to do is modify it like so:

ServerName {{servername}}

<VirtualHost first.example.com:80>
    ServerAdmin brett@mydomain.com
    DocumentRoot /var/www/first
</VirtualHost>


What I have done there is simply replaced the server name string to become a variable place holder that can be used by the jinja templating engine that salt uses to insert the proper data whenever the minion is updated.

I don't need to learn a whole new syntax because I can just use the standard Apache conf layout that I am already familiar with and make certain parts of it "variable" as required.

Salt really is in my humble opinion much simpler to get up and running (but that may just be because I'm a bit thick of course). Also no offence intended to the folks who love Puppet, I know it is widely used out there and I still have an inherited puppet system here at work. The bottom line is that OSS is all about choice after all.

That is not to say it is perfect however. The documentation leaves a lot to be desired for instance, which is a pretty big problem in itself.

Anyway, stay tuned for a quick start guide to SaltStack at a later date.

Friday, 12 December 2014

FIX: master and slave have equal MySQL server UUIDs

Newer versions of mysql use a unique UUID to do what the server variable server-id used to do.

That means if you need to do master/slave db replication each server will need its own UUID.

If the two servers have the same UUID, you will receive an error when attempting to sync the slave to the master:

master and slave have equal MySQL server UUIDs


If you are creating servers those servers from a virtual machine template then you will need to clear the UUID on each copy you make.

To do this, stop the mysql server and simply remove the file that contains the UUID

rm /var/lib/mysql/auto.cnf  


When you start the server again it will generate a new one automatically.

Tuesday, 7 October 2014

nvidia optimus

Trying to setup Mint Debian on a laptop with nvidia "optimus" is a bit different than the normal routine.

If you just install the nvidia-driver package and do nvidia-xconfig then when you try and reboot X will fail to start with;

"(EE) No Screens Found(EE)"

The reason for this is that the dual video card arrangement that Optimus provides is not supported "out of the box". You need to do a bit of extra work to get it working.

I am assuming that you have already installed the nvidia-drivers and linux kernel headers at this stage.

Next thing to do is make sure you remove /etc/X11/xorg.conf if you already have created that by using nvidia-xconfig. In fact at this point I recommend you remove nvidia-xconfig from your system entirely.

Next install some packages;

apt-get install bumblebee bumblebee-nvidia primus

Now, it would be nice to think that would be it but we do need to edit a file to get things working;


vi /etc/bumblebee/bumblebee.conf

Towards the bottom of the file in the [driver-nvidia] section change this line to look like this;


KernelDriver=nvidia-current

Reboot and you should be good to go.

You can test this by running this command;

optirun glxgears




Thursday, 2 October 2014

Windows 7 refuses to reconnect to Samba after reboot

Faaaaaark! I have been fighting this off and on now for weeks.

The scenario is this:

The network is a Windows domain. Let's call the domain "WINDOZESUX"

I have a Linux host running Samba that is not a domain member. Let's call it "sambaserver"

sambaserver is configured with:

workgroup = WINDOZESUX

Result: Windows 7 client can successfully mount \\sambaserver\share

That's cool.

Move forward until one of the Windows 7 clients reboots.

Result: Windows 7 client cannot reconnect to the samba share "The user name is not found"

Solution: Delete the saved credentials on the Windows client

Result: Windows 7 client can successfully mount \\sambaserver\share

Rinse, lather repeat.

Much troubleshooting follows. Eventually I had a dim recollection that I had "fixed" this once before by using an IP address instead of DNS

Solution: Use an IP address in the UNC path

Result: Windows 7 client can successfully mount \\1.2.3.4\share

Reboot and the share connects automatically without trouble. yay

Now, I was going to leave it at that (and I have for a while) but I really don't want to hard configure IP addresses all over the place because it can become a management disaster for the future.

Now, I have spent hours googling, found thousands of posts for basic errors such as noobs who just didn't have their DNS configured properly at, also a bunch of other posts suggesting that the share was trying to reconnect before the network adapter had come up which plainly was not the case because it worked fine with an IP address. No it was something do with DNS or WINS resolution. Or so I thought.

Suffice to say I spent a lot of time mucking about with WINS, DNS and SAMBA configurations and nothing made a lick of difference.

Eventually while clutching at straws I changed the sambaserver configuration to:

workgroup = LINUXROX

Went through the rinse, lather and repeat process and still it behaved in the same infuriating fashion.

Then while I was poking around in the Windows credential manager, about to delete the credential for the hundredth time, I clicked on "Edit credential"

Lo and behold, the username in the credential manager was shown as WINDOZESUX\username where I am sure the last time I had connected to the share it was using LINUXROX\username

Hmmm. So I changed the entry in the credential manager to the correct LINUXROX\username and rebooted again.

Result: Windows 7 client successfully remounts \\sambaserver\share

FFS. So it appears Windows has a bug (which knowing Microsoft may in fact be a feature) where when you connect to a non domain share from a domain member it does it correctly but when it saves the credentials it goes and changes the goddamned domain from the one you had specified to the domain that the client is on. But it only does that when you use a DNS name. When you use an IP address it works fine. Who knows why? Will Microsoft fix it? Why would they. They might however put up a technet article one day suggesting the solution is to buy a windows server you smelly Linux user.

God I hate Microsoft crap.

In other news, Bordlerlands 2 was just released on SteamOS/Linux!

Thursday, 28 August 2014

Recovering a deleted file that is still held open

I accidentally deleted the disk image file for a running virtual machine. oopsy!

Luckily, there is an easy way to undo that using the lsof command!

lsof | grep /home/qemu/images/my-disk-image.qcow2

This produces output like this;

qemu-kvm  24816      root    9u      REG              253,2 214781394944   21102665 /home/qemu/images/my-disk-image.qcow2 (deleted)

Take note of the first two numbers, which in my case are 24816 and 9 (Note: you must strip the trailing char from the second number)

Pause the VM  (don't stop it!) so that the disk is not being written to while we do the next step.

Now you just need to copy the deleted file back to somewhere safe;

[root@devkvm03 images]# cp /proc/24816/fd/9 my-disk-image.qcow2