Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
nah, I just want to consolidate free space, not defrag. admittedly, those two are somewhat similar.
no need for sarcasm (if i understood some replies well, otherwise sorry).
I use 'dynamic' .vdi and try to keep image size small on ssd. presumably a lot of scattered small files are bad for dynamic-vdi/sparse.
anyway, why I want it shouldn't matter *that* much.
I don't want to copy the whole thing or something like that.
I use 'dynamic' .vdi and try to keep image size small on ssd. presumably a lot of scattered small files are bad for dynamic-vdi/sparse.
It probably doesn't help. However, ext2/3/4 deliberately distribute files across all the block groups in the filesystem. Directories and the files they contain tend to be allocated in the same or nearby block groups, and keeping the free space scattered means there will likely be nearby free space to do that. None of that makes any sense for a dynamic .vdi or SSD, but you will be constantly fighting against the filesystem to do anything else.
Sorry, but I don't know of any filesystem designed to keep free space consolidated in normal operation. And anyway, defragmenting the filesystem visible to the guest OS doesn't have much bearing on how fragmented the virtual disk image might be. It's like defragmenting your virtual address space in a program. The physical memory pages could, and probably will, still be scattered all over the processor's physical address space. Conversely, consecutive physical memory pages could map to scattered virtual addresses.
The initial post contained no relevant information - my reply was to highlight that fact. Had the later info been included in the original post, better answers would have arrived earlier.
This is a virtualbox issue, not a filesystem issue. Dynamic vdi only increases as required - (last I looked) it doesn't automatically shrink as files are deleted. If it did, the performance would be abysmal. And --compact only works if the data has been erased to zeroes on file deletion. ext4 is aware of SSD characteristics and supports trim to advise the hardware about unneeded space.
The issue is still if it is a problem with the file containing the virtual hard drive or the actual use of the virtual hard drive in the VM or the files on the filesystem.
Tar used to be the way to compact files and still works today. This would only help your real filesystem and not the actual growable virtual hard drive.
Boot up into the VM. Install the zerofree package.
Reboot the VM to recovery mode (shift key while booting to get Grub screen; root shell->maintenance).
Run df to determine the root partition. Then run the following commands (assumes root partition at /dev/sda1; replace systemctl poweroff with alternative if required):
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524
Rep:
As syg00 said, the size of the drive in the setup is not the actual size of the drive, because virtual drives are sparse files that grow as you need more capacity, unless you specifically tell the program to reserve all allotted space.
OH, and for defrag--if such a thing ever becomes necessary--I just rsync everything to a different drive and then put it all back.
Last edited by AwesomeMachine; 04-30-2018 at 10:36 PM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.