FAQ » VPS
How to manually Resizing a Virtuozzo Container Image
Resizing a Virtuozzo container image may sometimes require manual intervention, especially if built-in tools like vzctl compact
or ploop compact
are not effectively reducing the size. This guide outlines the steps for manually resizing a Virtuozzo container image.
Warning: This process involves advanced operations, and it is essential to perform a backup before making any changes to avoid potential data loss.
Prerequisites
Access to Virtuozzo Server: Ensure you have access to the Virtuozzo server where the container is hosted.
Container ID (
$CTID
): Identify the ID of the Virtuozzo container you want to resize.
Steps to Manually Resize a Virtuozzo Container Image
1. Stop the Container
Stop the Virtuozzo container to ensure no active processes are accessing the container image.
vzctl stop $CTID
2. Backup Your Data
Create a backup of the container data to prevent data loss during the resizing process.
3. Create a New Ploop Image
Use the ploop init
command to create a new ploop image with the desired size.
ploop init -s <new_size> /vz/private/$CTID/new-root.hdd
Replace <new_size>
with the desired size for the new ploop image.
4. Mount the New Ploop Image
Mount the new ploop image to a temporary directory.
mkdir /mnt/new-root
ploop mount /vz/private/$CTID/new-root.hdd/DiskDescriptor.xml -m /mnt/new-root
5. Copy Data from Old to New Image
Use rsync
to copy the data from the old ploop image to the new one.
rsync -avz /vz/root/$CTID/ /mnt/new-root/
6. Unmount the New Ploop Image
Unmount the new ploop image.
ploop umount -m /mnt/new-root
7. Update Container Configuration
Update the container configuration to use the new ploop image. Edit the configuration file (usually located at /etc/vz/conf/$CTID.conf
) and update the DISK
parameter to point to the new ploop image.
8. Start the Container
Start the container with the new ploop image.
vzctl start $CTID
9. Verify Filesystem Size Inside the Container
Log into the container and verify that the filesystem size matches the desired size.
df -h
10. Remove Old Ploop Image (Optional)
If everything is working correctly with the new ploop image, you can choose to remove the old ploop image to free up disk space.
rm -rf /vz/private/$CTID/root.hdd
Feel free to customize the article as needed and incorporate additional details based on your specific use case or audience.
Last updated: 2023-12-01