1

What is the proper/best way to have a USB hard drive permanently mounted? I have done this using fstab using disk label as the identifier, but when I disconnected the drive and tried to boot the pi, it wouldn't boot (dropped to a root shell somewhere along the way) - I'd prefer it to boot even if the drive isn't connected. There are a couple of services (plex, squeezebox) that use the drive for their storage, which might complicate things more that just delaying the mounting till after booting has finished.

And what would be the typical/standard location to mount such drives to?

2

2 Answers 2

5

using /etc/fstab is the proper way of doing this.

if you do not want your system to depend on the drive on startup in case the usb drive is missing you have to set the relevant parameter / options

from man fstab

nofail           do  not  report  errors  for  this  device if it does not
                 exist.

so your fstab should have an entry like this:

UUID=631 /mountpoint/ ext4 rw,auto,nofail 0 2 while only nofail should be the important option to you.

1

nofail didn't help for me. What I did is I used init.d. So:

sudo touch /etc/init.d/hardrive
sudo chmod +x /etc/init.d/hardrive
sudo update-rc.d hardrive defaults

Content of hardrive file:

    #!/bin/sh

    ### BEGIN INIT INFO
    # Provides:          sample.py
    # Required-Start:    $remote_fs $syslog
    # Required-Stop:     $remote_fs $syslog
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # Short-Description: Start daemon at boot time
    # Description:       Enable service provided by daemon.
    ### END INIT INFO

    echo "I'm about to start" >> /tmp/mylogs

    if [ -e "/dev/sda1" ]; then
      echo "/dev/sda1 exists" >> /tmp/mylogs
      # This is to have some basic automatic disk maintenance
      ntfsfix -d /dev/sda1 >> /tmp/mylogs

      mount -t ntfs-3g -o uid-pi,gid-pi /dev/sda1 /mnt
      echo "Drive mounted" >> /tmp/mylogs
    fi
    echo "End of file" >> /tmp/mylogs
    exit 0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.