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