Skip to content

Instantly share code, notes, and snippets.

@vrdhn
Created December 25, 2022 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vrdhn/7c27ad3fa3be7ac422fc67e97ca3e4de to your computer and use it in GitHub Desktop.
Save vrdhn/7c27ad3fa3be7ac422fc67e97ca3e4de to your computer and use it in GitHub Desktop.
qemu-img create -f qcow2 arch-root.qcow2 64G
sudo modprobe nbd
sudo qemu-nbd -c /dev/nbd0 arch-root.qcow2
sudo cfdisk -z /dev/nbd0
# make dos partition table
# make a new partition, make it bootable
sudo mkfs.ext4 /dev/nbd0p1
sudo mount /dev/nbd0p1 /mnt/
sudo pacstrap -c /mnt base linux-lts curl openssh dhcpcd grub vim
sudo arch-chroot /mnt
## edit /etc/mkinitcpio.conf
MODULES=(virtio_pci virtio_blk virtio_net virtio_scsi virtio_console )
#
mkinitcpio -P
systemctl enable dhcpcd
systemctl enable sshd
mkdir -p -m 700 ~/.ssh
curl -o ~/.ssh/authorized_keys https://github.com/vrdhn.keys
## just in case ...
passwd
grub-install --target=i386-pc /dev/nbd0
grub-mkconfig -o /boot/grub/grub.cfg
pacman -Scc
exit
sudo lsof | grep /mnt
sudo umount /mnt
sudo qemu-nbd -d /dev/nbd0
sudo rmmod nbd
qemu-img convert -c -O qcow2 arch-root.qcow2 arch-root-small.qcow2
## Run using virt-manager or virsh
virsh -c qemu:///system list
virsh -c qemu:///system domifaddr --full --domain <id from above, 1,2 etc>
## get the IP
ssh root@192.168.122.249
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment