partman-btrfs/fstab.d/btrfs

80 lines
2.4 KiB
Bash
Executable file

#!/bin/sh
. /lib/partman/lib/base.sh
fs_found="unknown"
var_log_found="unknown"
# There is no btrfs fsck
pass=0
for dev in $DEVICES/*; do
[ -d $dev ] || continue
cd $dev
open_dialog PARTITIONS
while { read_line num id size type fs path name; [ "$id" ]; }; do
[ $fs != free ] || continue
[ -f "$id/method" ] || continue
[ -f "$id/acting_filesystem" ] || continue
method=$(cat $id/method)
filesystem=$(cat $id/acting_filesystem)
mountpoint=$(cat $id/mountpoint)
case "$filesystem" in
btrfs)
[ -f "$id/mountpoint" ] || continue
# due to #249322, #255135, #258117:
if [ "$mountpoint" = "/tmp" ]; then
rm -f $id/options/noexec
fi
options=$(get_mountoptions $dev $id)
if [ "$mountpoint" = "/" ]; then
# /var/log
if [ "$var_log_found" = "unknown" ]; then
var_log_options="${options:+$options,}subvol=log"
var_log_path="$path"
var_log_mp="${mountpoint}var/log"
var_log_found="false"
fi
# /run/witos
if [ "$fs_found" = "unknown" ]; then
fs_options="$options"
fs_path="$path"
fs_mp="${mountpoint}run/witos"
fs_found="false"
fi
db_get witos-release/version
witos_version="$RET"
options="${options:+$options,}subvol=images/${witos_version:-dev}"
elif [ "$mountpoint" = "/var/log" ]; then
options="${options:+$options,}subvol=log"
var_log_found="true"
fi
echo "$path" "$mountpoint" btrfs "$options" 0 $pass
;;
*)
if [ "$mountpoint" = "/run/witos" ]; then
fs_found="true"
elif [ "$mountpoint" = "/var/log" ]; then
var_log_found="true"
elif [ "$mountpoint" = "/var" ]; then
var_log_found="true"
fi
;;
esac
done
close_dialog
done
if [ "$var_log_found" = "false" ]; then
echo "$var_log_path" "$var_log_mp" btrfs "$var_log_options" 0 $pass
var_log_found="true"
fi
if [ "$fs_found" = "false" ]; then
echo "$fs_path" "$fs_mp" btrfs "$fs_options" 0 $pass
fs_found="true"
fi