various fixes, data subvols changed, mostly handled elsewhere now
authorIan Kelling <ian@iankelling.org>
Wed, 16 Nov 2016 17:37:25 +0000 (09:37 -0800)
committerIan Kelling <ian@iankelling.org>
Mon, 6 Feb 2017 06:21:42 +0000 (22:21 -0800)
chboot
fai/config/distro-install-common/end
fai/config/files/etc/apt/preferences.d/stable/STABLE
fai/config/files/etc/motd/FAIBASE [deleted file]
fai/config/files/etc/systemd/system/fai_check.service/STABLE_BOOTSTRAP
fai/config/files/root/fai-check/STABLE_BOOTSTRAP
fai/config/hooks/partition.DEFAULT
fai/config/scripts/GRUB_PC/11-ian
live-kexec

diff --git a/chboot b/chboot
index 12befb8a13ab80d68e7f950d12af22e3f24ffb7c..2a357e6d2f1dba5e01d92bdd8fa597a3958cbfd0 100755 (executable)
--- a/chboot
+++ b/chboot
@@ -61,7 +61,8 @@ distro=$1
 
 if [[ ! $distro ]]; then
     echo "available distros:"
 
 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
 
     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 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
 
 e umount $mount_point
 e rmdir $mount_point
 
index d226af6ce85e826af2a55e5f3a0f7ea75fc5d8a4..3735142d3507aa798e1f5d36cceafc61e0a511d6 100755 (executable)
@@ -67,18 +67,17 @@ if [[ ! -e $f ]] || ! grep -xF "$line" $f; then
 fi
 
 
 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 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)
 $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
 done
index 7f2e29f0971e18de38da6af1df9d83515e832b98..bc0047b99141dc4684f5765ed1900ce8517a49e3 100644 (file)
@@ -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
 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 (file)
index 4e5a967..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-Plan your installation, and FAI installs your plan.
index 2328452f111bab2c3363e0fe5848fcdb4431121f..cbe42722c75c6fd696d0567b2b01be18cf1aea3a 100644 (file)
@@ -6,4 +6,4 @@ Type=oneshot
 ExecStart=/root/fai-check
 
 [Install]
 ExecStart=/root/fai-check
 
 [Install]
-WantedBy=multi-user.target
+WantedBy=network.target
index 29bb1fbb7272813e1755b349000bef79bd7c3cd4..15c865f671f1007cf05a5361a0524375103946b5 100755 (executable)
@@ -3,12 +3,20 @@
 set -eE -o pipefail
 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
 
 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
 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
         pxe-kexec -n --ignore-whitelist -l fai-generated faiserver ||:
     else
         return 0
index 46887e9712d1aa558fb08bcab3be976a4fce6723..f81c6af7d5914398ef976f0916afb06b604866e8 100755 (executable)
@@ -31,12 +31,17 @@ rootn=1
 swapn=2
 bootn=3
 # ext partition so grub can write persistent variables,
 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
 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
 
 
 boot_mib=10000
 
 
@@ -358,21 +363,17 @@ if [[ $DISTRO != debianstable_bootstrap ]]; then
     cd /mnt
 
     btrfs subvolume create root_$DISTRO
     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
 
     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,
     # 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.
     # 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.
 
 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
 
 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
 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
     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
 $first_boot_dev  /boot  btrfs  noatime,subvol=$boot_vol  0 0
 EOF
-
     swaps=()
     for dev in ${devs[@]}; do
         swaps+=(`swap-cryptname`)
     swaps=()
     for dev in ${devs[@]}; do
         swaps+=(`swap-cryptname`)
index f4f1b7c87823afe24ea42ba7c87e4613d95ae0e2..a10efef37e185b42fd8e8a5d40c22b57a4b07a6c 100755 (executable)
@@ -13,6 +13,11 @@ if ! type -t fcopy &>/dev/null; then
 fi
 
 chroot $FAI_ROOT bash <<'EOFOUTER'
 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
 debconf-set-selections <<EOF
 kexec-tools kexec-tools/load_kexec boolean false
 EOF
@@ -69,9 +74,6 @@ usermod -aG adm,cdrom,floppy,sudo,audio,dip,video,plugdev,netdev ian
 
 if getent group systemd-journal >/dev/null; then
   usermod -aG systemd-journal ian
 
 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
 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
index 10975a8f223790a4499a558ceacf58f869616ae6..fd4bf6fa924658c55b2773c0241a27148d85ecaf 100644 (file)
@@ -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
 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
 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
 pxe-kexec -n --ignore-whitelist -l fai-generated faiserver