Hack and / - Migrate to a New Hard Drive
What you do during this step will vary a bit, depending on how you set up your partitions. If you moved your partition layout around, you need to edit the /etc/fstab file on your new root partition so that it reflects the new drives you have set up.
Traditionally, this has been a simple step for me, because I try to order the partitions the same and generally don't have to touch fstab, but on this last migration, I had to add an extra step due to Ubuntu's use of UUIDs to reference partitions. A lot of modern distributions don't refer to partitions by their device name. Instead, a unique identifier called the UUID is assigned to each partition. If you see UUID=longstringofhex in your /etc/fstab, this means you.
Now, you have two choices here. The first choice is to change all these UUID lines to reference the actual device. This will work, and is less prone to typos that will make the system not boot, but you will lose the advantage of UUIDs. The other method is to reference the UUIDs for your new partitions and put them in place of the old UUIDs. You can find the list of disk-to-UUID mappings under /dev/disk/by-uuid:
greenfly@minimus:~$ ls -l /dev/disk/by-uuid/ total 0 lrwxrwxrwx 1 root root 10 2008-04-06 16:00 ↪634719fd-a6da-4fee-8646-0d485d7681db -> ../../sda2 lrwxrwxrwx 1 root root 10 2008-04-06 16:00 ↪665d7008-fde9-4055-8af9-483697acb005 -> ../../sda1 lrwxrwxrwx 1 root root 10 2008-04-06 16:00 ↪cf3892fd-e3d8-446f-8552-4c633be9c382 -> ../../sda3
Of course, you always could choose a hybrid of the two approaches, and set the hard device names in the fstab for the first boot, and then once you have confirmed the system boots, you then can update fstab with UUIDs.
As with fstab, if you changed your partition layout, you need to update your GRUB configuration under /boot/grub/menu.lst (or on some systems, in /boot/grub/grub.conf) to reflect your changes. Also, GRUB can reference drives by UUID, so if you see references to UUID in the GRUB configuration file, be sure to update it to reflect the new values. Once the file has been updated, chroot into your new root partition's mountpoint and then run grub-install:
chroot /mnt/sdb1 /usr/sbin/grub-install --recheck /dev/sdb
Change /mnt/sdb1 and /dev/sdb to reflect your new mounted root partition and its disk device, respectively. If the chrooted grub-install doesn't work, you typically can use your rescue disk (or single user) grub-install with the --root-directory option:
/usr/sbin/grub-install --recheck --root-directory /mnt/sdb1 /dev/sdb
After I used my new system for some time, I noticed it wouldn't resume correctly from hibernation. It seemed like each time the swap partition would get corrupted. After some troubleshooting, I found that the root cause was a hard-coded resume device based on UUID that is put in the initial ramdisk for the machine. You may or may not run into this issue, depending on your Linux distribution, as each distribution manages its initrd differently. But, here is the fix for my Ubuntu system. I was able to find the offending reference to the old UUID in /etc/initramfs-tools/conf.d/resume. All I needed to do was update that file on the new drive to point to the new UUID for my swap partition, then run update-initramfs from the new system, and reboot.
Kyle Rankin is a Senior Systems Administrator in the San Francisco Bay Area and the author of a number of books, including Knoppix Hacks and Ubuntu Hacks for O'Reilly Media. He is currently the president of the North Bay Linux Users' Group.
Kyle Rankin is a director of engineering operations in the San Francisco Bay Area, the author of a number of books including DevOps Troubleshooting and The Official Ubuntu Server Book, and is a columnist for Linux Journal.
|PostgreSQL, the NoSQL Database||Jan 29, 2015|
|HPC Cluster Grant Accepting Applications!||Jan 28, 2015|
|Sharing Admin Privileges for Many Hosts Securely||Jan 28, 2015|
|Red Hat Enterprise Linux 7.1 beta available on IBM Power Platform||Jan 23, 2015|
|Designing with Linux||Jan 22, 2015|
|Wondershaper—QOS in a Pinch||Jan 21, 2015|
- PostgreSQL, the NoSQL Database
- Sharing Admin Privileges for Many Hosts Securely
- HPC Cluster Grant Accepting Applications!
- Internet of Things Blows Away CES, and it May Be Hunting for YOU Next
- Non-Linux FOSS: Animation Made Easy
- Wondershaper—QOS in a Pinch
- Ideal Backups with zbackup
- Red Hat Enterprise Linux 7.1 beta available on IBM Power Platform
- Designing with Linux
- Hats Off to Mozilla
Editorial Advisory Panel
Thank you to our 2014 Editorial Advisors!
- Jeff Parent
- Brad Baillio
- Nick Baronian
- Steve Case
- Chadalavada Kalyana
- Caleb Cullen
- Keir Davis
- Michael Eager
- Nick Faltys
- Dennis Frey
- Philip Jacob
- Jay Kruizenga
- Steve Marquez
- Dave McAllister
- Craig Oda
- Mike Roberts
- Chris Stark
- Patrick Swartz
- David Lynch
- Alicia Gibb
- Thomas Quinlan
- Carson McDonald
- Kristen Shoemaker
- Charnell Luchich
- James Walker
- Victor Gregorio
- Hari Boukis
- Brian Conner
- David Lane