I'm running Ubuntu Desktop 12.04, and I was wondering if it was possible to somehow take my whole filesystem (everything under /) and create an ISO from it. Then, perhaps, use that ISO as the file system of a VBox VM (obviously, it would have to be Ubuntu, and probably 12.04).

Basically, I've spent a lot of time configuring my development machine, but need to be able to work on it from whatever computer I happen to be at. VMs seem like the perfect solution. Thanks in advance!


It'd probably be easier to create a fresh VM, install Ubuntu on it, and then back up your dev box and restore the backup to the VM. That'd give you a VM you could run on any machine where VirtualBox is, or could be, installed.

That said, is there a reason you couldn't just open up VNC or SSH access to your existing dev box, and access it remotely? If possible, that might well be a simpler option -- at the least, it'd save you some suffering every time you want to use the dev box from a new machine.

Hope this helps!

  • Thanks @Aaron Miller (+1) - what backup tool might you recommend, and how does it work? Does it back my entire PC into some file that can then be used to overwrite the entire file system on the VM? Thanks again!
    – pnongrata
    Oct 1 '12 at 16:46
  • 1
    Glad to be of help! As for a backup tool -- man tar is what I'd recommend here; it's not the most welcoming interface, perhaps, but if you just tar up / on the dev box (making sure to avoid /proc, /sys, /dev, and /root via the --exclude option) and untar the result on your VM, you'll probably have about what you need. (I would, though, think hard in your shoes about whether it's possible to just bring across the development stuff without touching the rest -- perhaps copy /home/username across and do the rest via apt, for example. Always best to do the least amount of work necessary, I say.) Oct 1 '12 at 17:46
  • 2
    Though very informative and helpful, this suggestion should be a comment and not an answer. It does not answer the question.
    – dotancohen
    Oct 2 '12 at 6:13

you can dump your hd into an image with dd then convert the image to a vmdk or whatever.

apt-get install qemu (installs QEMU on debian/ubuntu)

qemu-img convert imagefile.dd -O vmdk vmdkname.vmdk

taken from: here

  • I don't know for sure if this will work but +1 and I'm going to try.
    – Mikey
    Oct 1 '12 at 18:27
  • 1
    You can also use the image in VirtualBox. Ubuntu normally installs drivers for various hardware (unlike Windows), making it more portable, so this will generally work. Oct 1 '12 at 19:51
  • 2
    This will not just work. The file /etc/fstab is the file your system reads to know what disks mount where. The disks are stored by a uuid, and when you make a new disk this won't be the same. You will need to edit this file on the new system to fix that. Also network cards will be renamed (that would happen anyways.) Oct 1 '12 at 20:51
  • Also to make the image, you should run a live cd with the disk not mounted. Store the image on another disk.
    – nikhil
    Oct 5 '12 at 16:09

I did this previously on a Windows XP machine, but I guess you can do it in Ubuntu as well. But it uses vmware, not virtualbox...

Install vmware-converter (free product) in your Ubuntu box. Then convert the physical system to a virtual system, after tweaking configuration settings.

After this, you have you virtualized image that can be 'played' with vmplayer.

  • 1
    VirtualBox will be able to use VMDKs created in this way.
    – bfhd
    Oct 1 '12 at 22:10
  • Doesn't work that well, you need a vmware server on your network to which it exports the image. I had no luck with it.
    – nikhil
    Oct 5 '12 at 16:10

Another option might be to clone your OS into a VirtualBox disk image:

vboxmanage createhd --filename foo.vdi --size 10240

modprobe nbd max_part=16
qemu-nbd -c /dev/nbd0 foo.vdi

# create a partition (will automatically produce a new device /dev/nbd0p1)
sfdisk -D /dev/nbd0 <<EOF

mkfs -t ext2 /dev/nbd0p1
mount -o loop /dev/nbd0p1 /mnt

# clone your OS
rsync -aH --exclude mnt --exclude dev --exclude proc --exclude sys / /mnt/

# install the boot loader on the virtual disk
mount --bind /dev /mnt/dev
chroot /mnt grub-install /dev/sda

umount /mnt
qemu-nbd -d /dev/nbd0

rmmod nbd

So there are one of two ways to do this. To make an ISO directly you should use Remastersys. This is a tool that will allow you to create an ISO of the current system. You can then boot off the ISO and get that enviornemtn as a LiveCD. A good guide can be found here.

If you want to make a VHD (virtual hard disk) from the physical disk, they only tool I know of would be disk2VHD. That is a Windows only tool. However, you can also use the Linux tool dd. There is a good tutorial for this found here.


Copied from (http://karim-ouda.blogspot.com/2011/11/how-to-create-virtualbox-image-from.html)

sudo dd if=DRIVE | VBoxManage convertfromraw stdin FILENAME BYTES

Real Example

sudo dd if=/dev/sda | VBoxManage convertfromraw stdin MyLinuxImage.vdi 120034123776


  1. To get the number of bytes in partition, you can use the following command sudo fdisk -l /dev/sda

  2. You need to use /dev/xxx not /dev/xxx1 or xxx2 so that the image contains MBR records


To start you can create a disk image using the partimage utility in a command line interface. After this I imagine you would be able to boot the newly create iso with VMware.

Using Partimage If you are using Ubuntu 12.04 or even 11.04, Partimage should be available from the Ubuntu software center. This installation method will allow you to easily search and install your selected software.

Step 1. Open the Ubuntu Software Center and locate the search bar in the top right hand corner of the window. Type "partimage" in the search bar then press enter. The partimage software package will be the first to display. Also returned from this search are partclone (utility to clone and restore a partition), partimage-server (use partimage across a network), and partimage-doc (partition image user documentation). You will want to click install and let the software center install the package for you.

Step 2. Open Terminal and enter the following command " sudo partimage", then enter your password and press enter.

Step 3. After entering your password the Partimage application should display in the Terminal window.

Step 4. Understanding the available options.

* Partition to save/restore -  A list of all available partitions on all drives able to be backed up from or restored to. You may only choose to operate on one partition at a time. 
* Image file to create/use - If creating a new image file enter the path and file name where the created back up will be written. If using an image file to restore a partition or drive enter the path to the mounted drive where the file is located. 
Action to be done: 
    (*) Save partition into a new image file - Choosing this option will tell Partition Image to create a backup .img file from the partition selected in "Partition to save/restore", and write the file to the path entered in "Image file to create/use."
    (  ) Restore partition from an image file - This option will write the image file from the path entered under "Image file to create/use", and write it to the partition and/or drive selected under "Partition to save/restore."
    (   ) Restore an MBR from the image file - This will restore the MBR to the drive selected under "Partition to save/restore" to the image file contained in the path under "Image file to create/use."
[  ] Connect to server - This option will allow you to connect to a remote server to read or write an image file.

Step 5. This screen is fairly self explanatory. You will first want to select the desired compression level if any. You may also change how the image will be split during the writing process. The default mode is to create a 2Gb files. The final option gives Part Image instructions on what to do if it finishes the job succesfully. Choose which ever option is most appropriate for your situation.


  • Have you tried your solution?
    – user66001
    Nov 11 '15 at 15:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.