In this post I’ll show how to backup bit-by-bit an existing gentoo linux installation to an iPod classic via USB, and how to restore the image to a vmware virtual machine. Why all that? Because iPod classic can be used as a portable hard disk with 160 Gb… And what better way there is to test a backup than actually run it as if it were the real machine ? 😉
What you’ll need:
- an Ipod classic 160 Gb, with enough free space
- a burned ISO of Ghost for Linux (g4l)
- a burned ISO of Gentoo Live CD
- a running vmware server on another machine.
Prepare the kernel for vmware
Since the existing physical gentoo installation will run on vmware after the backup, it doesn’t hurt to enable in the kernel support for the “hardware” it’ll encounter. These are the features that must be enabled on the kernel to support vmware server 1.0.x:
Support for vmware NIC:
Device Drivers --->
[*] Network device support --->
[*] Ethernet (10 or 100Mbit) --->
[*] EISA, VLB, PCI and on board controllers
<*> AMD PCnet32 PCI support
Support for vmware SCSI:
Device Drivers --->
SCSI device support --->
<*> SCSI disk support
[*] SCSI low-level drivers --->
<*> BusLogic SCSI support
Doing the backup
1. Connect the ipod via USB and boot the gentoo machine with the g4l CD. In the kernel list, choose the latest RELEASED one.
2. After booting, the ipod should be detected as a general USB storage device. In my machine it is seen as /dev/sdb1. To be sure, a simple mount will suffice to discover:
mount /dev/sdb1 /mnt/local
3. Type ‘g4l’ to enter the ‘graphical interface’. In the main menu, choose “RAW Mode”
4. Then choose “Local use”
5. In the local use screen, configure the following values:
A: Pick the drive: choose the ipod device, or (X) sdb1
B: Config filename: I’ve chosen vaio_bkp.img
C: Toogle split: (X) On. This is very important. Ipod is formatted as FAT32 under windows, and does not support files larger than 4Gb
D: Toogle compression: I’ve chosen (X) None, since I have plenty of free space in my ipod and thus the process can be faster and less cpu intensive
E: Backup: choose the partition on the machine to be backed up, (X) sda4, for example.
After that, G4l will show all the choices made before starting the process:
6. Several 1Gb files will be created in the ipod root folder. The backup speed was about 18 Mb/s in my environment, so, to backup 80Gb it took aprox. 70 min.
Creating the vm
1. In another machine that has vmware server instaled, create a new virtual machine (File -> New -> Virtual Machine), choose “custom” -> “Linux” -> “Other Linux 2.6.x kernel”, and when prompted for “I/O Adpater type” choose “BusLogic”. When prompted for “Disk type”, choose “SCSI”. In the “Disk capacity” choose the same size of the partition in the original machine. Keep “allocate disk now” unchecked, to save space. In the vmware server console, add to the virtual machine a USB Controller (menu VM -> Settings) and then “Add -> USB Controller”
2. Boot the virtual machine with g4l live CD, with the ipod plugged in. Run “fdisk” and make sure that the partition layout is the same of the original gentoo, that is, if the partition was called /dev/sda4 in the source machine, create in the virtual machine the same partition name. Don’t forget to toggle the bootable flag in this partition.
3. The vm should see the ipod in the USB. If not go to menu VM -> Removable Devices -> USB Devices and mark “Apple Computer USB Device”.
Restoring the backup
1. In ghost for linux, go to the menus:
RAW Mode -> Local Use
2. Choose the options:
A: sdb1 (or where the ipod was mounted)
B: the same name used to backup
C: Toogle split (On)
D: Toogle compression (None) if compression was not used
F: Restore: choose the partition created in vmware, matching the original partition name. G4l will show a resume before restoring:
The restore will take longer than the backup, since vmware server 1.0.x still does not support high speed USB (the support is coming in vmware server 2, still in beta stage). In my environment, I could get a 2.4 Mb/s speed.
Fixing the bootloader
Now that you have a clone of the physical machine under vmware, chances are that it still not bootable. This may occurs if the partition backed-up was not where the bootloader was installed. In my case, the backup was made from /dev/sda4, and the bootloader was installed in /dev/sda alongside with windows, to enable dual boot. To fix this, boot the virtual machine with gentoo install CD, and install grub again:
# mount the partition
mount /dev/sda4 /mnt/gentoo
# Remount /dev/ inside the partition
mount -o bind /dev/ /mnt/gentoo/dev
# Chroot into the partition
chroot /mnt/gentoo /bin/bash
# mount proc
mount -t proc proc /proc
# Populate /etc/mtab, so that grub-install does not get angry
cat /proc/mount >> /etc/mtab
# Install grub on the disk
Now the virtual machine is bootable!
Fixing X and network
After booting, eth0 is not available, thanks to udev. As the MAC Address of the NIC changed, udev allocates eth1 and wipes eth0. To fix this, simply:
and reboot the system.
To fix the X server, run the command ‘xorgconfig’. Choose the following options:
Mouse Protocol: 1
Mouse device: /dev/input/mouse0
card database: choose 30 (vmware)
And that’s all! Now we have a perfect running clone of the physical machine, with network and X support, in a relative easy manner.