1

I created an udev rule that launches a shell script that creates a directory /media/my-disk when some specific USB HD is connected. It has been working many months, but after a reboot (probably some packages were updated) it shows the following message (in syslog) everytime I plug the drive in:

mkdir: cannot create directory '/media/my-disk': Read-only file system

I have added the following lines to the script:

whoami
mount

And the result is:

root

usb-mount.sh: /dev/mapper/sda3_crypt on / type btrfs (ro,relatime,ssd,space_cache,subvolid=257,subvol=/@)

So it seems udev is seeing the root filesystem as readonly, but if I execute sudo mount manually it shows it mounted as read/write:

/dev/mapper/sda3_crypt on / type btrfs (rw,relatime,ssd,space_cache,subvolid=257,subvol=/@)

I've searched on the Internet and I've found the same exact problem but without a solution: https://www.raspberrypi.org/forums/viewtopic.php?t=210243

Restarting the udev service solves the problem until the next reboot.

What can I check solve it permanently?

NOTE: I am running Ubuntu 18.04.1 LTS

1 Answer 1

0

I see two possibilities:

  1. The systemd-udevd process was started before the root filesystem was remounted read-write, and see it read-only.
  2. The systemd-udevd process is constraint by some security mechanism, AppArmor in the Ubuntu case.

But the fact that it works when you restart udev manually strongly indicates the first possibility. I would try to remount the rootfs read-write in usb-mount.sh, with a command like:

mount -o remount,rw /

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .