Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Wipe free space

Featured Replies

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 

Solved by Opawesome

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?

  • Author
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?

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 by TangoEchoAlpha

  • Author
  • Solution

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 by Opawesome
typo

  • Author
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

  • 1 year later...
  • Author
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).

  • 2 months later...
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.

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.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.