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.
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 !
- Find the UUID of each partition IDs
ls -l /dev/disk/by-uuid
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
- 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
- Do the same for the 3 remaining partitions
- Mount the partitions
Voilà. Plus de soucis d’association 😉