I have a disk with this format:
sdc 8:32 0 1,8T 0 disk └─sdc1 8:33 0 1,8T 0 part ├─vg-lv1 (dm-0) 254:0 0 900G 0 lvm /media/lv1 └─vg-lv2 (dm-1) 254:1 0 923G 0 lvm └─lv2 (dm-9) 254:9 0 923G 0 crypt /media/lv2
lv2 is an ext4 filesystem, but the block device underneath it (the logical volume
vg-lv2) is encrypted with
What are the steps to safely grow this filesystem?
I have already enlarged the logical volume, and I know I will have to
resize2fs, but I'm guessing I will have to do something at the
I first created this filesystem with two steps (in pseudo-shellscript):
Sanitize the block device
$randompassword = $(pwgen)
cryptsetup luksFormat --cipher aes-cbc-essiv:sha256 --key-size 256 /dev/mapper/vg-lv2, with
$randompasswordas the key.
cryptsetup luksOpen /dev/mapper/vg-lv2 sanitize
nice -20 ionice -c 3 dd if=/dev/zero of=/dev/mapper/sanitize bs=1M
cryptsetup remove sanitize
Prepare the block device for production use
- Pick a passphrase
cryptsetup luksFormat --cipher aes-cbc-essiv:sha256 --key-size 256 /dev/mapper/vg-lv2, with the new key.
cryptsetup luksOpen /dev/mapper/vg-lv2 lv2
mke2fs /dev/mapper/vg-lv2(I don't remember the arguments, but there were probably none)
When ready for production use, the unencrypted block device was zeroed (effectively writing pseudo-random data in the encrypted device).
Now, since I want to grow the filesystem, I should also make the first step and sanitize it before use. This is what I don't how to do:
- I can just call the resize functions and I'll eventually use the whole space, but I'm not comfortable with this idea.
- I can shrink the logical volume to the size it was before, create a new one, do those steps in it, then delete it, grow again the LV, and hope that it occupies the space of the previously sanitized logical volume ("hope" is the reason I don't like this approach)
- I have to know, without a doubt, what the offsets on
dd if=/dev/zero of=/dev/mapper/vg-lv2 bs=1M skip=$SKIPBLOCKS. I can not get this
$SKIPBLOCKSvariable wrong, so what I actually need to know is how can I know, given an already-existing filesystem, which is the first empty block after it, so I can randomize that space onwards.