Simple, detailed instructions to wipe free space please.
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Simple, detailed instructions to wipe free space please.
Can someone please give me simple detailed instructions on how to wipe the free space on my hard drive. I have a Ubuntu/WXP dual install. It is very easy to do this in Windows as there are several free software tools to do it. Is there anything like this in Ubuntu?
When you say "free space", it could mean space that is not partitioned, or it could mean free space within a filesystem.
The standard tool for wiping a partition or an entire disk is dd. It can also be used to wipe unpartitioned space.
I am not aware of a way to wipe unused space within a file system. There is something called "shred" which works with individual files, but I have never used it.
Could you explain what you are trying to do a little better? I am not sure what you mean by "wipe free space". Do you mean zeroing out unused parts of the disk?
If you delete a file, then there is no longer a connection to it, and something like shred is not going to work. (As far as the filesystem is concerned, the file no longer exists.)
Even if you delete in a GUI, and then restore from the trash, there is no guarantee that the file will be in the same place on the physical drive.
If you have a partition on which you have deleted some files which you now need to shred, I think the best solution **might** be this:
1. Using the filessytem, copy the entire contents to some other partition or disk. (be sure to include hidden files)
2. Wipe the original partition (using something like dd) and re-format it.
3. Copy the contents back
Depending on your partition setup, it could be just as easy to wipe the whole disk and re-install.
I think the easiest way to accomplish what you're trying to do is to write over all the free blocks including data that is still on the drive even there is no link to it. Shred does this at the time the deletion occurs (I belive the default is 25x). To do this for an entire drive, you would use dd to fill the drive with random data, and then re-write over it with 0's.
This will use the urandom device for data and write to a file (overwriting any block that currently dont have "files" linked to them). Then remove the file once the drive is out of space. Then using the zero device to fill it with 0's.
** Be careful with this. Read the manual on dd first. A typo can erase everything on your system. And if you have everything on a single partition this can lead to a system hang as you will have no space left on your device for system processes. **
Last edited by Weird0ne; 05-03-2010 at 02:50 PM.
Reason: Caution
When you say "free space", it could mean space that is not partitioned, or it could mean free space within a filesystem.
The standard tool for wiping a partition or an entire disk is dd. It can also be used to wipe unpartitioned space.
I am not aware of a way to wipe unused space within a file system. There is something called "shred" which works with individual files, but I have never used it.
Wipping free space within filesystem once was easy:
Code:
as root:
dd if=/dev/zero of=/some/none_exist_file_inside_filesystem
and then
rm /some/none_exist_file_inside_filesystem
"As root" needed to fill with zeros 5% of filesystem size reserved for
root usage only
Of course on filesystems with journal it may be not enough
Weird One's should do it. If you want to make sure you don't crash your system, don't run it as root, but if you want to be more certain the data is deleted then be root.
Bear in mind full disks play havoc with some software. Notably, Thunderbird goes badly haywire.
So can I just use the dd command as described by Valery Reznic? And how long will it take? Otherwise it just seems too complicated. I'm not really paranoid.
I do not understand what Valery suggests---it look like he is writing zeros to a file. If the file has already been deleted, then I do not see how it could do anything.
Back to basics:
Within a filesystem you can copy, delete, and remove file using the well-known tools. In this case, deletion and moving do not erase the actual bit patterns---they only break the connections and allow the space to be used for something else.
By contrast, a tool like dd has the ability to operate on the raw device, regardless of whether there is a filesystem. Using dd to wipe the space occupied by a deleted file is certainly possible, but only if you know where the actual data WAS. (Again, I don't see how Valery's method would do this.)
dd, specifically, can read and write using EITHER the raw device name OR a file name (Not surprising, considering the long-standing *n(u|i)x principle that "everything is a file")---So:
to write to /dev/sda2 (a partition), the partition needs to exist
to write to /home/myjunk/filename, the FILE needs to exist
WeirdOne and Valery's method works by creating a new file, filling the entire free space, and that is all zeroes. Thus, the space freed by any previously deleted files will be used by the new file, and hence zeroed out. You then delete the big file full of zeroes to recover your space.
Sorry, I just don't understand how to apply most of what you have said. I am a complete newbie to Linux. All my computer work has been in Windows.
What I want are simple instructions like: Do this, do that, so and so will happen, then do that, etc. until the desired result is achieved. If these cannot be provided I just won't bother and will simply re-install WXP, wipe the free space (which is easy in Windows), abandon Ubuntu and carry on happily using Windows.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.