/usr/lib/fai/fai-mount-disk is in fai-nfsroot 5.3.6ubuntu1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | #! /bin/bash
# Copyright (c) 2002-2015 by Thomas Lange
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fstab_mount() {
if [ $fstabcount -eq 1 ]; then
# save fstab
cp $FAI_ROOT/$fstabpart/etc/fstab /tmp
umount_local_disks
# mount according to fstab saved
mount2dir $FAI_ROOT /tmp/fstab 0 ro
fi
[ $fstabcount -eq 0 ] && echo "No /etc/fstab found"
[ $fstabcount -ge 2 ] && echo -e "Found multiple /etc/fstab files in : $fstablist\nUse mount2dir for mounting."
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mount_local_disks() {
# try to mount all local disk partitions containing a file system
local disk dev devname type
fstabcount=0
[ "$1" = "rw" ] && mountoption=$1
for disk in /dev/disk/by-uuid/*; do
type=$(blkid -sTYPE $disk)
[[ "$type" =~ "swap" ]] && continue
dev=$(readlink -e $disk)
devname=${dev##*/}
mkdir -p $FAI_ROOT/$devname
mount -o $mountoption $dev $FAI_ROOT/$devname
# look for btrfs subvolume
if [[ "$type" =~ "btrfs" ]]; then
subvol=$(btrfs sub list -a $FAI_ROOT/$devname|head -1)
subvol=${subvol#*path }
umount $FAI_ROOT/$devname
mount $dev -osubvol=$subvol $FAI_ROOT/$devname
fi
# \ && echo $partition mounted successfully
if [ -s $FAI_ROOT/$devname/etc/fstab ]; then
echo "/etc/fstab found in $dev"
fstabpart=$devname # used in fstab_mount
fstablist="$fstablist $devname"
(( fstabcount += 1 ))
fi
done
mount | grep $FAI_ROOT
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
umount_local_disks() {
# can be an extern script
local part
test -d $FAI_ROOT || return
for part in `grep $FAI_ROOT /proc/mounts | cut -d ' ' -f 2| sort -r`; do
umount $part
done
test -d $FAI_ROOT/ida && rmdir $FAI_ROOT/ida/*
test -d $FAI_ROOT/rd && rmdir $FAI_ROOT/rd/*
rmdir $FAI_ROOT/* 2>/dev/null
mountpoint -q $FAI_ROOT && umount $FAI_ROOT
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# main program
mountoption=ro
dofstab=0
while getopts ufw opt ; do
case "$opt" in
u) umount_local_disks ; exit ;;
w) mountoption=rw ;;
f) dofstab=1 ;;
esac
done
mount_local_disks
if [ $dofstab -eq 1 ]; then
fstab_mount
fi
|