Emulators, image files and installation voodoo

I have mentioned a number of times that I usually install distros across the USB port on the Mebius, but I haven’t gone into much detail about how that works.

It’s not the best way, probably, to install a full system to a machine this old, but in some senses it’s the only way to do it without running aground on memory limitations, or the need to install from a live system.

In short, you’ll need these things:

  1. An ISO image for the distro you want to install. You’re going to boot that in an emulator, so you don’t have to burn it to a CD.
  2. A working, running copy of Qemu on a system that is considerably faster than the target machine. I strongly recommend qemu-launcher too, just because it makes it easier to configure the emulated system to match your target. More on that later.
  3. A USB port of any speed on the target machine. That’s fairly obvious. Although it is possible to do this by writing an image to a drive in an enclosure, but then why would you be bothering with these instructions? :P
  4. A CD copy of Slitaz base, although something like DSL is as usable. This is what will boot the target machine to a live environment, and allow us to write the image to the target drive.
  5. A USB flash drive of whatever size you prefer.

I use a USB key of 2Gb; that’s more than enough to hold a root filesystem and home directories for most distros, and it only takes about 45 minutes to write all of that across USB1.1. And it’s cheap, which makes it a comfortable compromise between size, price and time.

Start up qemu-launcher and set it to acknowledge your network device and keyboard layout. Depending on the distro you’re installing, it might expect (or even need) network access on start.

Point qemu-launcher at the ISO you’re using, and then for an emulated hard drive, tell it you want a RAW file of the same dimensions of your USB drive. If it’s too big and you end up partitioning a file that doesn’t fit on the drive … well, needless to say that might be a problem.

Now boot the emulated system, and install it to the emulated drive. I can’t help you with that part. ;)

When you’re done, make sure you shut down the emulated system correctly and cleanly. If you close the emulated system without a correct shutdown, the system might not write out its contents fully. And that spells trouble. :|

Now comes the fun part. Put your USB stick in your fast computer, and check where it appears. Enter this as root:

fdisk -l

Watch for the drive assignment that matches your USB stick. Mine is usually /dev/sdb or /dev/sdc. Now write out the file to that device — not a partition on that device, the full device itself. Again, as root:

time dd if=emulated-system.img of=/dev/sdX

where X is the letter assigned to your drive. (time is just for fun.) Be absolutely sure you have the right drive before you start this command. If you accidentally write it to the wrong place, there is nothing that will recover it for you.

Now wait. Over USB2.0, a 2Gb file writes out in less than three minutes.

From here, we simply reverse the process. Start your target machine with the Slitaz base CD, or boot to a live environment that works for you. (As always, check out PLoP or Smart BootManager if you have a system that doesn’t boot from CD.)

Now insert the USB drive and check the drive assignment again.

fdisk -l

Then write the contents of the USB drive to the target drive.

time dd if=/dev/sdX of=/dev/hdY

Again, this can take a while. Drive write times and system speeds come into play here too. A relatively fast drive might be able to write quicker, but an old 4200rpm clunker is going to take forever, and rattle your ears too.

When it’s done, so are you. Bring the machine to a halt gracefully, then cycle the power. It should boot into your emulated, transferred system, unless something went weird.

Which is always a possibility. But just for comparison’s sake, it usually takes about three hours for me to install Debian via netboot to the Mebius, and that’s only to get to a console system. (Just to be clear, downloading the packages takes only about 10 minutes. The other three hours is for installation.)

On the other hand, I can install a console system in an emulator in about an hour on my X60s and write the entire business to the Mebius in about 45 minutes.

So for the time it takes to install Debian once on the host system, I can probably do it once in the emulator, write it across, troubleshoot it, and possibly do it again if I have to.

And the added bonus is that you have a file that represents a clean and pristine system, so if you misconfigure the target or scramble things badly, you’re only an hour away from a clean and fresh system. …

A few final points:

  • If you’re installing to a drive larger than your USB key, you can add the home directory later by partitioning the remainder of the drive and editing your fstab to point /home at it. Just as an idea. ;)
  • Remember that Qemu (and probably other emulators too) will report your architecture to be the same as the system they’re running on. That’s important for distros like Debian, which will install a system to match your processor. In other words, if you’re using something like Debian for an old, old machine, you want to make sure Qemu is set to emulate an i486. Otherwise, Debian will assume you’re using a modern processor, and install the 686 packages. And your target machine won’t boot. And you will cry. Of course, the other option is to tell Debian you want the expert install, and pick i486. … Congratulations, you’re an expert! :lol:
  • If you get crafty and think you can keep a library of emulated systems, I recommend against compressing those image files to save space. I tried that once and after decompressing it, it wouldn’t work. Things were really messed up. So just be aware, those image files probably shouldn’t be altered too much. ;)
  • Finally, you can try this with Windows as well, but I haven’t had as much luck getting it to boot after writing it into place. It might require reinstalling the master boot record; I don’t have enough interest to chase it that much. :roll:

That’s all. Have fun.

P.S.: Reverse the entire process for system backups … if your system drive isn’t too big. … :mrgreen:

About these ads

9 Responses to “Emulators, image files and installation voodoo”

  1. 1 snek 2010/11/15 at 7:12 PM

    Ha, just what I had emailed you about :)

    Guess you realised you hadn’t really written out your process for others to use?

    Glad to see it online now though, always handy for reference.

  2. 2 chris 2010/11/16 at 1:43 AM

    hm, I don’t see the need to use an image file for the hard disk, I would only use something like qemu -hda /dev/sdX …

    Actually, I don’t even use a usb stick for those cases. I got a ide-usb convertor that includes laptops’s ide. (like this one: http://img594.imageshack.us/img594/6901/00007625.jpg)
    So I connect the laptops hard disk and use qemu directly on the drive.

    • 3 K.Mandla 2010/11/16 at 6:03 AM

      Techically it’s not needed, but I like to keep clean and fresh installations on a spare drive, so I can rewrite them if I want to start from scratch. A small added bonus, from my perspective. ;)

      • 4 chris 2010/11/16 at 11:06 AM

        heh well, true, I never though of that. XD
        so I guess thats what you meant with “a library of emulated systems”

  3. 6 n2j3 2010/11/20 at 5:08 AM

    thanks for finally posting this mini how-to

  1. 1 Three mediocre attempts « Motho ke motho ka botho Trackback on 2010/12/06 at 11:24 PM
  2. 2 Twenty-ten: The picks of the litter « Motho ke motho ka botho Trackback on 2010/12/13 at 8:40 AM
  3. 3 Too many variables « Motho ke motho ka botho Trackback on 2011/04/07 at 7:38 AM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Visit the Wiki!

Some recent desktops

May 6, 2011
Musca 0.9.24 on Crux Linux
150Mhz Pentium 96Mb 8Gb CF

May 14, 2011
IceWM 1.2.37 and Arch Linux
L2300 core duo 3Gb 320Gb

Some recent games

Apr. 21, 2011
Oolite on Xubuntu 11.04
L2300 core duo 3Gb 320Gb

Enter your email address to subscribe to this blog and receive notifications of new posts.

Join 405 other followers


This work is licensed under the GNU Free Documentation License. Please see the About page for details.

Blog Stats

  • 3,959,123 hits



Get every new post delivered to your Inbox.

Join 405 other followers

%d bloggers like this: