support automounting partitions if 'automount' string is present on boot command line

This commit is contained in:
TomasM
2017-12-15 05:31:04 -05:00
parent 08c52c2854
commit 96eecc9058
3 changed files with 34 additions and 7 deletions
+29 -2
View File
@@ -278,6 +278,16 @@ mounted_dir()
}
# Get device tag.
# $1 = device
# $2 = tag name, such as TYPE, LABEL, UUID, etc
#
device_tag()
{
blkid -s $2 "$1" | sed -r "s/^[^=]+=//" | tr -d '"'
}
# Make sure to mount FAT12/16/32 using vfat
# in order to support long filenames
# $1 = device
@@ -287,7 +297,7 @@ device_bestfs()
debug_log "device_bestfs" "$*"
local FS
FS="$(blkid -s TYPE "$1" | sed -r "s/.*TYPE=//" | tr -d '"' | tr [A-Z] [a-z])"
FS="$(device_tag "$1" TYPE | tr [A-Z] [a-z])"
if [ "$FS" = "msdos" -o "$FS" = "fat" -o "$FS" = "vfat" ]; then
FS="vfat"
elif [ "$FS" = "ntfs" ]; then
@@ -775,13 +785,30 @@ fstab_create()
{
debug_log "fstab_create" "$*"
local FSTAB
local FSTAB DEVICE FS LABEL
FSTAB="$1/etc/fstab"
echo aufs / aufs defaults 0 0 > $FSTAB
echo proc /proc proc defaults 0 0 >> $FSTAB
echo sysfs /sys sysfs defaults 0 0 >> $FSTAB
echo devpts /dev/pts devpts gid=5,mode=620 0 0 >> $FSTAB
echo tmpfs /dev/shm tmpfs defaults 0 0 >> $FSTAB
if grep -vq automount /proc/cmdline; then
return
fi
echo >> $FSTAB
blkid | cut -d: -f 1 | while read DEVICE; do
FS="$(device_tag $DEVICE TYPE)"
LABEL="$(device_tag $DEVICE LABEL | sed -r "s:[/ ]:_:g")"
if [ "$LABEL" = "" ]; then LABEL="$(basename $DEVICE)"
if [ "$FS" != "swap" ]; then
mkdir -p "$1/media/$LABEL"
echo "$DEVICE" "/media/$LABEL" $FS defaults,noatime 0 0 >> $FSTAB
fi
done
}