1

I'm trying to mount an external USB SSD in RPi Zero-W in Raspbian, no desktop mode, with fstab, and seems that it unmounts immediately.

EDIT: I found this bug (which is still unfixed), and see that systemctl daemon-reload after a reboot fixes this (until the next reboot).

The partition was formatted on an Ubuntu machine and owned by its main user (I don't know how to see the files owner id raw number). If I plug it in that Ubuntu machine or in Raspbian Desktop version, it works normally, showing files in it, writing and reading correctly.

What blkid outputs:

# blkid
...
/dev/sda1: UUID="08f443b0-4b84..." TYPE="ext4" PARTLABEL="all" PARTUUID="03ecea80-ce56-..."

I'm sure I used the correct UUID (the partition one, on the right, 03ecea80), because otherwise, if I use 08644, then moutn -av shows nothing (it does not see the partition with such UUID, I guess).

part of /etc/fstab:

PARTUUID=03ecea80-... /mnt/adata ext4 auto,user,rw,nofail 0 0

mounting:

# mount -av
...        : already mounted
...
/mnt/adata : successfully mounted

but /mnt/adata is empty, and df -aTh shows nothing in /mnt/adata either.

checking:

# journalctl -b | tail -n 10
11:05:08 raspberry pi kernel: EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: (null)
11:05:08 raspberry pi systemd[1]: mnt-adata.mount: Unit is bound to inactive unit dev-disk-by\x2dpartuuid-08f443b0... Stopping, too.
11:05:08 raspberry pi systemd[1]: Unmounting /mnt/adata...
11:05:08 raspberry pi systemd[638]: mnt-adata.mount: Succeeded.
11:05:09 raspberry pi systemd[1]: /mnt/adata.mount: Succeeded.
11:05:09 raspberry pi systemd[1]: Unmounted /mnt/adata.
2
  • 1
    I suppose you could post your edit as an answer. Unless this is fixed in systemd and Pi OS actually gets to use that fixed systemd (which could take years), there will be no better solution. Switching to OpenRC is far beyond the capabilities of an average user here. – Dmitry Grigoryev Jan 25 at 9:38
  • @DmitryGrigoryev yup. I'll post a script to create a service – culebrón Jan 26 at 6:12
1

WORKAROUND

The bug from 2015, that causes this, is still not fixed, and the workaround is to call systemctl daemon-reload, so I created a service to do this on each startup.

Here's what you have to do.

Remove μSD and plug it into a your usual machine so that you have convenient editors and full write permissions. All paths below are as you'll see them in RPi.

Set up the scrit and save to /home/pi/fixmount.sh:

systemctl daemon-reload && mount -av

Daemon-reload does the trick fixing the behavior, and mount -av mounts all partitions in verbose mode, so that you could see the error output right away.

Set permissions:

$ chmod a+x /home/pi/fixmount.sh

Create a service and save to /etc/systemd/system/fixmount.service

[Unit]
Description=Fix SSD Umounting

Wants=network.target
After=

[Service]
Type=simple
ExecStart=/home/pi/fixssdmount.sh
Restart=never
KillMode=process

[Install]
WantedBy=multi-user.target

Plug μSD and boot the RPi.

Try running the script to see if everything is correct:

$ cd ~
$ ./fixmount.sh

Enable the service (makes it run on every boot):

$ sudo systemctl enable fixmount.service

Test:

$ sudo systemctl start fixmount.service
$ sudo systemctl status fixmount.service

See if status is normal exit, not fail. If failed, check logs (might be wrong filename, wrong permissions).

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.