Resize encrypted disk

Automatic

There is a script available on the bacula directors named « resize_luks » that is in the PATH. You need to specify the VG you want to increase so that it can find the right partitions

For example if you want to increase the partition /opt/dedupRepl/containers its VG is containersRepl

  1. Run sudo vgs :

    $ sudo vgs
     VG             #PV #LV #SN Attr   VSize    VFree
     cl               2   4   0 wz--n-   53.49g    0
     cl_data          1   1   0 wz--n-  <90.00g    0
     containers       1   1   0 wz--n-  <38.00t    0
     containersRepl   1   1   0 wz--n-  <20.00t    0
     index            1   1   0 wz--n- <100.00g    0
     indexRepl        1   1   0 wz--n- <100.00g    0
     volumes          1   1   0 wz--n- <370.00g    0
     volumesRepl      1   1   0 wz--n- <400.00g    0
  2. Run resize_luks:

    sudo resize_luks containersRepl
  3. IF disk was full, restart service:

    sudo systemctl restart bacula-sd@9103.service

Manual

We use LUKS on LVM for our encrypted Disks.

First you will need to increase the Disk size in VMWare Vcenter.

Then to resize the disk you will need to have two information:

  1. The disk letter
  2. The crypt device UUID
  3. The VG name

To get the disk letter and the crypt device UUID, you can use « lsblk » command:

[jte@p1baculadirector1a ~]$ lsblk
NAME                                           MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
...
sdf                                              8:80   0    40G  0 disk 
└─index-data                                   253:6    0    40G  0 lvm  
  └─crypt-0815986c-39c2-4cfa-9c2f-935b4ee30255 253:9    0    40G  0 crypt /opt/dedup/index
...

In the example the disk letter is f, the device UUID is 0815986c-39c2-4cfa-9c2f-935b4ee30255 and the VG name is index

Then run the following script with your values:

echo 1 > /sys/block/sd<DISK_LETTER>/device/rescan
pvresize /dev/sd<DISK_LETTER>
lvextend -l+100%FREE /dev/<VG_NAME>/data
cryptsetup resize /dev/mapper/crypt-<UUID> -v
xfs_growfs /dev/mapper/crypt-<UUID>

Add new disk to existing partition

We use LUKS on LVM for our Bacula setup. This lets us span our encrypted FS over multiple logical disks.

First add a new disk to your Bacula instance and make it appear in lsblk:

for host in /sys/class/scsi_host/*; do echo "- - -" | sudo tee $host/scan; ls /dev/sd* ; done

Then use the following steps (e.g. for /dev/sde)

sudo pvcreate /dev/sde

Then expand the correct volume group

sudo vgextend containers /dev/sde

Then expand the data logical volume of this group

sudo lvextend -l+100%FREE /dev/containers/data

We should now see that the underlying disk has expanded but the LUKS volume has not. We will refresh it

sudo cryptsetup resize /dev/mapper/crypt-XXX -v

Finally we need to grow the filesystem

sudo xfs_growfs /dev/mapper/crypt-XXX