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

View File

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