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
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
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
-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
+++ /dev/null
-
-
-Plan your installation, and FAI installs your plan.
ExecStart=/root/fai-check
[Install]
-WantedBy=multi-user.target
+WantedBy=network.target
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
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
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.
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
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 <<EOF
$first_root_crypt / btrfs noatime,subvol=root_$DISTRO 0 0
-$first_root_crypt /q btrfs noatime,subvol=q 0 0
-/q/a /a none bind 0 0
+$first_root_crypt /nocow btrfs noatime,subvol=nocow 0 0
+$first_root_crypt /mnt/root btrfs noatime,subvolid=0 0 0
$first_boot_dev /boot btrfs noatime,subvol=$boot_vol 0 0
EOF
-
swaps=()
for dev in ${devs[@]}; do
swaps+=(`swap-cryptname`)
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 <<EOF
kexec-tools kexec-tools/load_kexec boolean false
EOF
if getent group systemd-journal >/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
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 <<EOF
+if ! type -p pxe-kexec &>/dev/null; then
+ apt-get update
+ apt-get install -y debconf
+ debconf-set-selections <<EOF
kexec-tools kexec-tools/load_kexec boolean false
EOF
-apt-get install -y pxe-kexec
-# at least on belanos, apt-get goes into the background,
-# and we need to wait for it to finish.
-sleep 5
+ apt-get install -y pxe-kexec
+fi
+# running this piped to bash on belanos, the apt-get goes
+# into the background while it's still installing, and pxe-kexec
+# just exits right away. sleep calls are strangely ignored.
+# I don't know whats going on, but just running the same
+# command again once it finishes works, and this is only
+# rarely used and done manually anyways, so whatever.
pxe-kexec -n --ignore-whitelist -l fai-generated faiserver