partman-btrfs/mount.d/btrfs

49 lines
1.1 KiB
Bash
Executable file

#!/bin/sh
. /lib/partman/lib/base.sh
set -- $1
fs=$1
mp=$2
type=$3
options=$4
dump=$5
pass=$6
case $type in
btrfs)
options="${options%,subvol=*}"
#for removing the option subvol,when thats the only option
#eg: options=="subvol=@", no comma present
options="${options%subvol=*}"
mount -t btrfs ${options:+-o "$options"} $fs /target$mp || exit 1
case $mp in
/)
mkdir /target$mp/images
chmod 755 /target$mp/images
db_get witos-release/version
witos_version="$RET"
btrfs subvolume create /target$mp/images/${witos_version:-dev}
chmod 755 /target$mp/images/${witos_version:-dev}
umount /target$mp
options="${options:+$options,}subvol=images/${witos_version:-dev}"
mount -t btrfs -o $options $fs /target$mp
;;
/var/log)
btrfs subvolume create /target$mp/log
chmod 755 /target$mp/log
umount /target$mp
options="${options:+$options,}subvol=log"
mount -t btrfs -o $options $fs /target$mp
;;
/run/witos)
umount /target$mp
;;
esac
echo "umount /target$mp"
exit 0
;;
esac
exit 1