installer: user can choose BTRFS subvolume layout (e.g. to support Timeshift)

This commit is contained in:
Daniel Langbein 2021-06-22 16:34:46 +02:00
parent d094f08f9d
commit fdf3d5f622
3 changed files with 79 additions and 26 deletions

View File

@ -2,7 +2,7 @@
_pkgname=installer _pkgname=installer
_reponame=arch _reponame=arch
pkgname="de-p1st-$_pkgname" pkgname="de-p1st-$_pkgname"
pkgver=0.1.17 pkgver=0.1.18
pkgrel=1 pkgrel=1
pkgdesc="Bash script to install Arch Linux" pkgdesc="Bash script to install Arch Linux"
arch=('any') arch=('any')

View File

@ -44,12 +44,7 @@ function main() {
join_by ',' TMP1 FS_MOUNT_OPTIONS || return $? join_by ',' TMP1 FS_MOUNT_OPTIONS || return $?
} }
echo 'Mounting data partition with options: '"${FS_MOUNT_OPTIONS}" mount_partitions || return $?
sudo mount -o "${FS_MOUNT_OPTIONS}" "${DATA_PART}" /mnt || return $?
echo 'Mounting boot partition ...'
mkdir /mnt/boot || return $?
sudo mount "${BOOT_PART}" /mnt/boot || return $?
# in: BOOT_FIRMWARE # in: BOOT_FIRMWARE
run_pacstrap || return $? run_pacstrap || return $?
@ -100,6 +95,7 @@ function get_user_input() {
# @post # @post
# BOOT_FIRMWARE (uefi or bios) # BOOT_FIRMWARE (uefi or bios)
# FS (BTRFS, EXT4, F2FS) # FS (BTRFS, EXT4, F2FS)
# FS_BTRFS_SUBVOL_LAYOUT (root_only, @root@home)
# HOSTNAME # HOSTNAME
# USERNAME, USER_PWD # USERNAME, USER_PWD
# LUKS_PWD # LUKS_PWD
@ -120,16 +116,23 @@ function get_user_input() {
BOOT_FIRMWARE='bios' BOOT_FIRMWARE='bios'
fi fi
else else # If $BOOT_FIRMWARE is empty: Let user select BIOS type
# If $BOOT_FIRMWARE is empty: Let user select BIOS type TMP1=('uefi' 'Newer mainboards' \
'bios' 'Legacy BIOS on older mainboards')
TMP1=('uefi' 'Newer mainboards' 'bios' 'Legacy BIOS on older mainboards')
single_choice_if_empty BOOT_FIRMWARE 'Select your bios type' TMP1 || return $? single_choice_if_empty BOOT_FIRMWARE 'Select your bios type' TMP1 || return $?
fi fi
TMP1=('BTRFS' 'Allows snapshots and dynamic extension of the FS' 'EXT4' 'Default FS of many distributions' 'F2FS' 'Flash-Friendly-FS for SSD or NVMe') TMP1=('BTRFS' 'Allows snapshots and dynamic extension of the FS' \
'EXT4' 'Default FS of many distributions' \
'F2FS' 'Flash-Friendly-FS for SSD or NVMe')
single_choice_if_empty FS 'Select filesystem to use' TMP1 || return $? single_choice_if_empty FS 'Select filesystem to use' TMP1 || return $?
if [ "${FS}" = 'BTRFS' ]; then
TMP1=('root_only' 'Just one subvolume for "/".' \
'@root@home' 'Two subvolumes @ and @home. This configuration allows usage of "Timeshift".')
single_choice_if_empty FS_BTRFS_SUBVOL_LAYOUT 'Select your preferred subvolume layout' TMP1 || return $?
fi
ask_user_if_empty HOSTNAME 'Enter hostname:' || return $? ask_user_if_empty HOSTNAME 'Enter hostname:' || return $?
ask_user_if_empty USERNAME 'Enter username:' || return $? ask_user_if_empty USERNAME 'Enter username:' || return $?
@ -180,7 +183,7 @@ function get_default_mount_options() {
FS_DEFAULT_MOUNT_OPTIONS+=('compress_algorithm=lz4') FS_DEFAULT_MOUNT_OPTIONS+=('compress_algorithm=lz4')
;; ;;
*) *)
echo 'Filesystem '"$FS"' not yet supported!' echo 'Filesystem '"${FS}"' not yet supported!'
return 1 return 1
;; ;;
esac esac
@ -210,7 +213,7 @@ function get_additional_mount_options() {
TMP1=('noatime' 'Don'\''t write file/folder access times' 'on') TMP1=('noatime' 'Don'\''t write file/folder access times' 'on')
;; ;;
*) *)
echo 'Filesystem '"$FS"' not yet supported!' echo 'Filesystem '"${FS}"' not yet supported!'
return 1 return 1
;; ;;
esac esac
@ -218,6 +221,51 @@ function get_additional_mount_options() {
multi_choice_if_empty FS_ADDITIONAL_MOUNT_OPTIONS 'Select mount options' TMP1 || return $? multi_choice_if_empty FS_ADDITIONAL_MOUNT_OPTIONS 'Select mount options' TMP1 || return $?
} }
function mount_partitions() {
# @pre
# FS, FS_BTRFS_SUBVOL_LAYOUT, FS_MOUNT_OPTIONS, DATA_PART, BOOT_PART
if [ "${FS}" = 'BTRFS' ]; then
case "${FS_BTRFS_SUBVOL_LAYOUT}" in
'root_only')
# Nothing special; same steps as for a regular FS
echo 'Mounting data partition with options: '"${FS_MOUNT_OPTIONS}"
sudo mount -o "${FS_MOUNT_OPTIONS}" "${DATA_PART}" /mnt || return $?
;;
'@root@home')
# Timeshift BTRFS subvol layout:
# https://github.com/teejee2008/timeshift#supported-system-configurations
# Mount top level subvolume
sudo mount -o subvolid=5 "${DATA_PART}" /mnt || return $?
# Create subvolumes @ and @home
sudo btrfs subvolume create /mnt/@ || return $?
sudo btrfs subvolume create /mnt/@home || return $?
# List the created subvolumes
sudo btrfs subvolume list /mnt || return $?
# Umount the top level subvolume
sudo umount -R /mnt || return $?
echo 'Mounting @ and @home subvolumes with options: '"${FS_MOUNT_OPTIONS}"
sudo mount -o 'subvol=@'"${FS_MOUNT_OPTIONS}" "${DATA_PART}" /mnt || return $?
sudo mkdir /mnt/home || return $?
sudo mount -o 'subvol=@home'"${FS_MOUNT_OPTIONS}" "${DATA_PART}" /mnt/home || return $?
;;
*)
echo 'BTRFS subvolume layout '"${FS_BTRFS_SUBVOL_LAYOUT}"' not supported!'
return 1
;;
esac
else
echo 'Mounting data partition with options: '"${FS_MOUNT_OPTIONS}"
sudo mount -o "${FS_MOUNT_OPTIONS}" "${DATA_PART}" /mnt || return $?
fi
echo 'Mounting boot partition ...'
sudo mkdir /mnt/boot || return $?
sudo mount "${BOOT_PART}" /mnt/boot || return $?
}
function run_pacstrap() { function run_pacstrap() {
# @pre # @pre
# BOOT_FIRMWARE # BOOT_FIRMWARE
@ -292,7 +340,7 @@ function run_genfstab() {
true true
;; ;;
*) *)
echo 'Filesystem '"$FS"' not yet supported!' echo 'Filesystem '"${FS}"' not yet supported!'
return 1 return 1
;; ;;
esac esac

View File

@ -3,33 +3,34 @@
# FQDN=domain.name.of.this.host.de # FQDN=domain.name.of.this.host.de
# STATIC_IP=123.123.123.123 # STATIC_IP=123.123.123.123
# IPV6_CAPABLE=1 # IPV6_CAPABLE=1
HOSTNAME=yodaTest HOSTNAME='yodaTest'
USERNAME=yoda USERNAME='yoda'
# One should rather enter these interactively than saving in this cfg. # One should rather enter these interactively than saving in this cfg.
USER_PWD=test USER_PWD='test'
LUKS_PWD=test LUKS_PWD='test'
# If unset, then USER_PWD will be used for ROOT_PWD # If unset, then USER_PWD will be used for ROOT_PWD
# ROOT_PWD=test # ROOT_PWD=test
TARGET_BLOCK_DEVICE=/dev/sda TARGET_BLOCK_DEVICE='/dev/sda'
BOOT_PART_SIZE=500 # MiB BOOT_PART_SIZE='500' # MiB
FS=BTRFS FS='BTRFS'
FS_BTRFS_SUBVOL_LAYOUT='@root@home' # Subvolume layout that is supported by Timeshift
FS_ADDITIONAL_MOUNT_OPTIONS=('noatime') FS_ADDITIONAL_MOUNT_OPTIONS=('noatime')
# If not booted into the target system, these values should be set: # If not booted into the target system, these values should be set:
# CPU_VENDOR: "autodetect", "amd", "intel" or "none" # CPU_VENDOR: "autodetect", "amd", "intel" or "none"
CPU_VENDOR=autodetect CPU_VENDOR='autodetect'
# BOOT_FIRMWARE: "autodetect", "uefi" or "bios" # BOOT_FIRMWARE: "autodetect", "uefi" or "bios"
BOOT_FIRMWARE=uefi BOOT_FIRMWARE='uefi'
# If set to "1", then the data, boot and luks partitions # If set to "1", then the data, boot and luks partitions
# will be left mounted/opened for manual inspection # will be left mounted/opened for manual inspection
# after the installation # after the installation
LEAVE_MOUNTED=1 LEAVE_MOUNTED='1'
PACSTRAP_INTERACTIVE=1 PACSTRAP_INTERACTIVE='1'
############## ADDITIONAL_PKGS from here on ############## ############## ADDITIONAL_PKGS from here on ##############
ADDITIONAL_PKGS=() ADDITIONAL_PKGS=()
@ -55,3 +56,7 @@ ADDITIONAL_PKGS+=('intellij-idea-ultimate-edition' 'intellij-idea-ultimate-editi
ADDITIONAL_PKGS+=('evince') ADDITIONAL_PKGS+=('evince')
# Gallery / image viewer # Gallery / image viewer
ADDITIONAL_PKGS+=('nomacs' 'qt5-imageformats') ADDITIONAL_PKGS+=('nomacs' 'qt5-imageformats')
# LibreOffice with spell checking (de, us) and hyphenation rules (de, us)
ADDITIONAL_PKGS+=('libreoffice-fresh')
ADDITIONAL_PKGS+=('hunspell-de' 'hunspell-en_US')
ADDITIONAL_PKGS+=('hyphen' 'hyphen-de' 'hyphen-en')