Debootstrap:ing

It’s that time of the year, or decade, to upgrade the file server’s OS. Got myself a new SSD and tought that’d be an easy upgrade path. Here’s what I did.

  • Rebooted as device information can get stale.
  • gparted /dev/sdb, Device » Create partition » gpt
  • ~100 GB at the start, ext4, boot flag
  • 8 GB swap at the end
  • mount /dev/sdb1 /mnt/sdb/1
  • mkswap /dev/sdb2
# get basics in place
debootstrap --arch amd64 xenial /mnt/sdb/1/ http://se.archive.ubuntu.com/ubuntu

# make a runnable environment
mount -o bind /dev /mnt/dev
mount -o bind /dev/pts /mnt/dev/pts
mount -t sysfs /sys /mnt/sys
mount -t proc /proc /mnt/proc
cp /proc/mounts /mnt/etc/mtab
cp /etc/resolv.conf /mnt/etc/resolv.conf

# chroot into it
LANG=en_US.UTF-8 chroot /mnt/

# configure locale
echo 'LC_ALL=en_US.UTF-8' >> /etc/default/locale
locale-gen en_US.UTF-8
update-locale LANG=en_US.UTF-8


cat > /etc/apt/sources.list << EOF
deb http://se.archive.ubuntu.com/ubuntu xenial main restricted universe multiverse
deb http://se.archive.ubuntu.com/ubuntu xenial-updates main restricted universe multiverse
deb http://se.archive.ubuntu.com/ubuntu xenial-backports main restricted universe multiverse
deb http://se.archive.ubuntu.com/ubuntu xenial-security main restricted universe multiverse
deb http://archive.canonical.com/ubuntu xenial partner
EOF

apt-get update && apt-get install apt vim openssl-server curl

# prep the user
useradd ceda
echo ceda:password | chpasswd
mkdir -p /home/ceda.ssh
curl http://fredrik.wendt.se/ssh/authorized_keys > /home/ceda/.ssh/authorized_keys
chown ceda:ceda /home/ceda -R
chmod 755 /home/ceda
chmod 700 /home/ceda/.ssh
chmod 600 /home/ceda/.ssh/authorized_keys

for i in adm cdrom sudo dip plugdev ; do usermod -aG $i ceda ; done

# set hostname
hostnamectl set-hostname XYZ

# make the disk bootable
apt install linux-image-generic
apt install zfsutils-linux dmraid

# back out
exit # chroot
umount /mnt/dev/pts
umount /mnt/dev/
umount /mnt/proc/
umount /mnt/sys
umount /mnt/

First boot

  • fix networking
  • apt install ubuntu-server
  • normal wendt bootstrap (ansible)
  • update infrastructure/machines
  • git clone gitlab-utils (and run sync)

References

  • https://videonauth.dyndns.org/index.php/2016/05/26/tutorial-how-to-install-ubuntu-and-other-debian-based-distributions-via-debootstrap/
  • http://manpages.ubuntu.com/manpages/xenial/man8/debootstrap.8.html
  • https://help.ubuntu.com/lts/installation-guide/amd64/apds04.html
This work by Fredrik Wendt is licensed under CC by-sa.