Last active
October 30, 2016 00:12
-
-
Save lennart/5ced21666468e30aa2441dbfa6386b28 to your computer and use it in GitHub Desktop.
diy shell script explanation of base image creation to run systemd-nspawn containers from btrfs subvolumes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
log=3 | |
fence="s/.*/ &/" | |
echo "# How to make a new base image" | |
echo "for containers." | |
echo | |
echo "Create a new logical volume:" | |
echo | |
lvcreate --help 2> /dev/null | head -n $log | sed "$fence" | |
echo | |
echo | |
echo "Setup a filesystem on it:" | |
echo | |
mkfs.btrfs --help | head -n $log | sed "$fence" | |
echo | |
echo | |
echo "Mount new volume, read-write" | |
echo | |
mount --help | head -n $log | sed "$fence" | |
echo | |
echo | |
echo "Create a subvolume for the first _OS_ install" | |
echo | |
btrfs subvolume create --help | head -n $log | sed "$fence" | |
echo | |
echo | |
echo "Mount the subvolume, and bootstrap _OS_ on it" | |
echo | |
mount --help | head -n $log | sed "$fence" | |
debootstrap --help | head -n $log | sed "$fence" | |
echo | |
echo | |
echo "Unmount volume again" | |
echo | |
umount --help | head -n $log | sed "$fence" | |
echo | |
echo | |
echo 'Edit `/etc/fstab`, add volume e.g. __read-only__ on boot' | |
echo | |
cat /etc/fstab | head -n $log | sed "$fence" | |
echo | |
echo | |
echo "Spawn new container as disposable snapshot" | |
echo | |
systemd-nspawn -xb --help | head -n $log | sed "$fence" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment