Click to See Complete Forum and Search --> : A Grub floppy's role in transferring Linux between computers


saikee
11-29-2005, 12:53 PM
This is intended as an example showing that there is nothing a Grub floppy cannot boot.

Tool required : one Grub floppy (with no operating system attached, see Chapter 3.1 of Grub Manual (http://www.gnu.org/software/grub/manual/grub.html) for its creation)

Hardware of the source PC : Asus Socket-A mobo with Athlon 2800 CPU, onboard Gagabit network card, separate Radeon SE 9200 video card. 33 operating systems in typically 5Gb logical partitions in a 200Gb IDE disk. Only one primary partition has 1Gb size for DOS 6.22. Number of partitions is 43.

Hardware of target PC : ASRock socket-939 mobo with AMD 64 3200 CPU, onboard network card and PCI Express video (type unknown). New 300Gb hard disk.

Cloning of partition : Partitioned the 300Gb disk, using cfdisk, with matching 32x5Gb partitions for Linux and 1Gb primary partition hda1 for DOS. Same partition number and sizes in both disks but relative positions changed as I have different sized primary partitions. Number of partitions is 60 in the new disk. New disk temporarily attached to old computer as disk hdc.

Each partition was cloned by a dd statement but the whole process was automated by a script repeating the command 33 times with alterations to partition numbers.

dd if=/dev/hda1 of=/dev/hdc1 bs=32256

When the new disk was offered to the new PC none of the systems booted because

(a) Each system's boot loader has the record of its own position relative to the old 200Gb disk and must be revised for the new 300Gb disk.

(b) The hardware change can cause the kernel to panic and/or lead to the loss of the screen by the mismatched video card.

To solve problem (a) I just boot up the Grub floppy to a Grub prompt. If I want to rescuse a Linux in hda10 for example I type at Grub prompt

root (hd0,9) <----------------tell Grub the root of the partition I am interested is hda10 (Grub counts from 0)
cat /boot/grub/menu.lst <-----display the content of the file showing how Grub boots this Linux
cat /etc/lilo.conf <----------- display the content of the file showing how Lilo boots this Linux

From either one of the above last two steps (only one but not both) I will have a response from Grub with a complete information of the Linux's kernel and initrd filenames. The booting is therefore complete by typing the relevant kernel and initrd statements in Grub prompt, like

kernel /boot/vmlinuz root=/dev/hda10 ro
initrd /boot/initrd
boot

The statements in blue are steps to boot a system manually.
The kernel and initrd filenames may have an identical long tail after "/boot/vmlinuz" and "/boot/initrd" and these have to be typed in accordingly. Big gun distros like Suse and Slackware use no tail.

The above will work regardless which boot loader was installed in the Linux. Additional parameters at kernel loading time may be added as per original instrcution. In the majority of my cases the above method booted up at least the kernel even if X-windows failed to fire up.

To overcome problem (b) brought about by the video card change one needs to amend the /etc/xorg.conf, which may be called /etc/XF86Config-4, and test the effect of various generic drivers. I have the "radeon" drivers for the old machine and the new one accepts "vesa".

Some distros have xorgconf that one can run at terminal to modify the /etc/xorg.conf but using the editor "vi" is simple enough to change "radeon" to "vesa". Once there is a workable kernel one can mount all the other systems and systematically updating the video driver in one operation.

After I boot up a Linux successfully, say at hda10, I restore its boot loader in its root partition using either "grub-install /dev/hda10" or "lilo -b /dev/hda10" depending if it uses Grub or Lilo respectively. Thereafter I just choose one Grub into the MBR and amend its menu.lst to "chainload" the rest of the systems.

Complications

I had about 6 distros that panic after porting to the new PC. Three of them (Mandrake 10, Libranet and PCLinuxOS 9.1) became bootable again after I opted for a well proven kenel provided by Slackware 10. The Slackware was installed in hda27 so to boot the Mandrake in hda14 I typed

root (hd0,13)
kernel (hd0,26)/boot/vmlinuz root=/dev/hda14 ro

Slackware does not use initrd and the above proved successfuly (using the kernel from another Linux). I did try later kernels from other new Linux but the one from Slackware seems to be the best.

Last remained problems

I left with only 3 out of the 33 systems that failed to boot. These are the Xandros 2.0 and 3.0 plus Sam 1.1. I cut my loss to re-install them as it would take me longer to find a way to boot these weird distros.

When a Linux is transferred from one PC to another it will detect the new environment and adjust itself accordingly. Although the normal course of action is to re-install the Linux in the new PC but surprising the same distro can be made to work in the new surrounding too with a high degree success rate. The majority of these 33 systems were in facted ported previously from yet another computer!

It is made possible by one humble a Grub floppy!