Virtualize disk with minimal space
Jump to navigation
Jump to search
- Clean things up
- Boot from separate media e.g. boot-repair live iso, shrink partition to desired size with gparted
- On other system connect disk, check partition layout with fdisk -l, dd if=source of=file bs=[Units in fdisk] count=[end of last partition +1 to cover last +33 for backup gpt table if gpt] (https://serverfault.com/a/853753 https://forums.raspberrypi.com/viewtopic.php?t=288670#p1745543)
- Boot from separate media with image attached, gparted likely will show unpartitioned
- If GPT disk: use sgdisk -e /dev/disk to recreate backup gpt partition table at end of disk (https://askubuntu.com/a/1370440)
- If wanting to make a sparse qcow2 image:
- Mount image, fill empty space with zeroes with dd if=/dev/zero of=tmpfile, rm tmpfile
- qemu-img convert -f raw -O qcow2 -S 4k [source] [dest]