reduce_lxc_size
./resize.sh 139 main 4G
- resize.sh
#!/usr/bin/bash lxcid=$1 lxcvg=$2 newsize=$3 lxcdisk=vm-$lxcid-disk-0 mkdir /mnt/old mount /dev/$lxcvg/$lxcdisk /mnt/old/ lvcreate -T main/lvpool -V $newsize -n $lxcdisk-new mkdir /mnt/new mkfs.ext4 /dev/$lxcvg/$lxcdisk-new mount /dev/$lxcvg/$lxcdisk-new /mnt/new/ cd /mnt/old/ rsync --stats -h -X -A --numeric-ids -aH --delete --no-whole-file --inplace --one-file-system --relative '--exclude=/tmp/?*' '--exclude=/var/tmp/?*' '--exclude=/var/run/?*.pid' * /mnt/new pct stop $lxcid rsync --stats -h -X -A --numeric-ids -aH --delete --no-whole-file --inplace --one-file-system --relative '--exclude=/tmp/?*' '--exclude=/var/tmp/?*' '--exclude=/var/run/?*.pid' * /mnt/new cd .. umount /mnt/old/ /mnt/new/ lvrename main $lxcdisk $lxcdisk-old lvrename main $lxcdisk-new $lxcdisk pct start $lxcid echo lvremove /dev/$lxcvg/$lxcdisk-old
reduce_lxc_size.txt · Dernière modification : 2021/12/05 13:12 de tomamplius