Contents
How to clear unused space with zeros in Linux?
For btrfs : Clear unused space with zeros (btrfs) Such an utility is zerofree. Zerofree finds the unallocated, non-zeroed blocks in an ext2 or ext3 file-system and fills them with zeroes.
Is there a way to empty a file in Linux?
Occasionally, while dealing with files in Linux terminal, you may want to clear the content of a file without necessarily opening it using any Linux command line editors. How can this be achieved? In this article, we will go through several different ways of emptying file content with the help of some useful commands.
Is there a way to zero space in a file?
Zerofree requires the file-system to be unmounted or mounted read-only. The usual way to achieve the same result (zeroing the unused blocks) is to run “dd” do create a file full of zeroes that takes up the entire free space on the drive, and then delete this file.
How to zero free blocks in ext2 file system?
Description: zero free blocks from ext2, ext3 and ext4 file-systems Zerofree finds the unallocated blocks with non-zero value content in an ext2, ext3 or ext4 file-system and fills them with zeroes… Another application this utility is to compress disk images that are a backup of a real disk.
Which is the fastest way to clear unused space?
Discarding tends to be the fastest method when a lot of previously used space needs to be zeroed but using zerofree after the discard process can sometimes zero a little bit extra (depending on how discard is implemented on the “disk”).
Is it possible to delete all BtrFS snapshots?
You cannot delete snapshots numbers 0 or 1, and you will probably want to keep the most recent snapshot and the most recent important one. So in this example, we can delete snapshot 146: Now check your free space with df -h. Space usage should have decreased. Be open however to the possibility that your space problems lie elsewhere.
How to get rid of unused space on a disk?
If the “disk” your filesystem is on is thin provisioned (e.g. a modern SSD supporting TRIM, a VM file whose format supports sparseness etc.) and your kernel says the block device understands it, you can use e2fsck -E discard src_fs to discard unused space (requires e2fsprogs 1.42.2 or higher).