Ubuntu Hard Drive Partition Re-Numbering
So with a vanilla Ubuntu installation, I used Gparted to shrink the 1st partition…
Afterwards I had a hard drive with a partition table that looked a bit like this:
- SDA1
- SDA3
- SDA2
- - SDA5
This is very easy to fix and it is best done with an Ubuntu Live Disc.
The Recipe - for use at your own risk!
- Check the partition ordering: At a command prompt, run “sudo fdisk -l”. It should be out of numerical order.
- Get the partition UUIDs: At a command prompt, run “sudo blkid”. Note the UUIDs for all the partitions on the hard drive.
- Lets fix it: At a command prompt, run “sudo fdisk /dev/sda”
- At the fdisk prompt, type “p” and press return. Then fdisk should list your partitions and inform you that they are not in order.
- At the fdisk prompt, type “x”, then “f”, and finally “w”.
- At this point fdisk will write out the new partition information, but will likely complain about the OS still using a cached copy.
- Now, reboot the machine back into the Live Disc environment again.
- Checking all is well: At a command prompt, run “sudo fdisk -l”. It should now be in numerical order.
- Check the UUIDs: At a command prompt, run “sudo blkid”. The UUIDs should be the same. If not, you will probably need to fix the fstab - mount your boot partition and update the UUIDs in /etc/fstab.
- All done: Reboot again, back into your normal Ubuntu (not the Live Disc environment).
