I have an LXC container with 50G (cloned from other LXC) that doesn't need that much, so I would like to reduce it to 25G. Data is not critical, so I think it's reasonable to try and learn. I did a google search and AI assistant provided me with these steps. Before I try anything I would like to make sure if this is the right approach and if there are any blind spots.
Stop the container:
Find the logical volume path using the following command:
Run a Filesystem Check: Before resizing, check the filesystem for errors:
Shrink the Filesystem: Enter the container and shrink the filesystem to the desired size (e.g., 25G):
Shrink the Logical Volume: Use the following command to reduce the logical volume size:
Update the container's configuration file to reflect the new disk size:
Start the cointainer:
Can anybody confirm these steps will not break anything?
Bash:
export CTID=114
Stop the container:
Bash:
pct stop ${CTID}
Find the logical volume path using the following command:
Bash:
lvdisplay | grep "LV Path\|LV Size"
Run a Filesystem Check: Before resizing, check the filesystem for errors:
Bash:
e2fsck -fy /dev/pve/vm-${CTID}-disk-0
Shrink the Filesystem: Enter the container and shrink the filesystem to the desired size (e.g., 25G):
Bash:
resize2fs /dev/pve/vm-${CTID}-disk-0 25G
Shrink the Logical Volume: Use the following command to reduce the logical volume size:
Bash:
lvreduce -L 25G /dev/pve/vm-${CTID}-disk-0
Update the container's configuration file to reflect the new disk size:
Bash:
sed -i 's|50G|25G|g' /etc/pve/lxc/${CTID}.conf
Start the cointainer:
Bash:
pct start ${CTID}
Can anybody confirm these steps will not break anything?