Maintaining Ancient Machines

I needed to move one of my old machines (an HP Laptop) to a new hard drive. And although there were hiccups, it went smoothly enough that I did not have to re-install the OS. This is a machine that I do not have dedicated to any particular role at the moment. It’s come in handy when I’ve had work on other machines that needed to be brought down or had to come off of the network. A few months ago I started getting notices that a hard drive failure was imminent. So, here are the steps I took:

  1. use dd to directly copy everything from current drive to new drive. (Took a day).
  2. use uuidgen to get new uuid values for the partitions on the new drive.
  3. use tune2fs -U uid1 /dev/sdaX to set the uuid value for partition X – some details:
    • Note that this failed at first because there were errors in sda1. I had to run e2fsck /dev/sda1. I liberally used lsuid and fsck -l  to check that the new partitions were cool.
    • There was some confusion at first as the original drive was still connected. So I had to play games with forcing the laptop to boot from the USB-mounted new drive; that was fine but I did this when I had not yet changed any UUID which made things confusing as you had no way of knowing whose disk was actually mounted.
    • I almost started, actually I did start, down the rabbit hole of trying to understand how to mount two bootable disks with linux OS’s. This would be the equivalent of a dual boot system which I used to do back in the day with Linux + Windoze. Then good sense came to me and I remembered I didn’t want the original disk.
    • I concluded that the only change I should need to make would be to grub.cfg and to /etc/fstab to reflect the new UUID values. I did this from within gparted live. I also think I performed the tune2fs from the same system – I don’t recall if I had already removed the old hard drive.  I like gparted but a couple odd tricks:
      • running e2fsck is done as sudo e2fsck /dev/sdc1 for example.
      • Instead of tune2fs for the swap partition (which is not an ext2/ext3/ext4 fs), you literally recreate the swap space: mkswap /dev/ddb
      • Then become root on gparted live (use sudo su)
      • mount /dev/sda1 /mnt
      • edit /mnt/boot/grub/.cfg
      • edit /mnt/etc/fstab
      • use blkid to find the relevant UUID values.
  4. In the end, it worked like a charm. Some scary moments when I thought I would clobber myself, but it seemed good. Also, I had to install uuidgen on gparted, and I had to do an update to tune2fs (or maybe it was e2fsck) on gparted.

All in all, some good practice.

 

Leave a comment