Opawesome Posted June 10, 2021 Share Posted June 10, 2021 Hi all, I would like to wipe the free space on my array (not the actual files). Is the command is this post (dd if=/dev/random >/dev/disk??/big_file) still the best way to do so or is there a newer/better way? I understand that running this command creates a full-disk error condition and therefore a risk of cascading failures. Best, OP Quote Link to comment
TangoEchoAlpha Posted June 10, 2021 Share Posted June 10, 2021 I don't know if either will be viewed as a 'full disk' but how about nwipe (kinda replacement for the old Darik's Boot And Nuke DBAN) or shred? Quote Link to comment
Opawesome Posted June 10, 2021 Author Share Posted June 10, 2021 7 minutes ago, TangoEchoAlpha said: I don't know if either will be viewed as a 'full disk' but how about nwipe (kinda replacement for the old Darik's Boot And Nuke DBAN) or shred? Can any of those be used to wipe free space and not files or entire disk? Quote Link to comment
TangoEchoAlpha Posted June 10, 2021 Share Posted June 10, 2021 (edited) 7 minutes ago, Opawesome said: Can any of those be used to wipe free space and not files or entire disk? Ah, sorry. Yes, I think they will wipe the entire disk. The only tool I have ever used to wipe free space is on Windows, a free tool called file shredder - https://www.fileshredder.org/ Actually, shred can delete individual files. Check out the -u option: Quote Delete FILE(s) if --remove (-u) is specified. The default is not to remove the files because it is common to operate on device files like /dev/hda, and those files usually should not be removed. When operating on regular files, most people use the --remove option. Edited June 10, 2021 by TangoEchoAlpha Quote Link to comment
Solution Opawesome Posted June 10, 2021 Author Solution Share Posted June 10, 2021 (edited) It turns out this little script seems to do the job: #!/bin/bash DISKNUMBER="1" # Set the disk number which free space should be wiped dd if=/dev/zero of=/mnt/disk"$DISKNUMBER"/zero.small.file bs=1024 count=102400 cat /dev/zero > /mnt/disk"$DISKNUMBER"/zero.large.file sync ; sleep 5 ; sync rm /mnt/disk"$DISKNUMBER"/zero.small.file rm /mnt/disk"$DISKNUMBER"/zero.large.file unset DISKNUMBER I have just tested it in a screen session. The disk filled up as expected and then the "zero.small.file" and "zero.large.file" were deleted to free up the space back. The point of having a small file is to avoid keeping the disk completely filled too long, as it can take time to delete the large file. I hope this helps. Any improvement or remark is obviously more than welcome. OP Edited March 23, 2022 by Opawesome typo 3 Quote Link to comment
Opawesome Posted June 10, 2021 Author Share Posted June 10, 2021 2 hours ago, TangoEchoAlpha said: Actually, shred can delete individual files. Check out the -u option: Well, as stated, I don't want to delete any file, I want to wipe the free space. So shred is not a solution. But thank you anyway. Op Quote Link to comment
Opawesome Posted April 17, 2023 Author Share Posted April 17, 2023 On 4/12/2023 at 4:14 AM, shiftylilbastrd said: Does it just write zeros to all the free space or does it randomize the written data? Yes, zeros. You could replace "/dev/zero" with "/dev/random" to have randomised data (subject to the warning bellow). This link can help you decide which one to pick: https://stackoverflow.com/questions/11499409/dev-zero-or-dev-random-what-is-more-secure-and-why On 4/12/2023 at 4:14 AM, shiftylilbastrd said: Is there a way to add a run "X" number of times to be able to get a more secure wipe of the disk? I guess the safer way for you might just be run the script "X" number of times. Playing with the "dd" command while not being comfortable with the CLI can result in loosing all your data (I am not kidding). Quote Link to comment
sunwind Posted July 6, 2023 Share Posted July 6, 2023 On 6/27/2023 at 9:45 AM, jasonjulius1122 said: While using the command "dd if=/dev/random >/dev/disk??/big_file" can be an effective way to wipe the free space on your array, there are newer and potentially better methods available. One alternative approach is to use tools specifically designed for secure file deletion, such as "shred" or "sfill," which provide more control and options for securely wiping free space. These tools offer enhanced security and reduce the risk of encountering cascading failures associated with the full-disk error condition caused by the mentioned command. Are those unraid tools though? I don't wanna pull disks from my server and all that. Will that script be fine to use? (how do you actually use it heh) thanks. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.