henryhanselscott
Posts: 107
Joined: Sun Jan 18, 2015 1:31 pm

Rpi2 renaming Flash?

Mon Jun 15, 2015 7:08 pm

So sometimes when an unexpected power failure happens with my pi and it has a USB flash inserted into it, it renames my flash. For instance, the flash is named 'FRED' using the Windows utility when you right click a drive and assign it a name. When being used in the pi, if power fails then on reboot when I navigate to the drive using File Manager the drive is now shown as 'FRED_' with an underscore attached to it. Putting this same drive back into a windows machine it shows up as just 'FRED'. The issue is that my Python code cannot find 'FRED' anymore and my script crashes.

Thanks,
Henry

User avatar
DougieLawson
Posts: 36541
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Rpi2 renaming Flash?

Mon Jun 15, 2015 7:26 pm

Use blkid to find the UUID for the drive, add a permanent mount for it in /etc/fstab.

Code: Select all

UUID=uuuu-uuuu-uuuu /media/FRED     xxxx    defaults,noatime        0 1
with uuuu-uuuu-uuuu as the UUID (from blkid) and xxxx as the filesystem type (fat32, ext4, ntfs or ntfs-3g) depending what's on your drive.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Tom_A
Posts: 272
Joined: Fri Dec 06, 2013 8:34 am

Re: Rpi2 renaming Flash?

Mon Jun 15, 2015 11:28 pm

DougieLawson wrote:Use blkid to find the UUID for the drive, add a permanent mount for it in /etc/fstab.

Code: Select all

UUID=uuuu-uuuu-uuuu /media/FRED     xxxx    defaults,noatime        0 1
with uuuu-uuuu-uuuu as the UUID (from blkid) and xxxx as the filesystem type (fat32, ext4, ntfs or ntfs-3g) depending what's on your drive.
You know, I've been trying to use something similar to make my USB root partition mount by UUID instead of /dev/sda1. I worked when I was running RaspBMC, but I've never gotten it to work with Raspbian.

shadowofdarkness
Posts: 35
Joined: Fri Jan 11, 2013 9:54 pm

Re: Rpi2 renaming Flash?

Tue Jun 16, 2015 12:40 am

Does the FRED directory already exist before plugging the drive in. Because a extra underscore usually is only added if the directory already exists under /media so can't be used.

henryhanselscott
Posts: 107
Joined: Sun Jan 18, 2015 1:31 pm

Re: Rpi2 renaming Flash?

Tue Jun 16, 2015 10:36 am

Does the FRED directory already exist before plugging the drive in
Not sure what you mean exactly...but the mythical "FRED" directory exist only on the USB flash. With the drive in one of the USB ports and then after an abrupt power loss on reboot, the drive now is "FRED_ " using file manager to look at it. Python can no longer find my original "FRED" directory and so it crashes.

So its like the OS sees 2 instances of "FRED" and renames one of them to "FRED_"?

Henry

Return to “General discussion”