Raspberry Pi : mount the partitions on the disk by their UUID

Mount the partitions via fstab and using/dev/sdX-type devices, It knows all. But what happens there if like me you just put a USB stick and she just replace ID of your main disk ? Well nothing works. So let's see how to force mounting thanks to the UUID, a fixed and single partitions.

Raspberry Pi Home Server : Monter les partitions du disque par leur UUID

Tonight I was gone to my small hacks for a backup with a USB system (Article soon in stores !). Du coup j’installe ma distribution favorite sur a USB key en suivant les étapes décrites here. Je fais une petite sauvegarde de my SD card in the event that, I put my key in the 2nd port and I turn on the Raspberry. And there necessarily, my partitions on the disk that were in hda are hdb and so it no longer works !

So it is left to replace traditional editing by a mounting thanks to the UUID who will ensure that we mount the good partitions in the right place !

  1. Find the UUID of each partition IDs
    ls -l /dev/disk/by-uuid

    Trouver les identifiants UUID de chaque partition

    Here we find the 4 partitions on the USB disk in sdbX (instead of sdaX) and the 2 partitions of the USB stick in sdaX

  2. We will edit the file /etc/fstab to replace the old values with our UUID.For example, the line :
    /dev/sda2/media/usbdrive/internet ext4 defaults 0 0

    Will become the next row using the UUID of the partition sdb2 :

    UUID=31c26f5b-372e-48f0-b38e-794d9c87b6e1 /media/usbdrive/internet ext4 defaults 0 0
  3. Do the same for the 3 remaining partitions
  4. Mount the partitions
    mount -a

Voilà. Plus de soucis d’association 😉

You may also like...