If you can boot to DOS, and run DEBUG, there is a simple real mode io sequence to corrupt the CMOS, provoking most BIOS implementations to reset to factory defaults and clear any password. Since I could not do that, there is also a free (as in beer) Windows program called "KILLCMOS" that will do something similar (if you have Admin privilege on Windows - which most end users do to avoid having to deal with an Admin account). It also installs Spyware (definitely not Free) - not a problem since we are going to wipe Windows anyway. However, I was scared off by a report of KILLCMOS bricking someones Sony laptop.
# fdisk /dev/sdbto inspect the partition table. There was a 5GB Sony Diagnostics partition, which I left alone since it could be useful, and some Windows partitions, which I deleted. I then allocated a 200M boot partition on hdb2 as Linux and the remainder of the drive as an LVM physical volume on hdb3. I used
# mke2fs -j /dev/hdb2to format a filesystem on the boot partition and
# pvcreate /dev/hdb3to format a physical volume (PV) on the LVM partition. I used
# vgcreate rootvg /dev/hdb3to add the PV to a Volume Group (VG) named "rootvg". (If you are following my example - make sure that "rootvg" is *not* the name of any existing volume group on the system you are using. Use "vgs" to list them.) I used
# lvcreate -L 15G -n f10 rootvgto allocate a root filesystem,
# lvcreate -L 1G -n swap rootvgto allocate some swap, and
# lvcreate -L 16G -n home rootvgto allocate a "/home" filesystem. These were all formatted with
# mke2fs -j /dev/rootvg/f10 # mkswap /dev/rootvg/swaprespectively. I noted the UUID reported by mkswap for use below. I would deal with moving /home to the 3rd LV after the system was booting.
# mount /dev/rootvg/f10 /mnt # mkdir /mnt/boot # mount /dev/sdb2 /mnt/bootI used
# rsync -ravHxX /boot/ /mnt/bootto copy /boot and
# rsync -ravHxX --exclude=/home/\* --exclude=/var/cache/yum/\* / /mntto copy the system, minus user data.
# tune2fs -l /dev/sdb2 | grep UU # tune2fs -l /dev/rootvg/f10 | grep UUUsing vim (or your favorite plain text editor), I edited /mnt/etc/fstab to insert the UUIDs of /, /boot, and swap. Next I edited /mnt/boot/grub/grub.conf to change the root UUID. I also changed "root (hd0,0)" to "root (hd0,1)" in grub.conf since I had preserved the Sony Diagnostics in the first partition and copied /boot to the second partition. If you are following my example, I hope you know how to use cut & paste, or the "!!" command in vim. I edited /mnt/etc/passwd, /mnt/etc/group, /mnt/etc/shadow, /mnt/etc/gshadow to remove the users and groups that were on my /home (and not copied).
(hd0) /dev/sdbThis tells grub to install the loader to access blocks currently mounted via /dev/sdb as BIOS drive 0x80. Then I used
# grub-install --root-directory=/mnt /dev/sdbto install the MBR and grub loader on the laptop drive. Then I changed /mnt/boot/grub/device.map back to "(hd0) /dev/sda", which would be correct when using grub on the laptop.
I made a few trial and error guesses (installing and removing the drive each time), but eventually hit upon the strategem of copying the isolinux directory from the LiveCD to /mnt/boot and adding an entry to /mnt/boot/grub/grub.conf to load the LiveCD kernel and initrd0. This initrd autodetected the IDE controller, and attempted to mount the CD (which would have let me do a LiveCD install as I originally intended), but it failed with "head select" errors (more on that later). But the LiveCD initrd helpfully drops you to a root shell, and I used "lsmod" to discover that the "pata_ali" module was required to access the hard disk (and CD).
# mkinitrd --with=pata_ali --fstab=/mnt/etc/fstab /tmp/initrd-220.127.116.11-170.2.35.fc10.i686.img 18.104.22.168-170.2.35.fc10.i686to create the customized initrd using the then current kernel version. (The trial and error attempts included a variety of guessed pata_* drivers - none of which were correct.) When this completed with no errors, I moved it into position with
# mv /tmp/initrd-22.214.171.124-170.2.35.fc10.i686.img /mnt/boot
# umount /mnt/boot # umount /mnt # vgchange -an rootvgto unmount everything on /dev/sdb. (Also unmount anything automounted on your desktop.) Then I unplugged the USB, disconnected the laptop drive, and reinstalled it in the laptop. Powering it on brought up grub! During the trial and error attempts to discover the required IDE driver, the kernel would load, but fail after reporting "volume group rootvg not found" and failing to find the root filesystem. With the proper driver, however, Linux proceeded through its boot proceedures (where kudzu discovered lots of hardware changes - doh!). Since linux keeps the hardware clock in UTC, and Windows keeps it in localtime (as nearly as it can manage this logically impossible task), the filesystem timestamps were in the future, triggering filesystem checks. When this was all complete, however, up came the Gnome login!
Mar 29 12:39:41 rafael kernel: sr: Sense Key : Hardware Error [current] Mar 29 12:39:41 rafael kernel: sr: Add. Sense: Head select faultgetting logged to /var/log/messages. To be really sure, I should have tried reading a CD in XP before wiping it - but I didn't think of it.