From 3271a8db0be8e284f9f7a348d922e2baac0b14ee Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Tue, 21 Jan 2014 00:28:40 +0100 Subject: setup-arch-vm: improve to allow fully automatic operation; create a full disk partition Signed-off-by: Florian Pritz --- setup-arch-vm | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'setup-arch-vm') 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 </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 -- cgit v1.2.3-24-g4f1b