Compare commits
8 Commits
1290869dfe
...
c66e910146
Author | SHA1 | Date | |
---|---|---|---|
c66e910146 | |||
f9b2f144a6 | |||
ac0e7dadf1 | |||
f9cb8c57a3 | |||
5ea002201f | |||
73258c22b0 | |||
d5f6e62b56 | |||
61cffda88b |
@@ -79,7 +79,7 @@ The ZFS pool and dataset setup that makes this tick, explained in plain English.
|
||||
1. Neither the root dataset nor the pool are mounted at this time. We now create one boot environment dataset where we want to install Arch Linux.
|
||||
1. `-o mountpoint=/`: Our Arch Linux dataset will be mounted at `/`.
|
||||
1. `-o canmount=noauto`: When set to `noauto`, a dataset can only be mounted and unmounted explicitly. The dataset is not mounted automatically when the dataset is created or imported, nor is it mounted by the `zfs mount -a` command or unmounted by the `zfs unmount -a` command.
|
||||
1. We then `zpool set bootfs="zpool/root/archlinux" zpool`: ZFSBootMenu uses the `bootfs` property to identify suitable boot environments. If only one dataset has it - as is the case here - it'll be booted by default with a 10-second countdown allowing manual interaction in ZFSBootMenu.
|
||||
1. We then `zpool set bootfs="zpool/root/archlinux" zpool`: ZFSBootMenu uses the `bootfs` property to identify suitable boot environments. If only one pool has it - as is the case here - it identifies the pool's preferred boot dataset that will be booted with a 10-second countdown allowing manual interaction in ZFSBootMenu.
|
||||
1. We explicitly mount the boot environment. Since the entire pool is still subject to our initial `-R /mnt` during creation a `zfs mount zpool/root/archlinux` will mount the Arch Linux dataset not into `/` but instead into `/mnt`.
|
||||
1. We also create a `data` dataset that - at least for now - we use to store only our `/home` data.
|
||||
1. For `zpool/data`:
|
||||
|
54
setup.sh
54
setup.sh
@@ -7,6 +7,10 @@ declare zpool_name zfs_arch_dataset_name
|
||||
zpool_name='zpool'
|
||||
zfs_arch_dataset_name='archlinux'
|
||||
|
||||
# https://unix.stackexchange.com/a/48550
|
||||
set -E
|
||||
trap '[ "$?" -ne 77 ] || exit 77' ERR
|
||||
|
||||
function set_ntp () {
|
||||
timedatectl set-ntp true
|
||||
}
|
||||
@@ -56,8 +60,8 @@ function get_parts () {
|
||||
parts="$(get_partitions | jq --raw-output '.[][] | select(.parttype=="c12a7328-f81f-11d2-ba4b-00a0c93ec93b") | .path')" || exit 1
|
||||
;;
|
||||
*)
|
||||
printf -- '%s\n' 'Unknown partition type '"'"'"${parttype}"'"'"', exiting 1 ...'
|
||||
exit 1
|
||||
>2 printf -- '%s\n' 'Unknown partition type '"'"'"${parttype}"'"'"', exiting 1 ...'
|
||||
exit 77
|
||||
;;
|
||||
esac
|
||||
printf -- '%s' "${parts}"
|
||||
@@ -72,8 +76,8 @@ function we_have_exactly_one_part () {
|
||||
if [[ "$(wc -c <<<"${parts_list}")" -gt '1' ]]; then
|
||||
case "${parts_count}" in
|
||||
0)
|
||||
printf -- '%s\n' 'No '"${parttype^^}"' partition found. Exiting 1 ...'
|
||||
exit 1
|
||||
>2 printf -- '%s\n' 'No '"${parttype^^}"' partition found. Exiting 1 ...'
|
||||
exit 77
|
||||
;;
|
||||
1)
|
||||
return 0
|
||||
@@ -82,20 +86,21 @@ function we_have_exactly_one_part () {
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
printf -- '%s\n' 'Partition list does not look valid. Cowardly exiting 1 ...'
|
||||
exit 1
|
||||
>2 printf -- '%s\n' 'Partition list does not look valid. Cowardly exiting 1 ...'
|
||||
exit 77
|
||||
fi
|
||||
}
|
||||
|
||||
function get_drive_id () {
|
||||
declare drive_id
|
||||
drive_id="$(find -L /dev/disk/by-id -samefile "${1:?}")"
|
||||
if [[ "$(wc -l <<<"${drive_id}")" -eq '1' ]] && [[ "$(wc -c <<<"${drive_id}")" -gt '1' ]]; then
|
||||
printf -- '%s' "${drive_id}"
|
||||
local drive_id_list drive_id_single
|
||||
drive_id_list="$(find -L /dev/disk/by-id -samefile "${1:?}" | sort)"
|
||||
drive_id_single="$(head -n1 <<<"${drive_id_list}")"
|
||||
if [[ "$(wc -l <<<"${drive_id_single}")" -eq '1' ]] && [[ "$(wc -c <<<"${drive_id_single}")" -gt '1' ]]; then
|
||||
printf -- '%s' "${drive_id_single}"
|
||||
return 0
|
||||
fi
|
||||
printf -- '%s\n' 'Not exactly one '"'${1:?}'"' partition entry in /dev/disk/by-id, exiting 1 ...'
|
||||
exit 1
|
||||
>2 printf -- '%s\n' 'Not exactly one '"'${1:?}'"' partition entry in /dev/disk/by-id, exiting 1 ...'
|
||||
exit 77
|
||||
}
|
||||
|
||||
function select_part () {
|
||||
@@ -220,8 +225,12 @@ function copy_zpool_cache () {
|
||||
zpool set 'cachefile=/etc/zfs/'"${zpool_name}"'.cache' "${zpool_name}"
|
||||
}
|
||||
|
||||
function install_archlinux () {
|
||||
function pacman_dl_parallel () {
|
||||
sed -ri -e 's'$'\x1''^.*?(ParallelDownloads)[^\r\n\f]*'$'\x1''\1 = 5'$'\x1''g' '/etc/pacman.conf'
|
||||
}
|
||||
|
||||
function install_archlinux () {
|
||||
pacman_dl_parallel
|
||||
pacstrap /mnt \
|
||||
base \
|
||||
base-devel \
|
||||
@@ -426,6 +435,21 @@ EOF
|
||||
systemctl enable "${path_unit}"
|
||||
}
|
||||
|
||||
function add_motd_getting_started_msg () {
|
||||
cat > '/etc/motd' <<"EOF"
|
||||
|
||||
####################
|
||||
|
||||
GUI basics:
|
||||
|
||||
paru -S xorg plasma-meta kde-applications-meta sddm
|
||||
localectl set-x11-keymap de
|
||||
|
||||
####################
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
function install_os_in_chroot () {
|
||||
### Reinit keyring
|
||||
# As keyring is initialized at boot, and copied to the install dir with pacstrap, and ntp is running
|
||||
@@ -437,6 +461,9 @@ function install_os_in_chroot () {
|
||||
pacman -S archlinux-keyring --noconfirm
|
||||
|
||||
keep_initiramfs_root_only_rw
|
||||
pacman_dl_parallel
|
||||
unleash_makepkg
|
||||
add_motd_getting_started_msg
|
||||
get_aur_helper
|
||||
paru_install 'zfs-dkms' 'zfs-utils'
|
||||
hwclock --systohc
|
||||
@@ -576,6 +603,7 @@ function main () {
|
||||
set_ntp
|
||||
update_pacman_db
|
||||
install_pkgs 'jq'
|
||||
unleash_makepkg
|
||||
install_zfs
|
||||
setup_zpool
|
||||
mount_system
|
||||
|
Reference in New Issue
Block a user