From cadde0df60e97c663825969cc5a7c35e9e96bb97 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Wed, 25 Dec 2019 11:27:26 +0200 Subject: Change: make v-i work on my x220 Previously, mysterious failings with grub. --- README.md | 48 ++++++++++++++++-------------------------------- ansible.cfg | 3 +++ bootinstalled | 22 ---------------------- bootvm | 23 ----------------------- v-i.vmdb | 10 +++++----- v-i.yml | 7 +------ x220.sh | 12 ++++++++++++ x220.vmdb | 23 ++++++++++++----------- x220.yml | 36 +++++++++++++++++++++++------------- 9 files changed, 72 insertions(+), 112 deletions(-) create mode 100644 ansible.cfg delete mode 100755 bootinstalled delete mode 100755 bootvm create mode 100755 x220.sh diff --git a/README.md b/README.md index 7ed4641..5640fa6 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,15 @@ -Install Debian using vmdb2 (v-i) +Install Debian using vmdb2 (v-i) onto my Thinkpad x220 laptop ============================================================================= WARNING! ----------------------------------------------------------------------------- -Warning: this is an operating system installer. It will overwrite your +**Warning:** this is an operating system installer. It will overwrite your hard drive and annihilate anything that used to be there. There are no safety rails. You will lose all your data. Make sure your backups work. You have been warned. + Introduction ----------------------------------------------------------------------------- @@ -16,7 +17,7 @@ This is a hack for my own amusement. It's not meant to be taken seriously. This is a rudimentary installer of Debian based on vmdb2. It has -nothing to do with debian-install, the official Debian installer, +nothing to do with debian-installer, the official Debian installer, known as d-i. I use d-i, but would like something better: * I'd like something I can easily modify. d-i requires building @@ -29,19 +30,21 @@ known as d-i. I use d-i, but would like something better: only helps to answer questions the packages ask. v-i lets you have the full power of Ansible during initial installation. -On the other hand, d-i is mature software and tested by thousands. v-i -can just barely install my own Thinkpad x220 laptop. +On the other hand, d-i is mature software and tested by a very large +number of people, on a very large number of different hardware. v-i +can just barely install my own Thinkpad x220 laptop, using UEFI. -v-i is not currently expected to work with any other hardware. +v-i is not currently expected to work with any other hardware. It +might not even work on your x220. Architecture ----------------------------------------------------------------------------- -The vmdb2-installer builds a bootable disk image with Debian. The -image boots with UEFI, and has everything you need to run vmdb2. You -write the image to a USB drive, boot off that, and run vmdb2 in the -booted system to install Debian onto the hard drive. +The vmdb2 installer builds a bootable disk image with Debian. The +image boots with UEFI, and has vmdb2 installed. You write the image to +a USB drive, boot off that, and run vmdb2 in the booted system to +install Debian onto the hard drive. Thus: @@ -49,6 +52,9 @@ Thus: - installer image -> USB drive - boot from USB drive - run vmdb2 to install onto laptop hard drive + - the /root/x220.sh script does this, and installs a basic Debian + system using my Ansible playbooks +- boot off the laptop hard drive The image building uses vmdb2 as well. Things get a little recursive. @@ -77,15 +83,6 @@ To write the resulting v-i.img to a USB drive: sudo dd if=v-i.img of=/dev/path/to/usb/drive/device status=progress oflag=direct ~~~ -Alternatively, use bmaptool (from bmap-tools), which does the same -thing as dd but skips holes in sparse files, so it's more efficient -for disk images: - -~~~sh -bmaptool create v-i.img > v-i.bmap -sudo bmaptool copy v-i.img /dev/path/to/usb/drive/device -~~~ - Plug in the USB drive to the laptop, boot off that. Log into the installer as root (no password), and run @@ -95,16 +92,3 @@ installer as root (no password), and run Reboot laptop from its hard drive and you should have a bare bones Debian system installed. - - -Virtual test envionment ------------------------------------------------------------------------------ - -You probably want to test with virtual machines instead of real -hardware, for convenience. - -~~~sh -apt install qemu-system -qemu-img create ~/tmp/main.img 10G -./bootvm ~/tmp/main.img 10G v-i.img -~~~ diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..67e1f40 --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,3 @@ +[defaults] +nocows = 1 +log_path = ansible.log diff --git a/bootinstalled b/bootinstalled deleted file mode 100755 index 55150a9..0000000 --- a/bootinstalled +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh -# -# Based on: https://wiki.debian.org/SecureBoot/VirtualMachine - -set -eu - -main="$1" -shift 1 - -if ! [ -e OVFM_VARS.fd ] -then - cp /usr/share/OVMF/OVMF_VARS.fd . -fi - -sudo chown liw:liw "$main" -kvm \ - -m 2048 \ - --machine pc-q35-2.5 \ - -drive if=pflash,format=raw,readonly,file=/usr/share/OVMF/OVMF_CODE.fd \ - -drive if=pflash,format=raw,file=./OVMF_VARS.fd \ - -drive file="$main",format=raw,index=0,media=disk \ - "$@" diff --git a/bootvm b/bootvm deleted file mode 100755 index e2ffb5e..0000000 --- a/bootvm +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -# -# Based on: https://wiki.debian.org/SecureBoot/VirtualMachine - -set -eu - -main="$1" -vi="$2" -shift 2 - -if ! [ -e OVFM_VARS.fd ] -then - cp /usr/share/OVMF/OVMF_VARS.fd . -fi - -kvm \ - -m 2048 \ - --machine pc-q35-2.5 \ - -drive if=pflash,format=raw,readonly,file=/usr/share/OVMF/OVMF_CODE.fd \ - -drive if=pflash,format=raw,file=./OVMF_VARS.fd \ - -drive file="$vi",format=raw,index=0,media=disk \ - -drive file="$main",format=raw,index=1,media=disk \ - "$@" diff --git a/v-i.vmdb b/v-i.vmdb index 68f4e17..a401a65 100644 --- a/v-i.vmdb +++ b/v-i.vmdb @@ -23,10 +23,6 @@ steps: partition: efi - mkfs: ext4 - - - mount: root - - - unpack-rootfs: root partition: / - mount: / @@ -49,7 +45,7 @@ steps: - apt: install packages: - - python + - python3-distutils - console-setup - locales-all - ifupdown @@ -68,6 +64,10 @@ steps: - ansible: / playbook: v-i.yml + - copy-file: /root/x220.sh + src: x220.sh + perm: 0755 + - fstab: / - grub: uefi diff --git a/v-i.yml b/v-i.yml index 5955513..c476585 100644 --- a/v-i.yml +++ b/v-i.yml @@ -40,7 +40,7 @@ shell: echo export LC_CTYPE=fi_FI.UTF8 >> /etc/profile.d/finnish.sh - - name: "configure networking" + - name: "configure Ethernet networking" copy: content: | auto eth0 @@ -53,11 +53,6 @@ src: "{{ rootfs_tarball }}" dest: /root/rootfs.tar.gz - - name: "copy my ssh pub key" - copy: - src: /home/liw/.ssh/liw-openpgp.pub - dest: /root/liw-openpgp.pub - - name: "add my ssh pub key to root's authorized keys" authorized_key: user: root diff --git a/x220.sh b/x220.sh new file mode 100755 index 0000000..f0e6524 --- /dev/null +++ b/x220.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +set -eux + +git clone -b x220 git://git.liw.fi/v-i +git clone git://git.liw.fi/ansibleness +git clone git://git.liw.fi/debian-ansible + +cd v-i +export ANSIBLE_LOG=/root/ansible.log +export ANSIBLE_ROLES_PATH=/root/debian-ansible/roles:/root/ansibleness/ansible/roles +vmdb2 --image /dev/sda x220.vmdb --verbose --rootfs-tarball /root/rootfs.tar.gz diff --git a/x220.vmdb b/x220.vmdb index d184107..26f913a 100644 --- a/x220.vmdb +++ b/x220.vmdb @@ -15,30 +15,30 @@ steps: device: "{{ image }}" start: 1G end: 100% - tag: rootfs + tag: / - mkfs: vfat partition: efi - mkfs: ext4 - partition: rootfs + partition: / - - mount: rootfs + - mount: / - - unpack-rootfs: rootfs + - unpack-rootfs: / - - debootstrap: unstable + - debootstrap: buster mirror: http://deb.debian.org/debian - target: rootfs + target: / unless: rootfs_unpacked - apt: install packages: - linux-image-amd64 - tag: rootfs + tag: / unless: rootfs_unpacked - - cache-rootfs: rootfs + - cache-rootfs: / unless: rootfs_unpacked - apt: install @@ -47,12 +47,13 @@ steps: - console-setup - locales-all - ifupdown - tag: rootfs + - ssh + tag: / - - ansible: rootfs + - ansible: / playbook: x220.yml - grub: uefi - tag: rootfs + tag: / efi: efi image-dev: "{{ image }}" diff --git a/x220.yml b/x220.yml index abc9685..44875e5 100644 --- a/x220.yml +++ b/x220.yml @@ -1,19 +1,14 @@ # Ansible playbook to install stuff on my Thinkpad X220. -# TODO: -# - maybe install iwlwifi firmware? -# - install liw-openpgp.pub and a gpg config to use my Yubikey - - hosts: image - tasks: - - - name: "set /etc/hostname" - shell: | - echo "{{ hostname }}" > /etc/hostname + roles: + - sane_debian_system + - comfortable-debian-system + - unix_users +# - gnome-system + - intel-wifi - - name: "unset root password" - shell: | - sed -i '/^root:[^:]*:/s//root::/' /etc/passwd + pre_tasks: - name: "configure keyboard layout" copy: @@ -49,4 +44,19 @@ dest: /etc/network/interfaces.d/wired vars: - hostname: exolobe1 + hostname: x220 + + debian_codename: buster + + timezone: Europe/Helsinki + + unix_users: + - username: liw + comment: Lars Wirzenius + sudo: yes + authorized_keys: | + ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDAlECa3tbFGXhB3Zh/4/GhM11THOThVfiuLqqJ2dpWHEClzpKJHpzzwWt7g9z/MMQNMsUJLy+okz+De6hdjjmYJ9kG9Sr3H4YKq6itGQMj7L/cH3WS3ynp0uy0oW3hf932vDZKQ8iy9vczXH+ERYl+4TYae1Jp4Hyf4/2IYxEfuhKctvSvqySST3Qk9JNZ71HFGOWhjH/MmoCLoT1v+HkqmHdYf/GMKGRo3gqCEGgCgNErYYIyKm3OF3dHXK+hyGLE/cZNu6fU5woW3rvtUCFt08Ri2pm0cnXXJn9jQIMxfS5Kkf64svwgzKmPqgX1f4flopYPlsBXduCgzbJvj+lpgauAk/i1A5B01CFa9sI4C6pHZmwk1qxRwN+4IXL2CQt+tDgYC84ZDDd8R7cNyL22a3KhMQmdHtvog1beAa3Ab+J+cafkXXN+Es9f1wQjzk7DiHupmJIVofBvPP+cRcB46rwha6ati8Fa5QkT9rXFNqQsKk7jq8TIi54Bm15OOa0jInGG3TM17b9Ftu2WTJSAaqgBnDfZiInK7HEvC6K/IBljrN3oGagmFZPrAvzw7d6C2/nKFAQtfoMcE5oWVDrJyjsmJ8oaru0E8rwj7mMvyKPgEMnXTGXLWDgEo50+i291m4bkCxVwiOPbPRvdMll1Y8qfBAPT76sY4Ikgcw/2iw== openpgp:0xBBE80E50 + + sources_lists: + - repo: | + deb http://deb.debian.org/debian buster contrib non-free -- cgit v1.2.1