Pre-installing Hard Disk to move to similar (but different) target CPU/Mobo

OK, I searched about a bit to see if this was covered in HOWTO’s, but haven’t stumbled on anything; which doesn’t mean to say this has not been documented somewhere already or been asked many times before.

Rather than install on the target hardware, I’d like to move the disk installed but minimally configured into the new box. Another reason to do this, would be on CPU/Mobo failure, where you wish to move your Linux disk without full reinstallation after a failure and purchased upgrade CPU/mobo. In this case the reason is lack of way to boot a CD/DVD with disk drive present & powered and avoiding a full install via USB memory stick.

Obviously it is trivial, if the CPU & chipset drivers & grafix are the same (and you choose the right mount options on install); but what about cases where different drivers are going to be needed to mount root, and the grafix uses same driver but changes model (think that’ll auto-configure) these days.

Off top of my head, not only generic kernel but to mount root, the fat initrd will be required. I have vague memories of finding an option enabling “firstboot” so YaST goes into configure. This is going back a yr or two though and I’ve not had my hands mucky in openSUSE for about 10 months and 12.1 M3.

Conceptually this is rather like the “Live CD” install only it’s a live disk.

Before I delve deeper into this I thought I’d ask for pointers here. It seems like delivering a turn key disk, ready for install into a box and on site configuration would not be an unusual requirement, even if MOST ppl would be happy to reinstall from DVD. Auto Yast isn’t really suitable for this, as it involves re-running installation and will require USB booting anyway.

The network might not work if you have ethernet onboard, because the eth device file will be incremented (eth0 → eth1). But you can change that back by editing /etc/udev/rules.d/70-persistent-net.rules. If the graphics chipset is different, just boot in runlevel 3 and install the appropriate driver (and deinstall the old one). You should not need to recreate initrd … unless you need to load a module which is not included in there. Enabling/disabling KMS should happen automatically if you install the driver properly (at least for the proprietary nvidia and ati ones). I don’t think you’re mounting partitions by-path (pci bus). Thus /etc/fstab and /boot/grubmenu.lst should be OK.

A new mainboard noawdays will have a UEFI BIOS. Make sure it is switched off. In most cases, it will switch to Legacy BIOS if it doesn’t find a UEFI boot device. Otherwise you have to turn it off in BIOS setup.

This would seem actually going to be part of the procedure, because the chipsets are different (I’ve done similar in past when testing pre-releases and found EIDE bugs so moved / onto (or off) a PCI PATA card).

See when I move the disk, how will it mount root for the /lib modules, unless the initrd is matched with the chipset? The initial load of kernel & initrd is done by BIOS calls not kernel driver. So not only will I need generic kernel, but I think the fat initrd option used by installation media & Live CDs; I don’t really want to guess as it’ll probably take 2-3 passes to get right.

Once it’s booted, from disk into run level 3 or 5 in a degraded mode, I shouldn’t have a problem. Ideally I will find the YaST firstboot thing again (SuSE Studio) does it and auto configure, or step by step configuration should sort out network adaptors. I never had a problem using eth1, eth2 instead of eth0 in past, so that part doesn’t worry me.

It’s not impossible that the storage controller will just use ahci, which is included in the default initrd. But you’re right. If you need to preload a specific pata/sata driver, you can use lsmod to list loaded modules from a live CD with the new mainboard and lsinitrd to show the content of an initrd file.

Here’s an example (but it’s an older mainboard):

$  lsmod | awk '/ata/{ print $1 }'
ata_generic
pata_atiixp


$ lsinitrd /boot/initrd | sed -n 's|.*/\(.*\).ko$|\1|p' | sort -u
ata_generic
fan
pata_atiixp
processor
thermal
thermal_sys

Under openSUSE, you put the modules in /etc/sysconfig/kernel

$ grep '^INITRD_MODULES' /etc/sysconfig/kernel
INITRD_MODULES="pata_atiixp ata_generic"

and rebuild initrd. If you do it in YaST, it should rebuild initrd for you.

hwinfo will also tell you which module is needed:

$ hwinfo --storage-ctrl | grep -i 'driver module'
  Driver Modules: "ahci"
  Driver Modules: "pata_atiixp"

You don’t need to include ahci (since 12.1 … or 11.4).