From 0a2a4d11ef323da19d0cebe2f5ec7b1be7bd15bc Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Wed, 16 Nov 2016 09:37:25 -0800 Subject: [PATCH] various fixes, data subvols changed, mostly handled elsewhere now --- chboot | 6 ++-- fai/config/distro-install-common/end | 5 ++-- .../files/etc/apt/preferences.d/stable/STABLE | 13 ++++++-- fai/config/files/etc/motd/FAIBASE | 3 -- .../system/fai_check.service/STABLE_BOOTSTRAP | 2 +- .../files/root/fai-check/STABLE_BOOTSTRAP | 8 +++++ fai/config/hooks/partition.DEFAULT | 30 +++++++++---------- fai/config/scripts/GRUB_PC/11-ian | 8 +++-- live-kexec | 19 +++++++----- 9 files changed, 58 insertions(+), 36 deletions(-) delete mode 100644 fai/config/files/etc/motd/FAIBASE diff --git a/chboot b/chboot index 12befb8..2a357e6 100755 --- a/chboot +++ b/chboot @@ -61,7 +61,8 @@ distro=$1 if [[ ! $distro ]]; then echo "available distros:" - btrfs subvolume list /boot | sed -rn 's/^.*boot_(.*)/\1/p' + cur=$(btrfs subvol show /boot| sed -rn 's/^.*Name:\s*(\S*).*/\1/p') + btrfs subvolume list /boot | awk '{print $9}' | sed "s/$cur/$cur (current)/" exit 0 fi @@ -98,7 +99,8 @@ e grub-bios-setup -d $mount_point/grub/i386-pc -s -m $mount_point/grub/device.ma e umount $mount_point e mount $boot_disk$grub_extn $mount_point -e grub-editenv $mount_point/grubenv set default_subvol=/boot_$distro +e grub-editenv $mount_point/grubenv set last_boot=/boot_$distro +e grub-editenv $mount_point/grubenv set did_fai_check=true e umount $mount_point e rmdir $mount_point diff --git a/fai/config/distro-install-common/end b/fai/config/distro-install-common/end index d226af6..3735142 100755 --- a/fai/config/distro-install-common/end +++ b/fai/config/distro-install-common/end @@ -67,18 +67,17 @@ if [[ ! -e $f ]] || ! grep -xF "$line" $f; then fi -dir=/q/p/c/machine_specific/$HOSTNAME/.unison +dir=/p/c/machine_specific/$HOSTNAME/.unison $ROOTCMD mkdir -p $dir if ! $ROOTCMD test -L /root/.unison; then $ROOTCMD rm -rf /root/.unison $ROOTCMD ln -s -T $dir /root/.unison fi -$ROOTCMD ln -sf /q/p / $ROOTCMD chown -R 1000:1000 $dir while true; do $ROOTCMD chown 1000:1000 $dir $ROOTCMD chmod 700 $dir dir=$(dirname $dir) - [[ $dir != /q ]] || break + if [[ $dir == /p ]]; then break; fi done diff --git a/fai/config/files/etc/apt/preferences.d/stable/STABLE b/fai/config/files/etc/apt/preferences.d/stable/STABLE index 7f2e29f..bc0047b 100644 --- a/fai/config/files/etc/apt/preferences.d/stable/STABLE +++ b/fai/config/files/etc/apt/preferences.d/stable/STABLE @@ -1,4 +1,13 @@ -Explanation: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=819978 -Package: tar +Explanation: tar, cuz https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=819978 +Explanation: kernel & btrfs-tools, because btrfs is getting a lot of active +Explanation: dev, and their mailing list says better to use recent version +Explanation: to avoid bugs. linux-base is needed for the kernel, +Explanation: which you can find out by failing +Explanation: apt-get install linux-image-amd64/jessie-backports +Explanation: And then trying aptitude -s install, or +Explanation: apt-get -t jessie-backports install linux-image-amd64 +Explanation: +Explanation: +Package: tar linux-image-amd64 linux-base btrfs-tools Pin: release a=jessie-backports Pin-Priority: 500 diff --git a/fai/config/files/etc/motd/FAIBASE b/fai/config/files/etc/motd/FAIBASE deleted file mode 100644 index 4e5a967..0000000 --- a/fai/config/files/etc/motd/FAIBASE +++ /dev/null @@ -1,3 +0,0 @@ - - -Plan your installation, and FAI installs your plan. diff --git a/fai/config/files/etc/systemd/system/fai_check.service/STABLE_BOOTSTRAP b/fai/config/files/etc/systemd/system/fai_check.service/STABLE_BOOTSTRAP index 2328452..cbe4272 100644 --- a/fai/config/files/etc/systemd/system/fai_check.service/STABLE_BOOTSTRAP +++ b/fai/config/files/etc/systemd/system/fai_check.service/STABLE_BOOTSTRAP @@ -6,4 +6,4 @@ Type=oneshot ExecStart=/root/fai-check [Install] -WantedBy=multi-user.target +WantedBy=network.target diff --git a/fai/config/files/root/fai-check/STABLE_BOOTSTRAP b/fai/config/files/root/fai-check/STABLE_BOOTSTRAP index 29bb1fb..15c865f 100755 --- a/fai/config/files/root/fai-check/STABLE_BOOTSTRAP +++ b/fai/config/files/root/fai-check/STABLE_BOOTSTRAP @@ -3,12 +3,20 @@ set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR +# keep it short so we don't delay too much wnen we don't have networking. +NETWORK_TIMOUT_SECS=10 fai_check=false check-fai() { # we could just as well check if last_boot != /debianstable_boostrap # the intent with this one is just a little clearer. if [[ $did_fai_check == true ]]; then fai_check=true + # ref: https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/ + deadline=$(( `date +%s` + NETWORK_TIMOUT_SECS )) + while ! systemctl status network-online.target && \ + (( `date +%s` < deadline )); do + sleep 1 + done pxe-kexec -n --ignore-whitelist -l fai-generated faiserver ||: else return 0 diff --git a/fai/config/hooks/partition.DEFAULT b/fai/config/hooks/partition.DEFAULT index 46887e9..f81c6af 100755 --- a/fai/config/hooks/partition.DEFAULT +++ b/fai/config/hooks/partition.DEFAULT @@ -31,12 +31,17 @@ rootn=1 swapn=2 bootn=3 # ext partition so grub can write persistent variables, -# so it can do a one time boot. +# so it can do a one time boot. grub can't write to +# btrfs or any cow fs because it's more +# more complicated to do and they don't want to. grub_extn=4 # bios boot partition, # https://wiki.archlinux.org/index.php/GRUB bios_grubn=5 lastn=$bios_grubn +# this is larger than needed for several /boot subvols, +# becuase I keep a minimal debian install on it, for +# recovery needs, and for doing pxe-kexec. boot_mib=10000 @@ -358,21 +363,17 @@ if [[ $DISTRO != debianstable_bootstrap ]]; then cd /mnt btrfs subvolume create root_$DISTRO - [[ -e q ]] || btrfs subvolume create q - chown root:1000 q + [[ -e nocow ]] || btrfs subvolume create nocow + chown root:1000 nocow + chattr +C nocow mkdir -p /mnt/root_$DISTRO/boot - for x in q/a q/i; do - mkdir -p $x - chown 1000:1000 $x - chmod 755 $x - done - # could set default like this, but no reason to. + # could set default subvol like this, but no reason to. # btrfs subvolume set-default \ # $(btrfs subvolume list . | grep "root_$DISTRO$" | awk '{print $2}') . # no cow on the root filesystem. it's setup is fully scripted, - # (immutable in buzzwords). if it messes up, we will just recreated it, + # if it's messed up, we will just recreated it, # and we can get better perf with this. # I can't remember exactly why, but this is preferable to mounting with # -o nodatacow, I think because subvolumes inherit that. @@ -385,7 +386,7 @@ mount -o subvolid=0 $first_boot_dev /mnt cd /mnt btrfs subvolume set-default 0 /mnt # already default, just ensuring it. -# for libreboot systems. +# for libreboot systems. grub2 only reads from subvolid=0 mkdir -p /mnt/grub2 cp $FAI/distro-install-common/libreboot_grub.cfg /mnt/grub2 @@ -417,14 +418,13 @@ BOOT_DEVICE="${short_devs[@]}" ROOT_PARTITION=$first_boot_dev EOF else - # note, the mount point /a seems to get automatically created somewhere + # note, fai creates the mountpoints like /nocow cat > /tmp/fai/fstab </dev/null; then fi chroot $FAI_ROOT bash <<'EOFOUTER' +if getent group systemd-journal >/dev/null; then + # makes the journal be saved to disk. + mkdir -p /var/log/journal + chmod 755 /var/log/journal +fi debconf-set-selections </dev/null; then usermod -aG systemd-journal ian - # makes the journal be saved to disk. - mkdir -p /var/log/journal - chmod 755 /var/log/journal fi # https://askubuntu.com/questions/33416/how-do-i-disable-the-boot-splash-screen-and-only-show-kernel-and-boot-text-inst # it suggests not having plymouth-theme-ubuntu-text, but diff --git a/live-kexec b/live-kexec index 10975a8..fd4bf6f 100644 --- a/live-kexec +++ b/live-kexec @@ -14,13 +14,18 @@ set -ex if grep -q ID=ubuntu /etc/os-release; then sed -ri '/^\s*deb/{/universe/!s/$/ universe/}' /etc/apt/sources.list fi -apt-get update -apt-get install -y debconf -debconf-set-selections </dev/null; then + apt-get update + apt-get install -y debconf + debconf-set-selections <