1

I am attempting to mount a usb drive to a specific directory at boot time so that it's mapped to the same directory each time. I read this article, Automounting USB drive on boot, that says to add it to /etc/fstab

proc            /proc           proc    defaults          0       0
PARTUUID=bf444af9-01  /boot           vfat    defaults          0       2
PARTUUID=bf444af9-02  /               ext4    defaults,noatime  0       1
UUID=b994a97c-027d-465e-8483-ad519866f87c /mnt/usb2 ext4 defaults,umask=000 0 0
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that

I tried both PARTUUID and UUID, same results both times.

Here's what I've tried:

PARTUUID=b994a97c-027d-465e-8483-ad519866f87c /mnt/usb2 ext4 defaults,umask=000 0 0
PARTUUID=fc69e031-8593-4c67-9cf9-c364d0166117 /mnt/usb2 ext4 defaults,umask=000 0 0
UUID=b994a97c-027d-465e-8483-ad519866f87c /mnt/usb2 ext4 defaults,umask=000 0 0
UUID=fc69e031-8593-4c67-9cf9-c364d0166117 /mnt/usb2 ext4 defaults,umask=000 0 0

When I restart, it is giving this error:

Cannot open access to console, the root account is locked.

I got out of this by modifying the cmdline.txt and adding bash.

I did a blkid to see my usb drive UUID. Here is what I got:

pi@raspberrypi:~ $ sudo blkid
/dev/mmcblk0p1: LABEL_FATBOOT="boot" LABEL="boot" UUID="6284-658D" TYPE="vfat" PARTUUID="bf444af9-01"
/dev/mmcblk0p2: LABEL="rootfs" UUID="3a324232-335f-4617-84c3-d4889840dc93" TYPE="ext4" PARTUUID="bf444af9-02"
/dev/sda2: UUID="b994a97c-027d-465e-8483-ad519866f87c" TYPE="ext4" PARTLABEL="Basic data partition" PARTUUID="fc69e031-8593-4c67-9cf9-c364d0166117"
/dev/mmcblk0: PTUUID="bf444af9" PTTYPE="dos"
/dev/sda1: PARTLABEL="Microsoft reserved partition" PARTUUID="4792d598-bd1e-4784-99a5-27db1f5d937b"

What am I doing wrong? I cannot get this usb drive to mount at boot up to a specific directory.

Any suggestions please?

2
  • Not sure as my mind is not into fstab tonight - first guess is the partition is not ext4. For testing new entries in fstab I use sudo mount -a once I've added the line in. Once that reports no errors and works I feel safe to reboot :-). Also add nofail to the line - see unix.stackexchange.com/questions/53456/…. It would help to know what works in the file and what you are adding :-). Though this is on a Raspberry Pi - its actually a Linux issue so it should be closed here and moved (daft I know) – user115418 Nov 15 '20 at 18:26
  • 1
    Add a nofail option to your fstab entry - see askubuntu.com/questions/14365/… – Dougie Nov 15 '20 at 22:33
1

I feel the article you followed is not a particularly good one.

The following /etc/fstab entry always works for me:

LABEL=PASSPORT2TB /mnt/Passport2TB ext4 rw,user,nofail 0 0

Of course you will need to substitute the LABEL that identifies your USB drive, and create a mount point that suits you better than /mnt/Passport2TB. If your drive is formatted in something other than ext4, change that to match.

If you want to edit the LABEL for your USB drive, there are several ways to do this:

  1. plug it into your Mac/Windows/Linux PC, and change it w/ the GUI

  2. you can also use the CLI with a procedure similar to this

Why use LABEL instead of UUID? How many drives are you mounting on an RPi? Do you really need 32 hex characters (236 bits) to keep up with all your disk drives? Which is easier to remember? Have you read the section Indicating the device and filesystem in man mount?

You have chosen /mnt/usb2 as your mount point. That should work, but have you also created the folder/dir you'll use for a mount point? Using the example above:

$ mkdir /mnt/Passport2TB

After you've done all of this, it's time to test:

$ sudo mount -av

All should be well. Now, if you want to experiment with other options (defaults, umask), edit the line you just inserted in /etc/fstab to add one of them. Then umount the USB drive, and run sudo mount -av again. Repeat as necessary until you've got it right.

If you're still having problems, run the command lsblk --fs, and post that instead of blkid results. Why use lsblk instead of blkid? If you actually read man blkid you'll see this passage:

Note that blkid reads information directly from devices and for non-root users it returns cached unverified information. It is better to use lsblk --fs to get a user-friendly overview of filesystems and devices. lsblk(8) is also easy to use in scripts. blkid is mostly designed for system services and to test libblkid functionality.

0

You could simply add the bash command a bash executable and place it in /etc/init.d

such as:

#!/bin/bash
sudo mount foo /dev/foo_bar

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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