I'm making a backup of Raspbian (I know, this isn't the Raspberry Pi SE, but it's a Linux question and it probably isn't just Raspbian that has this problem and BTW, the size of the drive is 128GB). The first backup is only 68GB after compression. Then, I deleted the first backup. The next backup is over 100GB in size! If I deleted the second backup and do another one, I run out of space when making a backup (since I use
sudo dd if=/dev/mmcblk0 bs=1M | gzip – | dd of=~/Desktop/backup-23-may-2020.gz and since the unused space isn't all zeros, the compression is getting worse)
To my knowledge, deleting a file using
rm just marks that file deleted, instead of zeroing out the file. I want to be able to completely zero out all the deleted files so when I back up the whole disk, the compression is better because all the unused space are zeros.
Will this command do that? (You will need to install
pv (pipe viewer) if you want to try out this command by running
sudo apt install pv)
dd if=/dev/zero | pv -s 100g -S | dd of=~/zeros.txt
EDIT 2: Forgot the
=. Thanks @Hermann.
I don't want to blindly execute this command because I did compile OpenCV on here and I refuse to do that again.
EDIT: According to
df -h I have 102G of memory.
pi@raspberrypi:~$ df -h Filesystem Size Used Avail Use% Mounted on /dev/root 115G 7.9G 102G 8% / devtmpfs 1.6G 0 1.6G 0% /dev tmpfs 1.7G 0 1.7G 0% /dev/shm tmpfs 1.7G 26M 1.7G 2% /run tmpfs 5.0M 4.0K 5.0M 1% /run/lock ...