Sample Header Ad - 728x90

deleting data in a domU-mounted image does not reduce the image size

1 vote
1 answer
62 views
I have difficulties understanding the following situation: Dom0 image:
[root@Dom0]# du -h 19.12.0.0_dbhome_1.img
980M    19.12.0.0_dbhome_1.img
is mounted on DomU:
[root@DomU]# df -h /u01/app/oracle/product/19.12.0.0/dbhome_1
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvde        50G   62M   47G   1% /u01/app/oracle/product/19.12.0.0/dbhome_1
When I write data to /u01/app/oracle/product/19.12.0.0/dbhome_1 the disk usage on DomU and Dom0 increases accordingly:
[root@DomU dbhome_1]# dd if=/dev/zero of=./test.img bs=4k iflag=fullblock,count_bytes > /dev/null
[root@DomU dbhome_1]# df -h /u01/app/oracle/product/19.12.0.0/dbhome_1
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvde        50G   21G   27G  44% /u01/app/oracle/product/19.12.0.0/dbhome_1
[root@Dom0]# du -h 19.12.0.0_dbhome_1.img
21G     19.12.0.0_dbhome_1.img
When I remove the data the diskusage of DomU is being reduced, but Dom0 stays the same:
[root@DomU dbhome_1]# rm test.img
[root@DomU dbhome_1]# df -h /u01/app/oracle/product/19.12.0.0/dbhome_1
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvde        50G   62M   47G   1% /u01/app/oracle/product/19.12.0.0/dbhome_1
[root@Dom0]# du -h 19.12.0.0_dbhome_1.img
21G     19.12.0.0_dbhome_1.img

How does the difference come about?

I did the following procedure to create and mount the image:
[root@Dom0]# qemu-img create 19.12.0.0_dbhome_1.img.img 50G &>/dev/null
[root@Dom0]# xm block-attach domU file:19.12.0.0_dbhome_1.img /dev/xvde w >/dev/null 2>&1
[root@Dom0]# ln -s 19.12.0.0_dbhome_1.img.img /path/to/link/19.12.0.0_dbhome_1.img
[root@Dom0]# vi vm.cfg (added link to disks[] parameter)
[root@DomU]# parted /dev/xvde mklabel gpt &>/dev/null
[root@DomU]# parted -s /dev/xvde mkpart primary 0 100% &>/dev/null
[root@DomU]# parted -s /dev/xvde set 1 lvm on &>/dev/null
[root@DomU]# echo "/dev/xvde /u01/app/oracle/product/19.12.0.0/dbhome_1 ext4 defaults 1 1\" >> /etc/fstab
[root@DomU]# mkfs.ext4 /dev/xvde &>/dev/null
[root@DomU]# mount -a &>/dev/null
Asked by Jan (75 rep)
May 31, 2022, 09:18 AM
Last activity: May 31, 2022, 11:06 AM