Browse Source

First try at making Docker persistent

content-update
xpetit 3 years ago
parent
commit
524492d205
  1. 23
      sh/debian/ubuntu/configure.sh
  2. 10
      sh/debian/ubuntu/system/etc/systemd/system/mount-docker.service
  3. 10
      sh/debian/ubuntu/system/usr/local/bin/mount-docker.sh

23
sh/debian/ubuntu/configure.sh diff.vendored

@ -388,10 +388,22 @@ cd $script_dir
rm -rf /tmp/system
if ! test -v PERSISTENT; then
sgdisk -n0:0:+32G "$disk"
sgdisk -N0 "$disk"
sgdisk -c3:01-tmp-home "$disk"
sgdisk -c4:01-tmp-system "$disk"
sgdisk --new 0:0:+32G "$disk"
sgdisk --new 0:0:+32G "$disk"
sgdisk --largest-new 0 "$disk"
sgdisk --change-name 3:01-tmp-home "$disk"
sgdisk --change-name 4:01-docker "$disk"
sgdisk --change-name 5:01-tmp-system "$disk"
# Add Docker persistent partition
mkfs.ext4 -E lazy_journal_init,lazy_itable_init=0 /dev/disk/by-partlabel/01-docker
echo 'PARTLABEL=01-docker /var/lib/docker ext4 noatime,errors=remount-ro 0 2' >> /etc/fstab
systemctl stop docker.service containerd.service
mv /var/lib/docker /tmp
mkdir /var/lib/docker
mount /dev/disk/by-partlabel/01-docker
mv /tmp/docker/* /var/lib/docker
umount /var/lib/docker
# Remove fsck because the system partition will be read-only (overlayroot)
rm /usr/share/initramfs-tools/hooks/fsck
@ -407,9 +419,6 @@ if ! test -v PERSISTENT; then
# Disable user password
passwd -d student
# Enable docker relocation
systemctl enable mount-docker
# Remove tty
cat <<-"EOF">> /etc/systemd/logind.conf
NAutoVTs=0

10
sh/debian/ubuntu/system/etc/systemd/system/mount-docker.service diff.vendored

@ -1,10 +0,0 @@
[Unit]
Description=Docker relocation
Before=docker.service
[Service]
ExecStart=/usr/local/bin/mount-docker.sh
Type=oneshot
[Install]
RequiredBy=docker.service

10
sh/debian/ubuntu/system/usr/local/bin/mount-docker.sh diff.vendored

@ -1,10 +0,0 @@
#!/usr/bin/env bash
# Unofficial Bash Strict Mode
set -euo pipefail
IFS='
'
cp -a /var/lib/docker /tmp
mount -t tmpfs -osize=2G tmpfs /var/lib/docker
mv /tmp/docker/* /var/lib/docker
Loading…
Cancel
Save