Reduce VM disk size (bhyve)

I'd like to reduce disk size to 10G on bhyve VM.
Is it possible to do it on "live" system and keep untouched data?
Eventually on single user boot.

Code:
=>      34  83886013  vtbd0  GPT  (40G)
        34      1024      1  freebsd-boot  (512K)
      1058  83884958      2  freebsd-ufs  (40G)
  83886016        31         - free -  (16K)
 
Making a disk smaller is usually problematic. It's theoretically possible if there's no data written at the end of the disk but that's difficult to find out.
 
Making a disk smaller is usually problematic. It's theoretically possible if there's no data written at the end of the disk but that's difficult to find out.
Thats the case on FAT or NTFS but not on UFS.
On UFS the inode tables are placed over the whole disk, and the file data are placed near the inode tables. This leads to "stripes" of data over the whole disk, even near the disk end.
Remember there is no shrinkfs command, but growfs.
 
Thanks for answers. I've "shrunk" the disk using a small workaround.

How this is VM so I've used other VM with smaller disk size, copied the whole smaller VM to new one and just copy there important files (/usr/local, /var etc.) using scp.
Step by step.

1. Backup as always.
2. I've used tar() and scp() commands to simply move important files from older and bigger disk.
3. I've copied VM file from the other one with smaller size.
4. I've logged in to the new smaller and destined VM and copy data (tar files) using scp.
5. I've rebooted and logged as single user to check disk consistency using fsck().
6. Rebooted VM again and workaround done.

Everything works fine and it took me about one hour to do this.
 
On UFS the inode tables are placed over the whole disk, and the file data are placed near the inode tables. This leads to "stripes" of data over the whole disk, even near the disk end.
I knew this was problematic but didn't know the exact reason.
 
Back
Top