vyt45
Posts: 5
Joined: Wed Sep 23, 2015 11:54 am

Partition letters constantly changing

Mon May 23, 2016 8:17 pm

Hi,

I have Rpi2 running raspbian, I use it for many purposes, recently it started changing volume letters. Normal mount setup would look like this:

Code: Select all

 Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1      409639      204819+  ee  GPT
/dev/sda2          409640   623872871   311731616    b  W95 FAT32

WARNING: GPT (GUID Partition Table) detected on '/dev/sdc'! The util fdisk doesn't support GPT. Use GNU Parted.


Disk /dev/sdc: 500.1 GB, 500107859968 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773164 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1      409639      204819+  ee  GPT
/dev/sdb2          411648   976773119   488180736    7  HPFS/NTFS/exFAT
But keeps swapping letters to c/b/ etc. I can't run services like plex because it has certain drives mapped. Both of the connected hdds have separate power supply.
fstab looks like this:

Code: Select all

proc            /proc           proc    defaults          0       0
/dev/mmcblk0p1  /boot           vfat    defaults          0       2
/dev/mmcblk0p2  /               ext4    defaults,noatime  0       1
/dev/sda2       /media/Share   exfat    defaults,umask=000 0 0
/dev/sdb2       /media/Share2   exfat    defaults,umask=000 0 0

klricks
Posts: 7154
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Partition letters constantly changing

Mon May 23, 2016 9:40 pm

Mount using UUID in FSTAB.
Google for examples.......
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

epoch1970
Posts: 5132
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Partition letters constantly changing

Mon May 23, 2016 10:01 pm

That's right. I'll elaborate a bit.
You need to recognize the current kernel name of the device. If you just plugged the drive, then "dmesg | tail" will show you the name of the recently arrived device, e.g. /dev/sda with 1 single partition /dev/sda1

Then you can use the "blkid" command:

Code: Select all

blkid /dev/sda1
/dev/sda1: UUID="9F86-E3F0" TYPE="vfat"
or if this fails, which is unlikely, you can "ls /dev/disk/by-uuid/" and see all the UUIDs that exist on the system. On each one you can use "readlink" to see to which kernel device the UUID is bound. E.g.

Code: Select all

readlink /dev/disk/by-uuid/9F86-E3F0 
../../sda1
Then you can change your /etc/fstab line to read something like:

Code: Select all

UUID=9F86-E3F0       /media/Share   exfat    defaults,umask=000  0 0
If you reformat, the UUID will change, and the mount will no longer work. Fair is fair.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

vyt45
Posts: 5
Joined: Wed Sep 23, 2015 11:54 am

Re: Partition letters constantly changing

Tue May 24, 2016 6:21 am

epoch1970 wrote:That's right. I'll elaborate a bit.
You need to recognize the current kernel name of the device. If you just plugged the drive, then "dmesg | tail" will show you the name of the recently arrived device, e.g. /dev/sda with 1 single partition /dev/sda1

Then you can use the "blkid" command:

Code: Select all

blkid /dev/sda1
/dev/sda1: UUID="9F86-E3F0" TYPE="vfat"
or if this fails, which is unlikely, you can "ls /dev/disk/by-uuid/" and see all the UUIDs that exist on the system. On each one you can use "readlink" to see to which kernel device the UUID is bound. E.g.

Code: Select all

readlink /dev/disk/by-uuid/9F86-E3F0 
../../sda1
Then you can change your /etc/fstab line to read something like:

Code: Select all

UUID=9F86-E3F0       /media/Share   exfat    defaults,umask=000  0 0
If you reformat, the UUID will change, and the mount will no longer work. Fair is fair.

That's exactly what I need, will test it when I get home. Thanks!

EDIT: Works perfectly!

Return to “Troubleshooting”