Player Image

Converting a physical partition with freebsd to a vmware image

There are many virtualization solutions today, but I chose a VMware solution for purposes of this article (conversion of a physical partition), as VMware is a pioneer in virtualization industry, company’ products are very fast, extremely portable, and many of them are free. VMware images are playable in VMware Player, which is also free for platforms that support it. This means that you can carry VMware Player and your images anywhere on a USB disk and play them without restrictions in Linux and Windows.

Putting a VMware image back to a physical disk is quite simple, too, but I will mostly focus on how to make a portable FreeBSD (applicable also to OpenBSD) virtual computer. I decided for this solution because my motherboard recently died. I realized that with a portable virtual computer on a portable USB disk I can enjoy real freedom.

Although I have a notebook, my Internet browser in it is without e-mail accounts and without all my bookmarks, music and books. When my motherboard died I understood that I must have a couple of virtual images, but not just the ordinary ones like I can download from the Internet, but the ones with all the software I love and with all my personal customizations – something an image of a virtual PC downloaded from the Internet can never substitute.

What you must do to convert a physical disk to a VMware image?

I will carefully describe all the steps I did, but as we are moving into the waters of portability, I must, too, leave the BSD ocean and move into Linux or Windows waters.

1) You must prepare an empty and configured (with CD-ROM devices, disks, networking, etc.) VMware image (the configuration is actually held in an accompanying VMX text file).

To do this,

a) either use proprietary VMware software; there are several packages, VMware Server is free (Linux and Windows);

b) or download one of many VMware images (free premade appliances), delete its content and use it; however, one of the drawbacks of this solution is that the premade images for VMware Player do not always come in the sizes you may like.

c) You may use some free utilities like qemu-img, which is included in the Qemu package and which creates empty disk images for use not only with QEMU, but also with VMware products. VMmanager is another free tool that does the same job but in Windows.

2) Before you make the backup, empty spaces on your physical partition must be zeroed, otherwise the gzipped partition will be too big. FreeBSD has internal partitions, so run the following command in all of them:

dd if=/dev/zero of=/usr/000file bs=200M

Note please that I use the term “partition” here as it is used generally for Windows or Linux. However, in the FreeBSD terminology I should use “slice” (“s” in device such as ad0s2). In FreeBSD, partitions (internal partitions that fdisk of Windows or Linux does not see) have letters assigned to them (ad0s2a, ad0s2d, etc. – that is, here we deal with slice 2 and internal partitions “a” and “d”).

After a very big file is created in /usr with the above command, delete it and run the command again, but point the execution of zeroing empty spaces into /var (of=/var/000file), /tmp, etc., because FreeBSD (during its installation process) always assigns (and mounts) its own internal partitions to these directories (/ = ad0s1a, /var = ad0s1e, /tmp = ad0s1d, etc.). To avoid possible boot problems, make sure that you copy (backup) the physical partition (if unsure, look into /etc/fstab) from /dev/ad0s2 to /dev/ad0s2 (not to /dev/ad0s1 in your virtual image). If the FreeBSD partition on your physical Hard Drive is /dev/ad0s2, make two primary partitions in your virtual image and restore the backup to /dev/ad0s2 (not to /dev/ad0s1). However, FreeBSD boots more intelligently than Linux. In case you have a different disk specified in /etc/fstab in your physical hard drive, the system (shortly after it boots) will ask you to supply the correct boot device. I inform about this because I took care of this issue and I advise you to do the same.

3) Now you must backup your FreeBSD partition. You may use any image creation program (like Norton Ghost, Acronis, etc.) that makes an image of a physical disk, or just use the following Unix command: dd if=/dev/ad0s2 bs=1M | gzip -2 > /mnt/diskimg.gz (and replace /dev/ad0s2 with your own device).

4) The VMware image must be partitioned and you must use the primary partition for FreeBSD (not a logical one). The size of it cannot be smaller than the size of the uncompressed image (the copy of your physical disk) now residing in the gzipped file (or in the Norton Ghost’s GHO image, etc.). To partition your virtual disk, you can also use the standard FreeBSD sysinstall tool (available on a bootable installation FreeBSD CD/DVD), or utilities such as gparted.

In my case I used an old DOS version of Partition Magic (I created three unformatted primary [DOS] partitions in my virtual disk) – I made two small primary partitions and the one required for FreeBSD (/dev/ad0s3).

5) You must create a bootable ISO image with the compressed (gzipped, etc.) partition in it; after you boot your virtual computer with it, restore the copied physical partition to your newly created VMware image. The way I did this was that I prepared a bootable ISO of the Norton Ghost image (compressed physical partition) with a bootable DOS floppy image in it (run the command like: mkisofs -b DOSfloppy.img -o /mnt/DOSandIMAGE.iso . With the dot at the end of the command mkisofs will put the directory where you presently work into the ISO file, so keep also your partition in the GHO or gzipped format in this directory). If you want to do it the same way as I did it, visit and download some DOS/Win98 floppy images.

