Showing posts with label gnome. Show all posts
Showing posts with label gnome. Show all posts

Tuesday, November 03, 2009

Auto starting and shutdown of Virtualbox VMs

Just a quickie to document a nice simple way of automatically starting and stopping Virtualbox virtual machines when you login and shutdown your Linux box.

Firstly, what is the name of virtual machine that you want to do this with?
You can list the names of your VMs in a terminal as below
$ VBoxManage list -l vms|grep "Guest OS" -B1
...and choose the name of your virtual machine.

For this example my VM is called 'Windows XP' and my host is running Ubuntu 9.10, other distros running Gnome shouldn't be much different.

To autostart your VM upon login to Gnome...

Launch System > Preference > Startup Applications, select the Add button.
Then enter a name for the program in the Name: field and in the Command field enter;
VBoxManage startvm "Your VM Name"
Replacing the 'Your VM Name' with the name of your VM, if there are spaces in the name your will need the quotes.


Lastly to have your system cleanly stop your running VMs for you when you shut down your Linux box you can edit the vboxdrv init script. To do this you will need root privileges.

You have the choice of 3 methods of stopping the VM, a poweroff, an acpi button emulation or my preference, a savestate shutdown which will stop the VM and preserve it's runtime state, it will then resume the next time it is started.

Edit the init script with the nano text editor, if you have sudo setup or if you're using an Ubuntu/Debian style Linux distribution...
$ sudo nano /etc/init.d/vboxdrv
... and enter your password.

If you don't use sudo, you can su to root before running nano or you can use su as below..
$ su root -c nano /etc/init.d/vboxdrv
... and enter the root account's password.

In nano hit [Ctrl]+[W] to search and enter SHUTDOWN in caps. This will take you line 235.

A few lines down uncomment the appropriate "SHUTDOWN=" line of choice, for example to choose a savestate shutdown edit the line;
# SHUTDOWN=savestate
to read,
SHUTDOWN=savestate
Then hit [Ctrl]+[O] to save the change, then [Ctrl]+[X] to exit nano.


This will ensure that your system when shut down will cleanly stop your running VMs without you having to do so manually.

Sunday, August 09, 2009

Make Fedora 11 unlock your Gnome keyring automatically upon login.

I love Fedora 11, it's so clean and doesn't have the crushing Intel graphics driver bugs present in Ubuntu 9.04. However one bug/feature that is really annoying is that you are made to unlock the Gnome keyring manually whenever an application attempts to access your keyring for stored credentials.
For instance if your network connection is a wireless connection using WEP/WPA encryption, the Network Manager application cannot connect after you login until you've typed in your Gnome keyring password, most annoying.

It is possible to make your Gnome keyring unlock automagically after login using the tool pam-keyring-tool.

Firstly it's often recommended that you delete your current keyrings. I don't think this is necessary as such but if you find this solution doesn't work then delete the keyrings in a terminal as follows;
 rm -f ~/.gnome2/keyrings/*  

Then in your Gnome desktop browse to System > Preferences > Startup Applications.
Select the [Add] button.
Enter the name as something meaningful such as GNOME Keyring Unlock
Enter the following in the command field;
 cat ~/.keypass | /usr/libexec/pam-keyring-tool --unlock --keyring=default -s  

Then select the [Add] button.

Finally you'll need to put your account's password in a file in your home directory..

 echo "yourpassword" > ~/.keypass  

...and set some secure permissions on the file...
 chmod 400 ~/.keypass  

Finished.

Now logout and log back in, you'll no longer be nagged to unlock your keyring.
If you deleted your default keyring file earlier, you'll have to re-enter your previously stored passwords and keys (such as your WEP/WPA key) when prompted.