Disk image

Posted on So 16 Mai 2021 in Notebook

Creating

dd if=/dev/zero of=file.img bs=1 count=0 seek=512M

Copy

cp --sparse=always new_file.img recovered_file.img

Growing

dd if=/dev/zero of=file.img bs=1 count=0 seek=1G

This will increase its size to 1 Gb, and leave its information intact.

cryptsetup luksOpen /dev/sda2 crypt-volume
cryptsetup resize crypt-volume
btrfs filesystem resize amount /dev/mapper/crypt-volume

The amount can also be max instead of a specified amount. This will use all remaining free space on the device.

Source: - https://wiki.archlinux.org/title/Sparse_file - https://unix.stackexchange.com/questions/320957/extend-a-luks-encrypted-partition-to-fill-disk - https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/storage_administration_guide/resizing-btrfs