Disk image

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

Recover Btrfs Partition

Let’s assume that you don’t have a physical device failure (which is a different set of tools – mount -odegraded, btrfs dev del missing). First thing to do is to take a btrfs-image -c9 -t4 of the filesystem, and keep a copy of the output to show josef. :) Then start with -orecovery and -oro,recovery for pretty much anything. If those fail, then look in dmesg for errors relating to the log tree – if that’s corrupt and can’t be read (or causes a crash), use btrfs-zero-log....

LVM

shrink lvm # Unmount the filesystem and check its' LV umount /mnt/foo e2fsck -f /dev/mapper/vg0-foo # Shrink ext4 and then the LV to the desired size resize2fs -p /dev/mapper/vg0-foo 40G lvreduce -L 40G /dev/mapper/vg0-foo # Before continuing, run e2fsck. If it bails because the partition # is too small, don't panic! The LV can still be extended with # lvextend until e2fsck succeeds, e.g.: # lvextend -L +1G /dev/mapper/vg0-foo e2fsck -f /dev/mapper/vg0-foo # Resize the filesystem to match the LVs size, check and mount it resize2fs -p /dev/mapper/vg0-foo e2fsck -f /dev/mapper/vg0-foo mount /mnt/foo expand lvm umount /mnt/bar # Extend the LV to use all free space lvextend -l +100%FREE /dev/mapper/vg0-bar e2fsck -f /dev/mapper/vg0-bar # Resize the partition to fill the LV resize2fs -p /dev/mapper/vg0-bar e2fsck -f /dev/mapper/vg0-bar mount /mnt/bar expand luks encrypted filesystems umount /crypto e2fsck -f /dev/mapper/crypto cryptsetup luksClose crypto lvextend -L +100M /dev/cryptovg/crypto cryptsetup luksOpen /dev/cryptovg/crypto crypto cryptsetup -v resize crypto e2fsck -f /dev/mapper/crypto resize2fs /dev/mapper/crypto e2fsck -f /dev/mapper/crypto mount /dev/mapper/crypto /crypto Snapshot Taking A Snapshot...