summaryrefslogtreecommitdiff
path: root/hooks/mount-partition.sh
blob: f554c28b250157d505605f1fe4736bcdf5f05444 (plain)
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
#!/bin/sh
[ "$root" ] || {
    root=$(getarg root=)
    case $root in
	LABEL=*) root=${root#LABEL=}
            root="$(echo $root |sed 's,/,\\x2f,g')"
            root="/dev/disk/by-label/${root}" ;;
        UUID=*) root="/dev/disk/by-uuid/${root#UUID=}" ;;
        '') echo "Warning: no root specified"
            root="/dev/sda1" ;;
    esac
}

[ "$rflags" ] || {
    if rflags="$(getarg rootflags=)"; then
	getarg rw && rflags="${rflags},rw" || rflags="${rflags},ro"
    else
	getarg rw && rflags=rw || rflags=ro
    fi
}

[ "$fstype" ] || {
    fstype="$(getarg rootfstype=)" && fstype="-t ${fstype}"
}

[ -e "$root" ] && mount $fstype -o "$rflags" "$root" "$NEWROOT" && \
    ROOTFS_MOUNTED=yes