fiss-linux

Some linux scripts for fiss
Log | Files | Refs | LICENSE

03-filesystems.sh (2150B)


      1 # vim: set ts=4 sw=4 et:
      2 
      3 [ -n "$VIRTUALIZATION" ] && return 0
      4 
      5 msg "Remounting rootfs read-only..."
      6 mount -o remount,ro / || emergency_shell
      7 
      8 if [ -x /sbin/dmraid -o -x /bin/dmraid ]; then
      9     msg "Activating dmraid devices..."
     10     dmraid -i -ay
     11 fi
     12 
     13 if [ -x /bin/mdadm ]; then
     14     msg "Activating software RAID arrays..."
     15     mdadm -As
     16 fi
     17 
     18 if [ -x /bin/btrfs ]; then
     19     msg "Activating btrfs devices..."
     20     btrfs device scan || emergency_shell
     21 fi
     22 
     23 if [ -x /sbin/vgchange -o -x /bin/vgchange ]; then
     24     msg "Activating LVM devices..."
     25     vgchange --sysinit -a ay || emergency_shell
     26 fi
     27 
     28 if [ -e /etc/crypttab ]; then
     29     msg "Activating encrypted devices..."
     30     awk -f /usr/share/fiss/crypt.awk /etc/crypttab
     31 
     32     if [ -x /sbin/vgchange -o -x /bin/vgchange ]; then
     33         msg "Activating LVM devices for dm-crypt..."
     34         vgchange --sysinit -a ay || emergency_shell
     35     fi
     36 fi
     37 
     38 if [ -x /usr/bin/zpool -a -x /usr/bin/zfs ]; then
     39     if [ -e /etc/zfs/zpool.cache ]; then
     40         msg "Importing cached ZFS pools..."
     41         zpool import -N -a -c /etc/zfs/zpool.cache
     42     else
     43         msg "Scanning for and importing ZFS pools..."
     44         zpool import -N -a -o cachefile=none
     45     fi
     46 
     47     msg "Mounting ZFS file systems..."
     48     zfs mount -a -l
     49 
     50     msg "Sharing ZFS file systems..."
     51     zfs share -a
     52 
     53     # NOTE(dh): ZFS has ZVOLs, block devices on top of storage pools.
     54     # In theory, it would be possible to use these as devices in
     55     # dmraid, btrfs, LVM and so on. In practice it's unlikely that
     56     # anybody is doing that, so we aren't supporting it for now.
     57 fi
     58 
     59 [ -f /fastboot ] && FASTBOOT=1
     60 [ -f /forcefsck ] && FORCEFSCK="-f"
     61 for arg in $(cat /proc/cmdline); do
     62     case $arg in
     63         fastboot) FASTBOOT=1;;
     64         forcefsck) FORCEFSCK="-f";;
     65     esac
     66 done
     67 
     68 if [ -z "$FASTBOOT" ]; then
     69     msg "Checking filesystems:"
     70     fsck -A -T -a -t noopts=_netdev $FORCEFSCK
     71     if [ $? -gt 1 ]; then
     72         emergency_shell
     73     fi
     74 fi
     75 
     76 msg "Mounting rootfs read-write..."
     77 mount -o remount,rw / || emergency_shell
     78 
     79 msg "Mounting all non-network filesystems..."
     80 mount -a -t "nosysfs,nonfs,nonfs4,nosmbfs,nocifs" -O no_netdev || emergency_shell