Skip to content

Instantly share code, notes, and snippets.

@delfer
Created May 18, 2018 18:20
Show Gist options
  • Select an option

  • Save delfer/362d70217a415dda6e0a48968628722c to your computer and use it in GitHub Desktop.

Select an option

Save delfer/362d70217a415dda6e0a48968628722c to your computer and use it in GitHub Desktop.
#host
docker run -ti --rm --privileged -v /dev:/dev -v $(pwd):/ws base/archlinux bash
#in C
cd /ws/
dd if=/dev/zero of=disk.img bs=1024k seek=4096 count=0
echo 'start=2048, type=83' | sfdisk disk.img
DISK=$(losetup -f --show -P disk.img)
DEVICE=${DISK}p1
mkfs.ext4 $DEVICE
mkdir /target
mount $DEVICE /target
pacstrap /target base intel-ucode grub terminus-font kbd
UUID=$(blkid -o value $DEVICE | head -1)
echo -e "UUID=$UUID\t/\text4\trw,relatime,data=ordered\t0\t1\n" >> /target/etc/fstab
arch-chroot /target
#in chroot
grub-mkconfig -o /boot/grub/grub.cfg
DEVICE=$(findmnt -n -o source /)
DSK=$(lsblk -no pkname $DEVICE)
DISK=/dev/${DSK}
grub-install $DISK
#echo "osimg.ru" | passwd --stdin
exit
#in C
dd if=/dev/zero of=/target/zroes bs=1M || rm -f /target/zroes
sync
umount /target
losetup -d $DISK
exit
#host
pacmap -S qemu
qemu-img convert -O vmdk disk.img disk.vmdk
xz -e9 -T0 disk.vmdk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment