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 www.bootdisk.com 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?

VirtualBox

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.

Qemu

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

VMware

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 Wiki.xensource.com 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 (http://www.bsdmag.org/) – 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?)


NFL Seattle Seahawks Russell Wilson Wilson R. #3 Player Image Scarf


NFL Seattle Seahawks Russell Wilson Wilson R. #3 Player Image Scarf


$21.73


100% officially licensed product from Forever Collectibles…

2015 NFL Team Player Image Scarf - Pick Team


2015 NFL Team Player Image Scarf – Pick Team



Keep warm during those brisk fall and winter days while supporting your team in style with this 2015 Player Image Scarf from Forever Collectibles! The scarf features woven Team Colors, Player Image and Number. Measures approximately 64 x7 and is made of 100% Acrylic. Makes a great Gift…


NFL Denver Broncos Super Bowl 50 Champions Player Image Can Coolers Set of 2


NFL Denver Broncos Super Bowl 50 Champions Player Image Can Coolers Set of 2


$12.60


NFL Denver Broncos Super Bowl 50 Champions Player Image Can Coolers Set of 2. Celebrate the Denver Broncos winning Super Bowl 50 with these can coolers! These full color imprinted 12 oz. can coolers with an imprint area of 4″ x 8″ made with 1/8″ neoprene feature players Aqib Talib, Demaryius Thomas, Von Miller, and Peyton Manning. Sure to make a great gift for your favorite fan!…







Sharper Image SBT4001BK Bluetooth Streaming Turntable Sound System with Two External Stereo Speakers (Black)


Sharper Image SBT4001BK Bluetooth Streaming Turntable Sound System with Two External Stereo Speakers (Black)


$69.99


It’s a turntable with a twist: this Turntable Stereo System by Sharper Image has everything needed for an incredible audio setup right out of the box. Flank the Bluetooth-enabled turntable with the included stereo speakers for an immersive audio experience-no additions required. Simply place the record on the manual turntable, match the turntable settings to the vinyl on the platter, and enjoy e…

The Sharper Image Touch MP3 Video Player 4GB with Pro Headphones (Stores and Plays Music, Video, & Pictures)


The Sharper Image Touch MP3 Video Player 4GB with Pro Headphones (Stores and Plays Music, Video, & Pictures)


$49.00


Perfect for digital music addicts, this Sharper Image MP4 is riveting and dynamic. The realistic digital sound quality featured on the Sharper Image SMP558 music player allows you to crank up your favorite tunes and jams as loud as you care to. With the copious data storage capacity featured on this digital media player, you can store your cherished song titles for your enjoyment whenever you like…

Michael Jordan Last Shot 24x36 Poster Chicago Bulls


Michael Jordan Last Shot 24×36 Poster Chicago Bulls


$0.90


Michael Jordan – The Last Shot 36×24 Poster Art Print Nba Superstar Poster…







Michael Jordan Success Inspirational Motivational Sports Basketball Icon Quote Poster Print 12x24


Michael Jordan Success Inspirational Motivational Sports Basketball Icon Quote Poster Print 12×24


$9.34


This poster features a quote by basketball legend Michael Jordan, in stylish typography. The quote reads “I’ve missed more than 9,000 shots in my career. I’ve lost almost 300 games. 26 times, I’ve been trusted to take the game winning shot and missed. I’ve failed over and over again in my life. And that is why I succeed.”….







Brain Quest - Find Your Friends


Brain Quest – Find Your Friends


$28.99


Gizmo and his Brain Quest friends come to life in this game of seek and find! Players race to find images of Gizmo and his Brain Quest friends in various disguises. The winner is the first and fastest to find the hidden characters.

Michael Vick Philadelphia Eagles 2-photo Frame


Michael Vick Philadelphia Eagles 2-photo Frame


$135.99


Show off your team spirit with this Philadelphia Eagles-themed framed picture, featuring an image of player Michael Vick.

Zippity Do


Zippity Do


$19.29


It’s the singing party game for kids. 6 picture cards are spread out on the table. One-by-one players take turns singing a song with one of the images. Remaining players try to be the first to identify what picture card is the subject of the song.

Paul Frank Boatload Of FUN


Paul Frank Boatload Of FUN


$23.49


Julius and his friends come to life in the first board game by Paul Frank for kids. Players race to find various images of their favorite characters from outer space, schoolyards, the shopping mall and the high seas. More than 100 images in all.

NHL 2011 Boston Bruins Stanley Cup Champions Ready-to-hang Plaque


NHL 2011 Boston Bruins Stanley Cup Champions Ready-to-hang Plaque


$19.99


Celebrate the exciting 2011 Boston Bruins Stanley Cup victory with this championship plaque. Featuring images of each player on the 2011 Boston Bruins team, this plaque comes framed and ready to hang on your wall to celebrate your favorite team.

NBA Portland Trail Blazers Signature Court


NBA Portland Trail Blazers Signature Court


$49.99


Show your support for the Portland Trail Blazers with this unique signature court NBA memorabilia. Officially licensed, this plaque features the replicated signatures of your favorite players over the home court image.

NBA San Antonio Spurs Signature Court


NBA San Antonio Spurs Signature Court


$49.99


Show your support for the San Antonio Spurs with this unique signature court NBA memorabilia. Officially licensed, this plaque features the replicated signatures of your favorite players over the home court image.

Stenzzles Artistic Layering Puzzle Tropical Collection


Stenzzles Artistic Layering Puzzle Tropical Collection


$14.79


This innovative puzzle challenges players to replicate a colorful image by layering the 8 Stenzzles cards together in the correct order and orientation. Select from 8 challenges and flip, rotate and layer the cards until they match the challenge image.

Johnny Manziel Texas A&M Special Edition Photo Mint Gold Coin


Johnny Manziel Texas A&M Special Edition Photo Mint Gold Coin


$299.99


This limited edition print features an action image of your favorite player Johnny Manziel as a member of the Texas A&M Aggies football team. This image and coin set is officially liscented by the CLC and NFLPA.

2010 Green Bay Packers Quartz Clock with Black Marble Finish


2010 Green Bay Packers Quartz Clock with Black Marble Finish


$37.99


Cheeseheads can share their love of the Green Bay Packers with friends and family with this fun sports clock. The plaque design features a large image of the Packers top players from 2010, reminding you of your pride every time that you look at it.

NHL LA Kings 2014 Stanley Cup Champions Celebration Signature Rink Frame


NHL LA Kings 2014 Stanley Cup Champions Celebration Signature Rink Frame


$49.99


Show off your team pride with this wonderful Los Angeles Kings Stanley Cup Champions Celebration Frame. Featured in this collectible frame is the facsimile, replica signatures of the players on the team displayed over an image of the team celebrating.

2013 Stanley Cup Champions Celebration Faxed Signature Rink


2013 Stanley Cup Champions Celebration Faxed Signature Rink


$49.99


This unique 12×20 collectible frame features an individually hand numbered 13×19 photo of the Stanley Cup Champions celebrating their victory on the ice after clinching the title. The players replica (facsimile) signatures are overlaid on the image.

2013 Stanley Cup Champions Faxed Signature Rink


2013 Stanley Cup Champions Faxed Signature Rink


$49.99


This unique 12×20 collectible frame features an individually hand numbered 13×19 photo of the Stanley Cup Champs huddled around the Stanley Cup following their clinching victory. Complete with the players replica signatures that are overlaid on the image.

Chicago Blackhawks 2015 Stanley Cup Champions 'Celebration' Signature Rink


Chicago Blackhawks 2015 Stanley Cup Champions ‘Celebration’ Signature Rink


$49.99


The 2015 Stanley Cup Champions Celebration Signature Court features the facsimile (replica) signatures the players on the team roster displayed over an image of the team celebrating after clinching the title. Each is individually numbered.

JaLink Board Game


JaLink Board Game


$30.99


JaLink is a high-speed creative free-for-all that pits players against each other in a race to associate images in ever-changing ways. Think up a new connection and shout JaLink to collect your kudos.

Slangology Board Game


Slangology Board Game


$29.49


In this hilarious, off-the-hook party game, players try to define slang terms by combining outrageous images and witty captions. Slangology is the new fantabulous board game that will have everyone laughing out loud.

Rally Up


Rally Up


$22.69


What happens when 110 illustrated cards are shuffled and turned face up on the table. Players will race to rally up 2 or more images belonging to the same family. Scan swiftly through the craziness to get these thingies back to where they belong.

Pluckin' Pairs


Pluckin’ Pairs


$24.69


Each player gets 60 seconds to pair up eleven images at the same time: five pairs and one bad apple. Players gain points by matching the most other players with the same pairs. Test your powers of prediction with this fun family game.

Mindware Get the Picture Game


Mindware Get the Picture Game


$34.99


In this brain-bending spin on dot to dot puzzles, two players or teams race to identify their mystery images by following secret clues. The clue windows on the game board reveal a series of dots to connect, or a special puzzle-solving hint to decipher.

Word Dominoes: Play With Pictures - Win With Words (Game)


Word Dominoes: Play With Pictures – Win With Words (Game)


$18.82


From the minds behind the bestselling Haikubes, this creative new twist on an old favorite invites players to create words and phrases by linking images. Match what other players are thinking to win! With 42 sturdy dominoes, 84 images, and unlimited co…

The National Baseball Hall of Fame Almanac 2015 (Paperback)


The National Baseball Hall of Fame Almanac 2015 (Paperback)


$15.38


This title is the most comprehensive reference book on the membership of the National Baseball Hall of Fame and Museum. The book contains exclusive Hall of Fame content including plaque images, photography, player biographies and statistics as well as …

Foundation ActionScript 3.0 Image Effects (Paperback)


Foundation ActionScript 3.0 Image Effects (Paperback)


$28.76


Provides information on ActionScript 3.0 bitmap data and image manipulation along with the features of Flash Player 10.

THEE IMAGE - THEE IMAGE/INSIDE THE TRIANGLE: REMASTERED EDITION


THEE IMAGE – THEE IMAGE/INSIDE THE TRIANGLE: REMASTERED EDITION


$10.2


Thee Image were formed in 1973 by former Blues Image, Iron Butterfly and Cactus guitarist Mike Pinera and keyboard player Duane Hitchings, formerly with Buddy Miles. Pinera’s first band, Blues Image scored a US hit with the single “Ride Captain Ride” a…

Trash Talk (Hardcover)


Trash Talk (Hardcover)


$12.22


Football, baseball, basketball, hockey – pro athletes revolt! Too many fights, too many problems, lousy image! The commissioners are fed up and players are angry at mandated, educational seminar attendance! But that’s what happened, and the commissione…