support automounting partitions if 'automount' string is present on boot command line
This commit is contained in:
+29
-2
@@ -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
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user