Closed ephestione closed 5 years ago
Yes, I will take a closer look to implement this
There is just one way to go about this IMO: rootfs PARTUUID is already extracted by the script, and a similar regexp to what was used to extract partuuid from /etc/fstab can be applied to /boot/cmdline.txt (which I seem to not be able to reproduce by altering the expression used in /etc/fstab...) If the two aren't equal, the script reports an inconsistency and alert the user of the possibility he's mounting the wrong partition as /boot
CMDLPU=$(cat /boot/cmdline.txt) CMDLPU=${CMDLPU##PARTUUID=} CMDLPU=${CMDLPU%% } echo ${CMDLPU}
grep "/boot" /etc/fstab |grep -o -E "PARTUUID=[0-9a-fA-F]+-[0-9a-fA-F]+"
grep "/ " /etc/fstab |grep -o -E "PARTUUID=[0-9a-fA-F]+-[0-9a-fA-F]+"
I didn't work on this in the past few days, your approach is an alternative to regex match on /etc/fstab, which works also on /boot/cmdline.txt like so:
grep -o -E "PARTUUID=[0-9a-fA-F]+-[0-9a-fA-F]+" /boot/cmdline.txt | grep -o -E "[0-9a-fA-F]+-[0-9a-fA-F]+"
Or better yet:
grep "^[^#;]" /boot/cmdline.txt | grep -o -E "PARTUUID=[0-9a-fA-F]+-[0-9a-fA-F]+" | grep -o -E "[0-9a-fA-F]+-[0-9a-fA-F]+"
since on one of my raspi's there was a commented line of an old config which generated a double output
The script should detect when the cmdline.txt contains a PARTUUID different from the actual partuuid of rootfs, which could mean that /etc/fstab was not updated with the correct PARTUUID for boot. It could give both false positives and false negatives, but it's still something relatively easy to do, and useful to have.