filesystems: re-enable only for swap configuration; systemd service: start befare swap.target

This commit is contained in:
Silvan Calarco 2013-09-26 14:26:55 +02:00
parent c7a0828eaa
commit d18482236a
2 changed files with 21 additions and 23 deletions

View File

@ -5,9 +5,6 @@
# Copyright (c) 2007 by Stefano Cotta Ramusino <stefano.cotta@openmamba.org> # Copyright (c) 2007 by Stefano Cotta Ramusino <stefano.cotta@openmamba.org>
# Copyright (c) 2009-2013 by Silvan Calarco <silvan.calarco@mambasoft.it> # Copyright (c) 2009-2013 by Silvan Calarco <silvan.calarco@mambasoft.it>
# systemd: completely disable for now
[ -d /run/systemd ] && exit 0
if [ $UID != 0 ]; then if [ $UID != 0 ]; then
echo "$0: must be superuser." >&2 echo "$0: must be superuser." >&2
exit 1 exit 1
@ -75,6 +72,10 @@ ${dir/[0-9]*/}$((${dir/$mp_suffix/}+1))" ;;
esac esac
} }
if [ -d /run/systemd ]; then
# With systemd only manage swap and disable everything else
unset FS_FLOPPY_UPDATE FS_CDROM_UPDATE FS_VFS_UPDATE FS_NODEV_REMOVE FS_PARTS_UPDATE FS_PARTS_MOUNT
fi
tmpfstab=`mktemp -q -t $me.XXXXXXXX` || tmpfstab=`mktemp -q -t $me.XXXXXXXX` ||
{ logmsg "$me" $"error: "$"cannot create temporary files" { logmsg "$me" $"error: "$"cannot create temporary files"
@ -89,7 +90,7 @@ trap "rm -f $tmpfstab" 0 1 2 5 15
# -name cdrecording -o -name cdrecording[0-9]\* \ # -name cdrecording -o -name cdrecording[0-9]\* \
#\) -print | xargs rmdir 2>/dev/null #\) -print | xargs rmdir 2>/dev/null
if [ "$FS_VFS_UPDATE" != no ]; then if [ "$FS_VFS_UPDATE" = "yes" ]; then
# note: '[ \t]\+/proc[ \t]\+' does not work :( # note: '[ \t]\+/proc[ \t]\+' does not work :(
grep -q "/proc" $fstab 2>/dev/null || grep -q "/proc" $fstab 2>/dev/null ||
{ echo "proc /proc proc defaults 0 0" >> $fstab { echo "proc /proc proc defaults 0 0" >> $fstab
@ -124,7 +125,7 @@ if [ "$FS_VFS_UPDATE" != no ]; then
fi fi
if [ "$FS_NO_DEV_REMOVE" = yes ]; then if [ "$FS_NO_DEV_REMOVE" = "yes" ]; then
[ -e $fstab ] && cp $fstab $tmpfstab || touch $fstab [ -e $fstab ] && cp $fstab $tmpfstab || touch $fstab
while read fs mount_point fstype options dump fsck_order ignore; do while read fs mount_point fstype options dump fsck_order ignore; do
case $fs in case $fs in
@ -163,9 +164,8 @@ let "swapon = 0"
# scan for new devices using the searching mask `$devs2scan' # scan for new devices using the searching mask `$devs2scan'
[[ "$FS_PARTS_MOUNT" = "yes" ]] && AUTO_ADD="" || AUTO_ADD="noauto," [[ "$FS_PARTS_MOUNT" = "yes" ]] && AUTO_ADD="" || AUTO_ADD="noauto,"
[[ "$FS_PARTS_UPDATE" = no && "$FS_SWAP_UPDATE" = no ]] || [[ "$FS_PARTS_UPDATE" != "yes" && "$FS_SWAP_UPDATE" != "yes" ]] ||
blkid | grep /dev/sd | while read line; do blkid | grep /dev/sd | while read line; do
unset dev uuid devline devfstype TYPE UUID LABEL unset dev uuid devline devfstype TYPE UUID LABEL
dev=${line/:*} dev=${line/:*}
devline=${line/*:} devline=${line/*:}
@ -194,11 +194,11 @@ blkid | grep /dev/sd | while read line; do
check_options="0 0" check_options="0 0"
case $dev in case $dev in
/dev/fd[0-9]*|/dev/floppy/[0-9]) # floppy disk drives /dev/fd[0-9]*|/dev/floppy/[0-9]) # floppy disk drives
[ "$FS_FLOPPY_UPDATE" = yes ] || continue [ "$FS_FLOPPY_UPDATE" = "yes" ] || continue
mount_point=$(get_new_mp_name floppy) mount_point=$(get_new_mp_name floppy)
;; ;;
/dev/cdrom[0-9]*) # CDROM devices /dev/cdrom[0-9]*) # CDROM devices
[ "$FS_CDROM_UPDATE" = yes ] || continue [ "$FS_CDROM_UPDATE" = "yes" ] || continue
# check if the CD is already mounted # check if the CD is already mounted
devfs="$(readlink -f $dev)" devfs="$(readlink -f $dev)"
mount | \ mount | \
@ -233,13 +233,13 @@ blkid | grep /dev/sd | while read line; do
# s/\([^ ]*[ ]*\)\{4\}\([^ ]*\).*/\2/p}" ) # s/\([^ ]*[ ]*\)\{4\}\([^ ]*\).*/\2/p}" )
case $devfstype in case $devfstype in
linux-swap|swap) # Linux swap linux-swap|swap) # Linux swap
[ "$FS_SWAP_UPDATE" = yes ] || continue [ "$FS_SWAP_UPDATE" = "yes" ] || continue
mount_point="swap" mount_point="swap"
fstype="swap" fstype="swap"
options="pri=1" options="pri=1"
let "swapon = 1" ;; let "swapon = 1" ;;
ext*|reiserfs|reiser4) # Linux partition ext*|reiserfs|reiser4) # Linux partition
[ "$FS_PARTS_UPDATE" = yes ] || continue [ "$FS_PARTS_UPDATE" = "yes" ] || continue
mount_point=$(get_new_mp_name "$label" $dev) mount_point=$(get_new_mp_name "$label" $dev)
if [[ "$mount_point" = "/" ]]; then if [[ "$mount_point" = "/" ]]; then
# found a root partition already mounted but not in fstab! # found a root partition already mounted but not in fstab!
@ -251,7 +251,7 @@ blkid | grep /dev/sd | while read line; do
fi fi
options="defaults,noatime" ;; options="defaults,noatime" ;;
ntfs|hpfs) # HPFS/NTFS ntfs|hpfs) # HPFS/NTFS
[ "$FS_PARTS_UPDATE" = yes ] || continue [ "$FS_PARTS_UPDATE" = "yes" ] || continue
mount_point=$(get_new_mp_name "$label" $dev) mount_point=$(get_new_mp_name "$label" $dev)
if [ -x /sbin/mount.ntfs-3g ]; then if [ -x /sbin/mount.ntfs-3g ]; then
fstype="ntfs-3g" fstype="ntfs-3g"
@ -261,17 +261,17 @@ blkid | grep /dev/sd | while read line; do
options="${AUTO_ADD}user,ro,gid=32,umask=002" options="${AUTO_ADD}user,ro,gid=32,umask=002"
fi ;; fi ;;
fat12|fat16|fat32|FAT|vfat) fat12|fat16|fat32|FAT|vfat)
[ "$FS_PARTS_UPDATE" = yes ] || continue [ "$FS_PARTS_UPDATE" = "yes" ] || continue
# FAT12, FAT16<32M, FAT16, FAT16 [LBA] # FAT12, FAT16<32M, FAT16, FAT16 [LBA]
# FAT32 [LBA] # FAT32 [LBA]
mount_point=$(get_new_mp_name "$label" $dev) mount_point=$(get_new_mp_name "$label" $dev)
options="${AUTO_ADD}user,gid=32,umask=002" ;; options="${AUTO_ADD}user,gid=32,umask=002" ;;
hfs|hfs+|hfsplus) hfs|hfs+|hfsplus)
[ "$FS_PARTS_UPDATE" = yes ] || continue [ "$FS_PARTS_UPDATE" = "yes" ] || continue
mount_point=$(get_new_mp_name "$label" $dev) mount_point=$(get_new_mp_name "$label" $dev)
options="${AUTO_ADD}user" ;; options="${AUTO_ADD}user" ;;
# f) # W95 Ext'd (LBA) # f) # W95 Ext'd (LBA)
# [ "$FS_PARTS_UPDATE" = yes ] || continue # [ "$FS_PARTS_UPDATE" = "yes" ] || continue
# unset nblocks # unset nblocks
# nblocks=$( echo $(grep ${dev/\/dev\//} /proc/partitions) | \ # nblocks=$( echo $(grep ${dev/\/dev\//} /proc/partitions) | \
# cut -d" " -f3 ) # cut -d" " -f3 )
@ -279,7 +279,7 @@ blkid | grep /dev/sd | while read line; do
# mount_point=$(get_new_mp_name "$label") # mount_point=$(get_new_mp_name "$label")
# options="${AUTO_ADD}user,gid=32,umask=002" ;; # options="${AUTO_ADD}user,gid=32,umask=002" ;;
*) # ignore unknown partitions *) # ignore unknown partitions
[ "$FS_PARTS_UPDATE" = yes ] || continue [ "$FS_PARTS_UPDATE" = "yes" ] || continue
logmsg "$me" $"ignoring unknown partition (id:$devfstype)" logmsg "$me" $"ignoring unknown partition (id:$devfstype)"
continue ;; continue ;;
esac esac
@ -313,11 +313,9 @@ ${fstype:-"auto"} ${options:-"noauto,user"}${extra_options} ${check_options}" >>
fi fi
done done
grep "[[:space:]]/[[:space:]].*ext[2-9].*defaults[[:space:]]" /etc/fstab >/dev/null && { grep "[[:space:]]/[[:space:]].*ext[2-9].*defaults,noatime[[:space:]]" /etc/fstab >/dev/null && {
logmsg "$me" $"enabling \`noatime' option for root filesystem" logmsg "$me" $"disabling \`noatime' option for root filesystem (previously added by postplug)"
sed -i "s|\([[:space:]]/[[:space:]].*ext[2-9].*defaults\)\([[:space:]]\)|\1,noatime\2|" /etc/fstab sed -i "s|\([[:space:]]/[[:space:]].*ext[2-9].*defaults\),noatime|\1|" /etc/fstab
mount -o remount /
} }
[ "$swapon" = 1 ] && swapon -a
exit 0 exit 0

View File

@ -2,7 +2,7 @@
Description=openmamba system configuration script Description=openmamba system configuration script
DefaultDependencies=no DefaultDependencies=no
After=systemd-udev-trigger.service systemd-remount-fs.service After=systemd-udev-trigger.service systemd-remount-fs.service
Before=sysinit.target Before=swap.target sysinit.target
[Service] [Service]
Type=oneshot Type=oneshot