The problem with using awk on blkid output is, it doesn't organise columns very well, whatever special options one uses.
Column 2 is LABEL, unless there is no label. then column 2 is UUID. Then for ext* you got the 'SEC _TYPE="ext2"' column before the actual 'TYPE' (e.g. ext4)
That then throws all the others in the list out of order, hence any script that relies on it can fail.
A script I made (scrappily and out of desperation) to get a consistent, readable partition list marking what is mounted for my new setup :
- Code: Select all
#!/bin/bash
# script name : partlist
# udev doesn't always assign the same device node to a disk Thanks udev.
# What was once, e.g. /dev/sda3, might be /dev/sdd3 next boot
# How do you know for sure which one you want to mount ?
# Don't you just love how blkid formats it's output and screws up the columns?
#
# get the partition list
# -c /dev/null stops blkid reading a (maybe outdated) cache
# get rid of some bits we don't want
/sbin/blkid -c /dev/null|sed 's/SEC_TYPE=\"ext2\"//'g|sed 's/://'g|sed 's/"//'g|sort > /tmp/blkid
# list what has no label
while read line; do
echo -e "$line"|grep -v LABEL=|awk '{print $1}'; done < /tmp/blkid >/tmp/nolabel
# If no label the columns are out of order so insert a non-blank "LABEL=" entry
for i in $(cat /tmp/nolabel); do sed -i "s:$i:$i LABEL=\"\" :" /tmp/blkid;done
# list what is mounted
/sbin/blkid -c /dev/null -o list|grep /dev|grep -v "(not mounted)"|awk '{print $1}'>/tmp/mounted
# mark mounts with "**" in the main list
for i in $(cat /tmp/mounted); do sed -i "s:$i:$i\**:" /tmp/blkid;done
# append a footnote to explain **
echo "** ** ** **">> /tmp/blkid
echo "**=MOUNTED">> /tmp/blkid
# tidy it up into nice columns
column -t /tmp/blkid >/tmp/partlist
# delete the crap
rm -f /tmp/blkid /tmp/mounted /tmp/nolabel
# display the result
xterm -geometry 95x30 -e "less /tmp/partlist"
Maybe bits of that are of some use. I'm not sure if "-c /dev/null" is a good idea or not, I don't trust the cache.
Anyway, thanks for looking in to this. Personally I'm really pleased with installer as it is, I can edit my own fstab, it depends how far you want to go supporting those who can't. But apparently the reason UUID became Debian default after Lenny was because of how udev handles device nodes, not always consistently.
With 27 partitions on 4 HD's here, I'm now using labels for absolutely everything.