carled
Posts: 37
Joined: Sat Feb 09, 2013 12:23 pm

Mounting random USB drives to a mountpoint

Sat Mar 23, 2013 12:28 pm

I want to run the Pi as a mini media server/nas using SAMBA and minidlna. Once I have a working setup I'd like to copy that image onto a few sd cards to give to my friends who want to do the same thing. However I've found from playing around this morning that the way that different usb drives identify themselves changes somewhat dramatically and this, to me, seems to break what I'm trying to do.

I created a mountpoint of /mnt/mediaStorage and chmodded it 755.

I then plugged in a Verbatim Store N Go usb flash drive. When I looked at dmesg, my sda line was:

Code: Select all

sda: sda1 < sda5 >
mounting the sda1 partition failed. mounting the sda5 partition succeeded and it contained my media files.

However, I know that my friends don't have the same usb drives. If I plug in a different USB drive, it doesn't give me the < sda5 > bit and instead just gives me sda1.

This will cause me problems I think! If I set my fstab entry to mount sda5 to /mnt/mediaStorage then when I pass my saved image on to my friends, their USB drives won't mount if they only have sda1!

Also what if my drive is FAT32 (it is) and theirs is ntfs? They are totally non-technical and just want to be able to plug and play. They also want to be able to change USB drives around so they can have some with films, some with music, some with both...

Is the only solution for me to have an fstab with an entry for every possible sda from, say, 1 to 9 and the same for sdb in case they plug in two drives at once? So I would have /mnt/mediaStorage1 through to /mnt/mediaStorage18 to cope with sda1->sda9 and sdb1->sdb9?

Seems massively inefficient but I can't see how I can set it up any other way so that the system can serve up every possible drive plugged in, whether usb flash in fat32 through to USB HDD in ntfs or even ext3 or ext4.

Am I missing a trick here? I'm a windows person not Linux so it's all a bit confusing!

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 7357
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.

Re: Mounting random USB drives to a mountpoint

Sat Mar 23, 2013 6:59 pm

Since Linux, unlike Windows, does not use drive letters (A, B, C ... Z) there probably isn't a "one for all" solution for what you're hoping to do. However take a look at my "Multiple USB Sticks" suggestions at http://www.cpmspectrepi.webspace.virgin ... ticks.html - using labels (OK for Windows formats) or UUID's within fstab may be of use. Also "man mount" will tell you quite a lot about the various options.
Trev.
Testing Bookworm on a Pi5 and a P4B but running Bullseye or Buster on other (older) Pi's and the P400 I often post from. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm for notes & screenshots etc.

carled
Posts: 37
Joined: Sat Feb 09, 2013 12:23 pm

Re: Mounting random USB drives to a mountpoint

Sun Mar 24, 2013 11:17 am

FTrevorGowen wrote:Since Linux, unlike Windows, does not use drive letters (A, B, C ... Z) there probably isn't a "one for all" solution for what you're hoping to do. However take a look at my "Multiple USB Sticks" suggestions at http://www.cpmspectrepi.webspace.virgin ... ticks.html - using labels (OK for Windows formats) or UUID's within fstab may be of use. Also "man mount" will tell you quite a lot about the various options.
Trev.
Thanks for the reply. I don't think this achieves what I want though as it assumes I know the IDs of the drives, which I don't. I'm looking into autofs now to see if that works.

ghans
Posts: 7893
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Mounting random USB drives to a mountpoint

Sun Mar 24, 2013 12:55 pm

usbmount might also be useful.

Code: Select all

sudo apt-get update
sudo apt-get install usbmount
Edit the usbmount.conf FILESYTEMS entry first.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

carled
Posts: 37
Joined: Sat Feb 09, 2013 12:23 pm

Re: Mounting random USB drives to a mountpoint

Sun Mar 24, 2013 2:00 pm

usbmount seems to be the one that works best so far! Thanks.

Return to “Beginners”