about summary refs log tree commit diff
path: root/core-services/03-filesystems.sh
blob: d30c0e5c90af60799c653b14cc2a3831a3080d69 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# vim: set ts=4 sw=4 et:

[ -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