diff options
Diffstat (limited to 'core-services/03-filesystems.sh')
-rwxr-xr-x | core-services/03-filesystems.sh | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/core-services/03-filesystems.sh b/core-services/03-filesystems.sh new file mode 100755 index 0000000..02df01a --- /dev/null +++ b/core-services/03-filesystems.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# vim: set ts=4 sw=4 et: + +. /etc/runit/functions +[ -r /etc/rc.conf ] && . /etc/rc.conf + +[ -n "$VIRTUALIZATION" ] && return 0 + +msg "Remounting rootfs read-only...\n" +mount -o remount,ro / || emergency_shell + +if [ -x /sbin/dmraid ]; then + msg "Activating dmraid devices...\n" + dmraid -i -ay || emergency_shell +fi + +if [ -x /bin/btrfs ]; then + msg "Activating btrfs devices...\n" + btrfs device scan || emergency_shell +fi + +if [ -x /sbin/vgchange ]; then + msg "Activating LVM devices...\n" + vgchange --sysinit -a y || emergency_shell +fi + +if [ -e /etc/crypttab ]; then + msg "Activating encrypted devices...\n" + awk '/^#/ || /^$/ { next } + NF>2 { print "unsupported crypttab: " $0 >"/dev/stderr"; next } + { system("cryptsetup luksOpen " $2 " " $1) }' /etc/crypttab + + if [ -x /sbin/vgchange ]; then + msg "Activating LVM devices for dm-crypt...\n" + vgchange --sysinit -a y || emergency_shell + fi +fi + +msg "Checking filesystems:\n" +fsck -A -T -a -t noopts=_netdev +if [ $? -gt 1 ]; then + emergency_shell +fi + +msg "Mounting rootfs read-write...\n" +mount -o remount,rw / || emergency_shell + +msg "Mounting all non-network filesystems...\n" +mount -a -t "nosysfs,nonfs,nonfs4,nosmbfs,nocifs" -O no_netdev || emergency_shell |