The dd command to restore the image can be used, too, but you need some Unix bootable floppy or CD/ISO. If you feel a little bit uncertain, use the NetBSD tool g4u, which is Harddisk Image Cloning for PC’s and which works the same way as Norton Ghost.

You may also work with two ISO images; however, one of them must be bootable (ISO image of g4u, for example; the other ISO image containing your copied physical partition does not need to be bootable in case you use two CD-ROM’s – that is, two ISO files).

6) After you create the partition(s) with fdisk (or gparted, Partition Magic, sysinstall, etc.) in your VMware image and with the size corresponding with the size of your physical FreeBSD disk, reboot the virtual computer. With a DOS or Unix bootable floppy or bootable CD (ISO image) you may now restore the backup. To do this with dd in Unix, run the command:

gzip -dc /path/to/image.gz | dd of=/dev/ad0s1

In case you decide to go on with the Acronis products, you can easily create a bootable CD applicable for image creation and restoration. But in this case the easiest way is to put the Acronis image file (the copy of your FreeBSD physical disk) into another ISO image (with mkisofs). With utilities such as g4g or Live CD’s such as my MaheshaBSD project and with a second computer around it is painless to restore the copy of your physical disk via FTP in Unix. MaheshaBSD has a working VSFTPD server in it, so just boot two computers with this CD and run the dd or the dump command to restore the image. It can even reside on a NTFS partition, as MaheshaBSD has no problem to mount NTFS volumes. To learn how to use networking in your virtual computer, see Some Questions And Answers below.

The last and very important thing is to make sure that the virtual partition that holds your FreeBSD in it is set active. You may also install FreeDOS, or some very small Unix systems (or even full installation of OpenBSD) onto the first two small partitions (if you have them) and use GAG boot manager to switch between them (multiple boot). This does not mean that small partitions are really needed, but they may appear very handy for testing purposes.

Some Questions and Answers

How to play your VMware images in FreeBSD?


In VirtualBox, just select File > Virtual Media Manager, click on Add in Virtual Media Manager and select your newly created VMware VMDK file. VirtualBox runs under FreeBSD very well and it is free.


Alternatively, you can use some conversion utilities like qemu-img and convert the VMware virtual disk for use with Qemu. Unfortunately, Qemu is slow, but there are a lot of sites dedicated to VMware-to-Qemu conversion. You need to install Qemu and use its qemu-img utility:

qemu-img convert win2kpro.vmdk -O qcow win2kpro.img


Running VMware on FreeBSD as a host is possible, but only older versions of VMware Workstations run. I recommend using VirtualBox.

Is it possible to convert VMware disk image (VMDK) to Xen?

Yes. You will find many websites that deal with this issue. However, there may be some little problems, so check them out. For the conversion you need the vmware-vdiskmanager tool that comes with VMware Server (for example, VMware Server 1.0). Check the website.

How to play your VMware images in Linux/Windows?

Download VMware Player, VMware Server, or VirtualBox. All alternatives are free and available for several platforms. To use your VMware image with Windows, edit the VMX file in notepad and change the syntax for CD-ROM and floppy devices (if you need them). Change:

ide1:0.fileName = “/dev/acd0″ to ide1:0.fileName = “H:”

floppy0.fileName = “/dev/fd0″ to floppy0.fileName = “A:”

Use the real letter (H: or I: or G:) that Windows assigned to the CD-ROM device.

In Linux the VMX file must describe these devices as they are known to the hosting Linux system. If your CD-ROM device is /dev/sr0 in Linux, you must have the following line in your VMX file: ide1:0.fileName = “/dev/sr0″

How to use the Internet?

The le (or em) driver handles networking. I configured my VMware image with a bridged networking and used the dhclient command to connect to the Internet (dhclient le0). It worked.

How to run X?

Before you backup your physical FreeBSD partition, install the Xorg VMware driver. It is in /usr/ports/x11-drivers/xf86-video-vmware. You can do this even after copying your physical partition to the virtual image. Running the command Xorg -configure in your virtual computer is necessary, too. Depending on the version of Xorg, sometimes adding the command Option “AllowEmptyInput” “Off” to your newly generated xorg.conf is necessary for your mouse to work. Then just run the startx command and enjoy.

Are VMware tools necessary?

The company does not presently support use of VMware tools (a special package of VMware enhancements) for FreeBSD and they are actually not needed at all for networking or X.

How to put a virtual computer back to a physical partition?

