summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--setup-arch-vm24
1 files changed, 17 insertions, 7 deletions
diff --git a/setup-arch-vm b/setup-arch-vm
index eb8d949..0c0a275 100644
--- a/setup-arch-vm
+++ b/setup-arch-vm
@@ -3,9 +3,21 @@
set -e
newuser="flo"
+disk=/dev/vda
-mkfs.ext4 /dev/vda
-mount /dev/vda /mnt
+die() {
+ echo "$@"
+ exit 1
+}
+
+grep -qE '^flags\s+: .* hypervisor( |$)' /proc/cpuinfo || die "Not running in hypervisor. aborting automatic setup"
+
+dhcpcd eth0
+
+parted -s -- $disk mklabel msdos mkpart primary 1 -0
+
+mkfs.ext4 ${disk}1
+mount ${disk}1 /mnt
cat <<EOF >/etc/pacman.d/mirrorlist
Server = http://mirror.server-speed.net/\$repo/os/\$arch
EOF
@@ -32,7 +44,7 @@ TIMEOUT 50
LABEL arch
MENU LABEL Arch Linux
LINUX ../vmlinuz-linux
- APPEND root=/dev/vda ro logo.nologo elevator=deadline console=tty0 console=ttyS0
+ APPEND root=${disk}1 ro logo.nologo elevator=deadline console=tty0 console=ttyS0 nomodeset
INITRD ../initramfs-linux.img
EOF
@@ -41,9 +53,7 @@ blacklist cirrus
EOF
arch-chroot /mnt mkinitcpio -p linux
-# expected error: /dev/vda - is a block device. Aborting set_active!
-# TODO: create partitions and remove the || true
-arch-chroot /mnt syslinux-install_update -aim || true
+arch-chroot /mnt syslinux-install_update -aim
arch-chroot /mnt useradd -m -g users -G wheel $newuser
mkdir /mnt/root/.ssh
touch /mnt/root/.ssh/authorized_keys
@@ -63,4 +73,4 @@ arch-chroot /mnt passwd -d $newuser
arch-chroot /mnt systemctl enable sshd multi-user.target haveged dhcpcd.service
sync
-systemctl poweroff
+systemctl reboot