added btrfs logic
This commit is contained in:
parent
8fb6610ee9
commit
48368fa7c8
|
|
@ -69,32 +69,23 @@ echo -ne "
|
|||
Creating Filesystems
|
||||
-------------------------------------------------------------------------
|
||||
"
|
||||
createsubvolumes () {
|
||||
btrfs subvolume create /mnt/@
|
||||
btrfs subvolume create /mnt/@home
|
||||
btrfs subvolume create /mnt/@var
|
||||
btrfs subvolume create /mnt/@tmp
|
||||
btrfs subvolume create /mnt/@.snapshots
|
||||
}
|
||||
do_btrfs() {
|
||||
mkfs.btrfs -L "$1" "$2" -f
|
||||
mount -t btrfs "$2" "$MOUNTPOINT"
|
||||
|
||||
mountallsubvol () {
|
||||
mount -o ${MOUNT_OPTIONS},subvol=@home ${partition3} /mnt/home
|
||||
mount -o ${MOUNT_OPTIONS},subvol=@tmp ${partition3} /mnt/tmp
|
||||
mount -o ${MOUNT_OPTIONS},subvol=@var ${partition3} /mnt/var
|
||||
mount -o ${MOUNT_OPTIONS},subvol=@.snapshots ${partition3} /mnt/.snapshots
|
||||
}
|
||||
echo "Creating subvolumes and directories"
|
||||
for x in "${SUBVOLUMES[@]}"; do
|
||||
btrfs subvolume create "$MOUNTPOINT"/"${x}" >/dev/null 2>&1
|
||||
done
|
||||
|
||||
subvolumesetup () {
|
||||
# create nonroot subvolumes
|
||||
createsubvolumes
|
||||
# unmount root to remount with subvolume
|
||||
umount /mnt
|
||||
# mount @ subvolume
|
||||
mount -o ${MOUNT_OPTIONS},subvol=@ ${partition3} /mnt
|
||||
# make directories home, .snapshots, var, tmp
|
||||
mkdir -p /mnt/{home,var,tmp,.snapshots}
|
||||
# mount subvolumes
|
||||
mountallsubvol
|
||||
mount -o "$MOUNT_OPTIONS",subvol=@ "$2" "$MOUNTPOINT"
|
||||
|
||||
for z in "${SUBVOLUMES[@]:1}"; do
|
||||
w="${z[*]//@/}"
|
||||
mkdir /mnt/"${w}"
|
||||
mount -o "$MOUNT_OPTIONS",subvol="${z}" "$2" "$MOUNTPOINT"/"${w}"
|
||||
done
|
||||
}
|
||||
|
||||
if [[ "${DISK}" =~ "nvme" ]]; then
|
||||
|
|
@ -107,9 +98,7 @@ fi
|
|||
|
||||
if [[ "${FS}" == "btrfs" ]]; then
|
||||
mkfs.vfat -F32 -n "EFIBOOT" ${partition2}
|
||||
mkfs.btrfs -L ROOT ${partition3} -f
|
||||
mount -t btrfs ${partition3} /mnt
|
||||
subvolumesetup
|
||||
do_btrfs "ROOT" "${partition3}"
|
||||
elif [[ "${FS}" == "ext4" ]]; then
|
||||
mkfs.vfat -F32 -n "EFIBOOT" ${partition2}
|
||||
mkfs.ext4 -L ROOT ${partition3}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,30 @@ set_option() {
|
|||
# Arguments : list of options, maximum of 256
|
||||
# "opt1" "opt2" ...
|
||||
# Return value: selected index (0 for opt1, 1 for opt2 ...)
|
||||
|
||||
set_btrfs() {
|
||||
echo "Please enter your btrfs subvolumes separated by space"
|
||||
echo "usualy they start with @."
|
||||
echo "like @home, [defaults are @home, @var, @tmp, @.snapshots]"
|
||||
echo " "
|
||||
read -r -p "press enter to use default: " -a ARR
|
||||
if [[ -z "${ARR[*]}" ]]; then
|
||||
set_option "SUBVOLUMES" "(@ @home @var @tmp @.snapshots)"
|
||||
else
|
||||
NAMES=(@)
|
||||
for i in "${ARR[@]}"; do
|
||||
if [[ $i =~ [@] ]]; then
|
||||
NAMES+=("$i")
|
||||
else
|
||||
NAMES+=(@"${i}")
|
||||
fi
|
||||
done
|
||||
IFS=" " read -r -a SUBS <<<"$(tr ' ' '\n' <<<"${NAMES[@]}" | awk '!x[$0]++' | tr '\n' ' ')"
|
||||
set_option "SUBVOLUMES" "${SUBS[*]}"
|
||||
set_option "MOUNTPOINT" "/mnt"
|
||||
fi
|
||||
}
|
||||
|
||||
select_option() {
|
||||
|
||||
# little helpers for terminal print control and key input
|
||||
|
|
@ -150,7 +174,10 @@ options=("btrfs" "ext4" "luks" "exit")
|
|||
select_option $? 1 "${options[@]}"
|
||||
|
||||
case $? in
|
||||
0) set_option FS btrfs;;
|
||||
0)
|
||||
set_btrfs
|
||||
set_option FS btrfs
|
||||
;;
|
||||
1) set_option FS ext4;;
|
||||
2)
|
||||
while true; do
|
||||
|
|
|
|||
Loading…
Reference in New Issue