Page 1 of 1

Mount USB Stick at Bootup

Posted: Sun Mar 26, 2017 10:05 am
by TerryC65
Hi,

For my project, to restore the bells and music to the local Model Town Minster, I want the system to run headless and so I won't need (or want) to run the desktop. The Python code is now working when tested in IDLE, so all I have left to do is start the script automatically at boot-up. (I will also need to boot into the system with the SD Card read-only, but that's another story.)

The software is running on a Pi 3 in Raspbian Pixel which is fully up to date. The music and chimes are all held on a removable USB stick plugged into one of the Pi's USB ports. When I boot into Raspbian Pixel (the desktop), this drive appears at /media/pi/MEDIA where MEDIA is the label of the USB Stick.

If I execute my python code from within the desktop, eg using IDLE, everything works OK. When I launch the script from the boot-up shell, I get 'permission denied'. On investigation, it looks like it's the MEDIA directory that is denied to me.

If I type:

Code: Select all

cd /media/pi/MEDIA
I get the permission denied message, even if I prefix the command with sudo. If I type:

Code: Select all

 cd /media/pi
I can enter the directory and list it's contents.

I'm assuming this is an idiosyncrasy of Raspbian (or Debian that it's derived from). I therefore decided that I need to mount the USB Stick in fstab and pointing atthe pi user's home directory. However, I don't seem to be able to do that.

I first tried mounting it manually using:

Code: Select all

/dev/disk/by-label/MEDIA /home/pi/WMT
This works, but when I try to add the equivalent line to fstab:

Code: Select all

/dev/disk/by-label/MEDIA /home/pi/WMT defaults 0 0
The pi goes into 'emergency mode' at boot up.

Can anyone give me the right fstab line?

Re: Mount USB Stick at Bootup

Posted: Sun Mar 26, 2017 10:09 am
by DougieLawson
Use sudo blkid /dev/sda to find a UUID or PARTUUID for the partition you want to mount.

Stick a line in /etc/fstab with

Code: Select all

PARTUUID=vvwwxxyy-0n /home/pi/WMT ext4 defaults 0 0 
(Change to ntfs-3g or vfat or whatever if it's not ext4 formatted)

Re: Mount USB Stick at Bootup

Posted: Sun Mar 26, 2017 10:11 am
by TerryC65
DougieLawson wrote:Use sudo blkid /dev/sda to find a UUID or PARTUUID for the partition you want to mount.
I was trying to avoid using UUID so that staff members can replace the USB Stick (should it fail) without having to know how to edit fstab; just change the label on the stick.

Re: Mount USB Stick at Bootup

Posted: Sun Mar 26, 2017 10:17 am
by TerryC65
DougieLawson wrote:Use Stick a line in /etc/fstab with

Code: Select all

PARTUUID=vvwwxxyy-0n /home/pi/WMT ext4 defaults 0 0 
(Change to ntfs-3g or vfat or whatever if it's not ext4 formatted)
Actually, disregard my last post; I'd left out the filesystem entry (vfat in this case). Your suggestion gave me the clue.

My first attempts had it in, but I was working out the path to the drive, getting it wrong, and making the entry simpler as I went. Well I made it too simple...