Ubuntu – How to use a PARTUUID in fstab

bootpartitioning

I needed to increase the size of my boot partition (I already removed old kernels with autoremove).
I increased the size of my drive (VM), and created a new partition. I did all things wonderful to make the new partition /boot. Blkid shows sda1 UUID=1234 PARTUUID=5678-01 and the new partition sda3 UUID=1234 PARTUUID=5678-03.
I tried adding PARTUUID="5678-03" /boot to my fstab but it didn't boot (it works with /dev/sda3 /boot).
Since partitions 1 and 3 are on the same disk (and the same UUID) how can I enter that in fstab?

Best Answer

  • As @mook765 mentions in comments, I think you can use PARTUUID, but just without quotes.

    PARTUUID=5678-03 /boot [...]
    

    Also, failing that, I think you can use the /dev/disk/by-partuuid/* symlinks that udev creates.

    You may also want to use 'UUID', not 'PARTUUID'. Here's an example of the boot section of my fstab (this is the default of Ubuntu):

    # /boot was on /dev/sda1 during installation
    UUID=4e8a17a6-87ca-403b-9a1a-896d553e518c       /boot   ext3    defaults        0       2
    UUID=7A56-4947  /boot/efi       vfat    defaults        0       1
    

    To get the UUID of a block device:

    sudo blkid /dev/sda1
    /dev/sda1: LABEL="ubuntu-boot" UUID="4e8a17a6-87ca-403b-9a1a-896d553e518c" TYPE="ext3" PARTLABEL="ubuntu-boot" PARTUUID="57e3d2de-492b-4875-b110-76325e2401ec"
    

    Just for example on another machine, you'll notice that each filesystem on the disk has a different UUID:

    root@bierstadt:~# lsblk -o name,UUID /dev/sda
    NAME                    UUID
    sda                     
    ├─sda1                  8D99-B7B6
    ├─sda2                  147da7cf-c356-4ff9-a6fa-8fb555290b25
    └─sda3                  1dd7ce7d-6de9-40e0-bd3f-5550ae40a588
      └─sda3_crypt          mAdSjw-3B31-Z7Im-WbCk-QmIP-b01M-5mFckC
        ├─ubuntu--vg-root   1b3d8c0f-2241-48c1-a272-39f8e683ccc9
        └─ubuntu--vg-swap_1 fd34789c-c65f-4253-a810-8183988e9760
    

    Note the UUID comes with the filesystem. So, if you have cloned the partition, the UUID will come with it. You should probably change it if you want to mount it, or refer to it distinctly:

    From this blog:

    Since it is not possible to mount two file systems with the same UUID, extra care need to be taken when LVM snapshots (or cloned disks) are used in an environment: mounting might fail due to duplicate UUIDs. [...] One way to deal with this is by the way to change the UUID during creation or afterwards, another way is to mount with the nouuid option.

    To change:

    # tune2fs -U new_uuid /dev/sdaX
    

    References

  • Related Question