consolidate free space on ext4
I need to consolidate free space on ext4.
thanks. |
Shouldn't be too hard.
|
You might look at e4defrag, but for the most part EXT4 avoids fragmentation rather well until you start to run out of space.
What problem are you trying to solve? |
Most binary "newbie" distros setup the system in a bad way.
you may look into Quote:
I'd also helps when you would rephrase waht you want to do in the first place. |
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. thanks. |
Quote:
|
thank you.
in that case could you please recommend a better filesystem for / (xubuntu64 guest) ? |
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 thing is, .vdi is about 5Gb, and 'du' says there's 4Gb of data. I've already used 'tune2fs -m 0'
can't figure out where the missing space is. |
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. |
thanks for the lesson. yes, I've already used /dev/zero and --compact.
|
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): Code:
mount -n -o remount,ro -t ext4 /dev/sda1 / Code:
vboxmanage modifyhd UUID --compact |
well, I just did all that, no change.
in past, I used the old: 'cat /dev/zero >zero.tmp; sync; rm zero...' however, zerofree output this (presumably) summary: 62646/4025006/5242368 seems that 4025006 is used space and 5242368 is occupied space. thanks all. |
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. |
All times are GMT -5. The time now is 07:48 AM. |