Customise partman-btrfs for witOS
This commit is contained in:
parent
a8d10cfbc5
commit
88f7226135
3 changed files with 107 additions and 43 deletions
13
debian/control
vendored
13
debian/control
vendored
|
|
@ -1,17 +1,18 @@
|
|||
Source: partman-btrfs
|
||||
Section: debian-installer
|
||||
Priority: standard
|
||||
Maintainer: Debian Install System Team <debian-boot@lists.debian.org>
|
||||
Uploaders: Anton Zinoviev <zinoviev@debian.org>,
|
||||
Nicholas D Steeves <nsteeves@gmail.com>
|
||||
Maintainer: witOS Team <team@witos.dev>
|
||||
Uploaders: Andrew Ying <andrew@witine.com>
|
||||
Build-Depends: debhelper-compat (= 13), dh-di, po-debconf
|
||||
Rules-Requires-Root: no
|
||||
Vcs-Browser: https://salsa.debian.org/installer-team/partman-btrfs
|
||||
Vcs-Git: https://salsa.debian.org/installer-team/partman-btrfs.git
|
||||
XS-Debian-Vcs-Browser: https://salsa.debian.org/installer-team/partman-btrfs
|
||||
XS-Debian-Vcs-Git: https://salsa.debian.org/installer-team/partman-btrfs.git
|
||||
Vcs-Browser: https://git.witine.com/witos/partman-btrfs
|
||||
Vcs-Git: https://git.witine.com/witos/partman-btrfs.git
|
||||
|
||||
Package: partman-btrfs
|
||||
Package-Type: udeb
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends}, btrfs-progs-udeb, btrfs-modules, partman-basicfilesystems, partman-base
|
||||
Depends: ${misc:Depends}, btrfs-progs-udeb, btrfs-modules, partman-basicfilesystems, partman-base, witos-release
|
||||
Provides: partman-filesystem
|
||||
Description: Add to partman support for btrfs
|
||||
|
|
|
|||
102
fstab.d/btrfs
102
fstab.d/btrfs
|
|
@ -2,33 +2,79 @@
|
|||
|
||||
. /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)
|
||||
case "$filesystem" in
|
||||
btrfs)
|
||||
[ -f "$id/mountpoint" ] || continue
|
||||
mountpoint=$(cat $id/mountpoint)
|
||||
# due to #249322, #255135, #258117:
|
||||
if [ "$mountpoint" = "/tmp" ]; then
|
||||
rm -f $id/options/noexec
|
||||
fi
|
||||
if [ "$mountpoint" = "/" ]; then
|
||||
options="$(get_mountoptions $dev $id),subvol=@rootfs"
|
||||
else
|
||||
options=$(get_mountoptions $dev $id)
|
||||
fi
|
||||
# There is no btrfs fsck
|
||||
echo "$path" "$mountpoint" btrfs $options 0 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
close_dialog
|
||||
[ -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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
. /lib/partman/lib/base.sh
|
||||
|
||||
set -- $1
|
||||
|
||||
fs=$1
|
||||
|
|
@ -11,19 +13,34 @@ pass=$6
|
|||
|
||||
case $type in
|
||||
btrfs)
|
||||
# import workaround from Kali's partman-btrfs commit:7f43d2c
|
||||
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
|
||||
if [ $mp = / ]; then
|
||||
btrfs subvolume create /target$mp/@rootfs
|
||||
chmod 755 /target$mp/@rootfs
|
||||
umount /target$mp
|
||||
options="${options:+$options,}subvol=@rootfs"
|
||||
mount -t btrfs -o $options $fs /target$mp
|
||||
fi
|
||||
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
|
||||
;;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue