diff options
-rw-r--r-- | ansible.cfg | 3 | ||||
-rwxr-xr-x | clean-up-disks | 91 | ||||
-rwxr-xr-x | x220.sh | 36 | ||||
-rw-r--r-- | x220.vmdb | 116 |
4 files changed, 0 insertions, 246 deletions
diff --git a/ansible.cfg b/ansible.cfg deleted file mode 100644 index 67e1f40..0000000 --- a/ansible.cfg +++ /dev/null @@ -1,3 +0,0 @@ -[defaults] -nocows = 1 -log_path = ansible.log diff --git a/clean-up-disks b/clean-up-disks deleted file mode 100755 index 794badf..0000000 --- a/clean-up-disks +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/python3 - -import glob -import os -from subprocess import run - - -def physical_volumes(): - p = run(["pvdisplay", "-C", "--noheadings"], capture_output=True, check=True) - lines = p.stdout.decode().splitlines() - pvs = [] - for line in lines: - words = line.split() - pv = words[0] - vg = words[1] - pvs.append({"pv": pv, "vg": vg}) - return pvs - - -def logical_volumes(): - p = run(["lvdisplay", "-C", "--noheadings"], capture_output=True, check=True) - lines = p.stdout.decode().splitlines() - lvs = [] - for line in lines: - words = line.split() - lv = words[0] - vg = words[1] - path = os.path.realpath(f"/dev/{vg}/{lv}") - lvs.append({"lv": lv, "vg": vg, "path": path}) - return lvs - - -def volume_groups(): - p = run(["vgdisplay", "-C", "--noheadings"], capture_output=True, check=True) - lines = p.stdout.decode().splitlines() - return [line.split()[0] for line in lines if line.strip()] - - -def mount_points(): - mounts = {} - for line in open("/proc/mounts").readlines(): - words = line.split() - dev = os.path.realpath(words[0]) if words[0].startswith("/") else words[0] - mounts[dev] = { - "mount": words[1], - "type": words[2], - } - return mounts - - -def find_mount_points(mounts, dev): - res = [] - if dev in mounts: - root = mounts[dev]["mount"] - for m in mounts.values(): - if m["mount"].startswith(root): - res.append(m) - return res - - -def is_luks(path): - p = run(["cryptsetup", "isLuks", path], check=False) - return p.returncode == 0 - - -mounts = mount_points() -pvs = physical_volumes() -lvs = logical_volumes() -vgs = volume_groups() - -for lv in lvs: - for m in find_mount_points(mounts, lv["path"]): - print("unount", m["mount"]) - run(["umount", m["mount"]]) - -for vg in vgs: - print("vgremove", vg) - run(["vgremove", "--yes", vg], check=True) - -for pv in pvs: - print("pvremove", pv) - run(["pvremove", pv["pv"]], check=True) - if is_luks(pv["pv"]): - print("cryptsetup close", pv["pv"]) - run(["cryptsetup", "close", pv["pv"]], check=True) - else: - print("not LUKS:", pv["pv"]) - -for mapping in glob.glob("/dev/mapper/*"): - if not mapping.endswith("/control"): - run(["cryptsetup", "close", mapping], check=False) diff --git a/x220.sh b/x220.sh deleted file mode 100755 index dcb322d..0000000 --- a/x220.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -vi="$1" -vmdb2="$2" - -gitget() { - local url="$1" - local branch="$2" - local dir="$3" - echo "get $url ($branch)" - if [ ! -e "$dir" ]; then - git clone -b "$branch" "$url" - else - (cd "$dir" && git checkout "$branch" && git pull) - fi -} - -git config --global pull.ff only -gitget git://git.liw.fi/v-i "$vi" v-i -gitget git://git.liw.fi/vmdb2 "$vmdb2" vmdb2 -gitget git://git.liw.fi/ansibleness main ansibleness -gitget git://git.liw.fi/debian-ansible main debian-ansible - -cd v-i -export ANSIBLE_LOG=/root/ansible.log -export ANSIBLE_ROLES_PATH=/root/debian-ansible/roles:/root/ansibleness/ansible/roles - -rm -f /root/x220.log -/root/vmdb2/vmdb2 \ - --verbose \ - --rootfs-tarball /root/rootfs.tar.gz \ - --log /root/x220.log \ - --image /dev/sda \ - x220.vmdb diff --git a/x220.vmdb b/x220.vmdb deleted file mode 100644 index 2d088a0..0000000 --- a/x220.vmdb +++ /dev/null @@ -1,116 +0,0 @@ -# This is a vmdb2 input file that installs Debian onto my Thinkpad -# X220. It has an SSD as sdb. - -steps: - - mklabel: gpt - device: "{{ image }}" - - # EFI partition. This MUST be vfat and cleartext so that UEFI BIOS - # can handle it. - - mkpart: primary - device: "{{ image }}" - start: 0% - end: 500M - tag: efi - - - mkfs: vfat - partition: efi - - # /boot partition. This will be cleartext, because GRUB doesn't seem - # to support LUKS2 yet. - - mkpart: primary - device: "{{ image }}" - start: 500M - end: 1G - tag: boot - - - mkfs: ext2 - partition: boot - - # The physical volume for LVM. This will be encrypted and the - # unlocked, opened variant will be used as the physical volume for - # LVM2. - - mkpart: primary - device: "{{ image }}" - start: 1G - end: 100% - tag: cleartext_pv0 - - - cryptsetup: cleartext_pv0 - password: asdf - name: pv0 - - - vgcreate: vg0 - physical: - - pv0 - - - lvcreate: vg0 - name: root - size: 10G - - - mkfs: ext4 - partition: root - - # Mount the file systems on top of each other. - - mount: root - - - mount: boot - dirname: /boot - mount-on: root - - - mount: efi - dirname: /boot/efi - mount-on: boot - - - virtual-filesystems: root - - # Install Debian. - - - unpack-rootfs: root - - - debootstrap: bullseye - mirror: http://deb.debian.org/debian - target: root - unless: rootfs_unpacked - - - apt: install - packages: - - linux-image-amd64 - tag: root - unless: rootfs_unpacked - - - cache-rootfs: root - unless: rootfs_unpacked - - # Create fstab and crypttab - - fstab: root - - # Install additional packages. These are not in the rootfs tarball, - # while I keep changing this list: it's easier and faster to iterate - # if the rootfs tarball doesn't need to be re-generated from - # scratch. - - apt: install - packages: - - console-setup - - cryptsetup - - cryptsetup-initramfs - - dosfstools - - ifupdown - - locales-all - - lvm2 - - psmisc - - python3 - - ssh - - strace - tag: root - - # Configure the system with Ansible. - - ansible: root - playbook: x220.yml - - # Install GRUB as the bootloader. - - grub: uefi - tag: root - efi: efi - quiet: true - image-dev: "{{ image }}" |