Raspberry Pi generally mounts two partitions at boot time; here's /etc/fstab
:
proc /proc proc defaults 0 0
PARTUUID=8a6020b5-01 /boot/firmware vfat defaults 0 2
PARTUUID=8a6020b5-02 / ext4 defaults,noatime 0 1
I have an issue in that on several occasions, the /boot/firmware
(vfat) partition has (apparently at random) become "un-mounted"; I have noted this in the output of lsblk --fs
:
# 'boot/firmware' mounted correctly:
$ lsblk --fs
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
nvme0n1
├─nvme0n1p1 vfat FAT32 bootfs 146B-AD94 444.8M 13% /boot/firmware
└─nvme0n1p2 ext4 1.0 rootfs ece25014-1cd7-4874-9bfc-f91e486bc000 364.9G 2% /
# 'boot/firmware' becomes "un-mounted":
$ lsblk --fs
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
nvme0n1
├─nvme0n1p1 vfat FAT32 bootfs 146B-AD94 444.8M 13%
└─nvme0n1p2 ext4 1.0 rootfs ece25014-1cd7-4874-9bfc-f91e486bc000 364.9G 2% /
After considering a few options to help "troubleshoot" this issue, I thought that using the --poll
option with findmnt
would be a good choice; i.e.:
$ nohup /usr/bin/findmnt -n --poll=umount,mount --target /boot/firmware &
I've run this command, and tested it using umount
and mount
to trigger findmnt --poll
:
$ nohup /usr/bin/findmnt --poll=umount,mount --target /boot/firmware &
[1] 10904
# wait a while, then
$ sudo umount /boot/firmware
$ sudo mount -a
# check nohup.out:
$ cat nohup.out
umount /boot/firmware /dev/nvme0n1p1 vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro
mount /boot/firmware /dev/nvme0n1p1 vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro
What I need to do is trigger a routine when when the umount ...
output is produced. So far I've been unable to do that, and that's where I need some help. I need a script that starts the findmnt --poll
command, and then waits for an output beginning with umount
. When that output arrives, I'd like to run dmesg
(?), capture that output to a logfile, maybe some other diagnostic(s), and finally issue a sudo mount -a
.
After findmnt --poll
outputs another line with mount
, I think the script should return to a "waiting" state to capture the next umount
event.
I've read a bit on the wait
command, but wonder if it's the correct approach because:
The wait command makes a shell script or terminal session wait for background processes to finish.
In this case, findmnt --poll
doesn't finish - it continues to run, polling for another reportable state change. Any suggestions on how to approach this?
while read
and use acase
statement to run whatever commands you need based on the input. Something like unix.stackexchange.com/a/28183/70524 or unix.stackexchange.com/a/83992/70524 You don't need to usewait
at all.