Move a Linux system into a virtual machine

I wanted to create a copy of my production system in a virtual machine to have a playground for experimenting. For this I cloned my system partition and put it into a virtual environment.

These are the steps:

For the cloning I used the Clonezilla live-CD ( I used the beginner mode to create an image of my source partition onto an USB drive.

On the host machine, I started Virtualbox to create a virtual machine with a disk size that is a little bigger than the size of the source partition. I created a disk of fixed size.

Now I had to trick clonezilla into restoring the image file to another partition number. Clonzilla does not support this. My source partition was sda6 and my destination in the virtual machine was sda1. This link form the Clonzilla FAQ shows how to do it.

After that, I booted the virtual machine with the CD image of the Clonezilla live-CD, plugged in my external USB drive and used the beginner mode again to restore the image to the empty partition inside the virtual machine.

Before rebooting the new system inside the virtual machine, I had to fix some details. For this I switched to the command shell of the Clonezilla system.

  • /etc/fstab - I had to remove the UUIDs for the drives and had refer to /dev/sdaX instead.
  • /etc/hostname - I changed the hostname of the virtual machine.

To get the new system inside the virtual machine to boot, I had to fix grub. The easiest way for me was to use the Super Grub2 Disk ( Set as an CD image in the virtual machine, it will boot into the installed system and allowed me to fix GRUB2 by running “sudo update-grub” in a terminal.

After that, I removed the CD image and booted into the virtual system and it worked immediately. I did not even have to boot into a safe graphics mode. It simply worked.

If you are using a PAE kernel, make sure to enable this feature inside your virtual machine.

Back to top

Improve GNOME login speed

The boot speed from GRUB to the GDM login screen is quite good these days. However the time from login screen to a working desktop can take a longer time.

Here is what can be done to improve login speed.

Go to System > Preferences > Startup Applications and uncheck all programes you do not need. If your computer does not have Bluetooth, deactivate it here. Same with personal file sharing, vino VNC server or the renaming of standard folders.

If you’ve added some extra application like a screenlet and you do not need it to be available immediately, you can delay its start up. For this, go to the hidden directory


in your home folder and look at the files with suffix desktop with a text editor. You can add a start delay of i.e. 20 seconds by adding this line to the desktop file:


After some experimenting you can find out a suitable value for your situation.

On my machine I replaced all individual calls to screenlets in autostart by one script that calls the screenlets sequentially. Here is my example:

# start daemon
/usr/share/screenlets-manager/ &
sleep 3
# battery
python -u /usr/share/screenlets/ACPIBattery/ &
sleep 3
# weather
python -u /usr/share/screenlets/ClearWeather/ &
sleep 3
# feed reader
python -u /usr/share/screenlets/FeedReader/ &

The corresponding desktop file has a delay of 20 seconds. So my desktop starts quicker and I can do some things before the screenlets are getting started.

Back to top

VNC viewer with panning

Once in a while I want to take over my desktop machine from my notebook.

On my desktop I can simply run

x11vnc -loop

to fire up the VNC server.

On the notebook I can connect via

vncviewer <hostname or ip of desktop>

Because the desktop screen is much bigger than the notebook screen, I have to deal with scrollbars in the viewer application to navigate on the big desktop screen.

My notebook has Intel graphics, so I can use xrandr to enable panning on a bigger virtual screen. So I wrote this little script to connect to my desktop pc sirius:

xrandr --output LVDS1 --panning "$REMOTE_RES"
vncviewer $HOSTNAME
xrandr --output LVDS1 --panning "$LOCAL_RES"

With this script the notebook screen switches to a big virtual screen with panning (screen window follows the mouse) before starting the remote desktop viewer. So no scrollbar handling an more :-)

Back to top