The following procedure applies to expanding an LVM swap volume only. If you want to expand a LVM root or data volume, see Expanding an LVM Data or Root Volume. If you want to expand a Linux root or data partition that is not managed by LVM, see Expanding a Root Partition and Expanding a Linux Data Partition.
Before You Begin
Make sure you know the name of the LVM swap volume and the KeyControl clear text path to it. If you do not, use the hcl status
command and look at the Registered Devices section. For example:
# hcl status ... Registered Devices -------------------------------------------------------------------------------- Disk Name Cipher Status Clear -------------------------------------------------------------------------------- cl_centos73-swap AES-256 Attached /dev/mapper/clear_htswap (swap) '--> auto_attach=ENABLED, attach_handler=DEFAULT, detach_handler=DEFAULT cl_centos73-root AES-256 Attached /dev/mapper/clear_htroot (/) '--> auto_attach=ENABLED, attach_handler=DEFAULT, detach_handler=DEFAULT
Procedure
root
.Get the UUID of the swap device by using the blkid swap-clear-text-path
command. For example:
# blkid /dev/mapper/clear_htswap
/dev/mapper/clear_htswap: UUID="a949b636-1669-43cb-acc4-b1ed86e7f2f1 TYPE="swap"
Turn the swap off by entering the command swapoff -a
.
# swapoff -av swapoff on /dev/mapper/clear_htswap
Tip: | If the swapoff command does not work, applications are probably using the swap file. You can make a temporary swap space and move the swap there until this procedure is finished. For example: |
# fallocate --length 2GiB /swapfile # mkswap /swapfile # swapon /swapfile
You can also try stopping all main applications and then dropping all caches from memory. For details, see your Linux documentation.
Increase the size the LVM swap volume as desired using the lvresize diskname
command, where diskname
is the name of the swap volume . For example, if you want to increase the swap volume cl_centos73-swap
by 256M, you would enter:
# lvm lvresize /dev/cl_centos73/swap -L +256M Size of logical volume cl_centos73/swap changed from 1.00 GiB (256 extents) to 1.25 GiB (320 extents). Logical volume cl_centos73/swap successfully resized.
Increase the size of the encrypted swap to match the new volume size. How you do this depends on whether Online Encryption is enabled or disabled for the volume.
Tip: | You can always use the Offline Resize Method for swap volumes regardless of whether they use Online Encryption. If you are not sure whether Online Encryption is enabled on the volume, use the Offline Resize Method. |
Select one of the following methods:
Online Resize Method — Usable for swap volumes only if Online Encryption is disabled.
Use the command hcl resize diskname
, where diskname
is the name of the swap volume.
# hcl resize cl_centos73-swap Warning: Resizing active device incorrectly can cause any data stored on them to become inaccessible Do you want to proceed? (y/n) y Device cl_centos73-swap was successfully resized Updating the KC with the size (1310720 KB) of the device Successfully updated the KC with size (1310720 KB) of the device cl_centos73-swap
Offline Resize Method — Usable for all swap volumes. This method is required for swap volumes on which Online Encryption is enabled.
Reboot the VM.
# reboot
Re-create swap on the swap volume using the mkswap -U clear-text-path
command, where clear-text-path
is the clear text path to the swap volume. For example, if the clear text path is /dev/mapper/clear_htswap
, you
would enter:
# mkswap -U "a949b636-1669-43cb-acc4-b1ed86e7f2f1" /dev/mapper/clear_htswap mkswap: /dev/mapper/clear_htswap: warning: wiping old swap signature. Setting up swapspace version 1, size = 1310716 KiB no label, UUID=a949b636-1669-43cb-acc4-b1ed86e7f2f1
Turn the swap back on using the swapon -va
command. For example:
# swapon -va swapon /dev/mapper/clear_htswap swapon: /dev/mapper/clear_htswap: found swap signature: version 1, page-size 4, same byte order swapon: /dev/mapper/clear_htswap: pagesize=4096, swapsize=1342177280, devsize=1342177280 # swapon --show NAME TYPE SIZE USED PRIO /dev/dm-4 partition 1.3G 0B -1