Reduce (shrink) and resize raw disk at Proxmox

 Reduce (shrink) and resize raw disk at Proxmox

1. Check the status of raw disk:
 
#e2fsck -fy /hdd-img/images/111/vm-111-disk-1.raw
e2fsck 1.46.5 (30-Dec-2021)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/hdd-img/images/111/vm-111-disk-1.raw: 135279/327680000 files (1.8% non-contiguous), 857599886/1310720000 blocks 

2. At first, check raw disk size:
 
#qemu-img info /hdd-img/images/111/vm-111-disk-1.raw
image: /hdd-img/images/111/vm-111-disk-1.raw
file format: raw
virtual size: 4.88 TiB (5368709120000 bytes)
disk size: 3.59 TiB 

3. Resize filesystem:
-M - will resize to the minimum size based on saved files
-p - will display progress bar

#resize2fs -M -p /hdd-img/images/111/vm-111-disk-1.raw
resize2fs 1.46.5 (30-Dec-2021)
Resizing the filesystem on /hdd-img/images/111/vm-111-disk-1.raw to 852166716 (4k) blocks.
Begin pass 2 (max = 196490057)
Relocating blocks             XXXXXXXXX-------------------------------

4. Check the new raw disk size:
#qemu-img info /hdd-img/images/111/vm-111-disk-1.raw
image: /hdd-img/images/111/vm-111-disk-1.raw
file format: raw
virtual size: 2.68 TiB (3687091200000 bytes)
disk size: 2.49 TiB  


 
5. Resize the raw disk:
qemu-img resize -f raw --shrink /hdd-img/images/111/vm-111-disk-1.raw -1.0T
Image resized.

Comments

Popular posts from this blog

How to clean DB from old logs in Magento 1.x

Securing the Pi-hole with fail2ban to prevent DNS Amplification attacks

Apache 2.4 + mod_wsgi + Python 3.7 + Django installation on Centos 7.10