You must use the same method but reversely (the dd command, Acronis, Norton Ghost, g4u, etc.) – back up your virtual computer. To do so, you only need another (empty) virtual disk or just an FTP storage. After making a copy of your virtual disk you must make a bootable CD/DVD with it. Use the same standard way you use for restoring physical partitions.

Are there any special tweaks recommended?

Reduce kern.hz (Kernel Timer Frequency), as the FreeBSD’s default value of kern.hz is set to a relatively high number. High kern.hz value is beneficial on real hardware. To check your present kern.hz value on the system, type: sysctl kern.hz and if it is over 100, make your virtual FreeBSD a little bit faster by adding the following line to your /boot/loader.conf: kern.hz=45

How about sound and video?

I did not make any changes and the sound and video worked (ogg, mp3 files, avi, mpg, etc.).

May I use snapshots with FreeBSD?

Yes. Snapshots, a very valuable feature of every good virtualization software today, save your time, because you immediately restore your virtual system to the point you left it the last time (starting your virtual machine again but without booting it), but they bring a very big security problem.

Anybody who has a physical access to your virtual computer’s snapshot may (after he or she restores it) read your emails (if a snapshot was made with Thunderbird active on your desktop), or perhaps grab your passwords. Use snapshots in physically secure environment only (do not carry them on portable USB disks that you may lose). Although you may argue that anybody can boot a virtual FreeBSD machine in a single user mode, you are right, but this article is not primarily about security. When someone opens your VM in single user mode it is still a bit harder for him or her to access other encrypted stuff that is not left as an easy prey on your desktop (seen immediately after a snapshot restoration). However, the rule of thumb is that the same security measure you apply to your car keys do also apply to your virtual machines and keep them always away from prying eyes.

The article first appeared in the 2011 April issue of BSD magazine ( – free computer magazine (feel free to download it and see the article also with pictures).

About the Author

Juraj’s karma with FreeBSD

Let’s Play Mission 2: Team Player (Buy Modern Warfare 2?)

Pyle PSW Waterproof Neckband MP3 Player and Headphones for Swimming, Water Sports

Pyle PSW Waterproof Neckband MP3 Player and Headphones for Swimming, Water Sports


Official Licensed FC FCB Barcelona THERMAL Travel Coffee Mug Cup - w/ Player IMages

Official Licensed FC FCB Barcelona THERMAL Travel Coffee Mug Cup – w/ Player IMages


Official Licensed FC FCB Barcelona THERMAL Travel Coffee Mug Cup – w/ Player IMages. OFFICIAL LICENSED GENUINE – GUARENTEED!! (Please see photos). The Measurements are as follows: Height: 7.25″ (18.5 cm), Diameter of top: 2.5″ (7 cm)…

Spots8® for HTC Desire 610, Glossy Image Graphic Design on 2 Piece Snap-On [Slim Fit] Hard Protective Case Cover [Retro Game Player]

Spots8® for HTC Desire 610, Glossy Image Graphic Design on 2 Piece Snap-On [Slim Fit] Hard Protective Case Cover [Retro Game Player]


Protect your device with style and carry your phone with you knowing that it is protected with this product. This case is designed to offer you protection for your expensive device by preventing daily scratch, bumps, and dings. Precision and detail to cutouts will allow you full use of your phone’s functionality without any interference. The 2 piece snap on case will offer your device maximum prot…

IMAGE® Mini USB Turntable Built in Speaker Vinyl Record to MP3 CD Converter Supports Windows XP/Vista/7/Mac

IMAGE® Mini USB Turntable Built in Speaker Vinyl Record to MP3 CD Converter Supports Windows XP/Vista/7/Mac


It could be used as a turntable player with built-in speaker. And it can transfer vinyl tape audio into MP3/WAV by professional software through connecting with PC. To keep classic music audio forever and memorable Vinyl LP audio!
1, Turntable Convert LPs to audio files via USB connection to Mac or PC. 2, Turntable Recordable Turntable with Speaker and main Volume. 3…

Tetris Mens T-Shirt - Epic Fail A Very Bad Player Image (XX-Large) Black

Tetris Mens T-Shirt – Epic Fail A Very Bad Player Image (XX-Large) Black


This black 100% cotton tee is perfect for fans of Tetris….

Cleveland Cavaliers 308S Lebron James Mega Mesh Mens Crew Socks

Cleveland Cavaliers 308S Lebron James Mega Mesh Mens Crew Socks


Officially licensed, brand new with tags, For Bare Feet Mega Mesh 308S NBA Cleveland Cavaliers basketball men’s socks feature image of player LeBron James, team logo, and number 23 jersey in sublimated mesh design. Stretch fabric for ultimate comfort, moisture resistant; padded heel for performance. Fits approximately men’s shoe sizes 10-13. 94% Polyester, 5% Rubber, 1% Spandex….