Repartition drive, keeping /home on a new, separate partition

Q I run Ubuntu 7.10 and thought I would repartition my hard disk, and keep /home on a new separate partition, but without the encryption. However a number of issues arose and before I do the deed I would appreciate some advice if possible. It is not clear from any of the books I have read, exactly how to ensure that the operating system knows where the new /home partition is. The instructions in the article apply to the situation where the encryption process has been completed. I thought that the answer might lie with fstab so I had a look at fstab (I've attached a copy) but found that the existing Linux partitions have a UUID entry, which is frankly incomprehensible. The fstab entries for the two Linux partitions on the drive also seem to be commented out.

# /dev/sda3
UUID=ff773431-fb57-48b4-bb55-01da6902c372 / ext3 defaults,errors=remount-ro 0 1

If I run GParted from the System/Administration menu I cannot change the sizes of the Linux partitions - I think this is because they are mounted and it is more dangerous to edit mounted partitions - however I have downloaded a Live CD version of GParted that boots the PC and allows any of the partitions to be edited.

A You are on the right lines with trying to add the new /home to /etc/fstab. The entry would normally be something like

/dev/sda5 / ext3 defaults,errors=remount-ro 0 1

but, as you have discovered, Ubuntu uses UUIDs instead of partition numbers. The commented lines before them are simply to show you which partitions they applied to at the time of installation. A UUID is a unique identifier applied to a filesystem when it is created, one that doesn't change for the life of the filesystem. If you were to shrink /dev/sda2 and add another partition between it and the current sda3, that would change to sda4 and your fstab would no longer work, but the UUID stays the same, so the Ubuntu-style fstab would still work. You have a number of choices here when you add your new home filesystem. You can do it the way you know and use the traditional /dev/xxx method, knowing that you will need to edit fstab if you move partitions. Or you could do it the Ubuntu way by using the vol_id command to get the UUID of your new partition.

$ sudo vol_id /dev/sda5

Here you can see the UUID of the filesystem and you can paste it into fstab. There is a third option, and vol_id's output gives a clue - the filesystem label, which is the method preferred by Red Hat/Fedora. This has the advantages of UUID in terms of not changing when partitions are added, but is also more readable. All you need to do is give your partitions labels with

e2label /dev/sda5 HOME

then edit /etc/fstab to contain

LABEL=HOME / ext3 defaults,errors=remount-ro 01

You can change the label of an existing ext3 filesystem with e2label without disturbing the contents, so you can label your root partition and amend fstab. If you are using a filesystem other than ext3, they all have their own labelling tools, you can even label your swap partition with "mkswap -L ..." . You are correct about GParted not working on mounted partitions, but you don't need a separate Live CD; you can boot from the Ubuntu install disk and run it from there.

Follow us on or Twitter

Username:   Password: