LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 05-03-2010, 01:19 PM   #1
PeterJD
LQ Newbie
 
Registered: Dec 2009
Posts: 8

Rep: Reputation: 0
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?

Best, PeterJD
 
Old 05-03-2010, 01:24 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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.
 
1 members found this post helpful.
Old 05-03-2010, 01:24 PM   #3
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
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?
 
Old 05-03-2010, 01:39 PM   #4
PeterJD
LQ Newbie
 
Registered: Dec 2009
Posts: 8

Original Poster
Rep: Reputation: 0
Thank you. What I am interested in wiping is files which I have "deleted" and browser history which I have "deleted".

PeterD
 
Old 05-03-2010, 01:46 PM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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.

I'm out of ideas --for now, at least
 
Old 05-03-2010, 01:54 PM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
This is strictly a hunch....not advice

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.
 
Old 05-03-2010, 02:46 PM   #7
Weird0ne
LQ Newbie
 
Registered: Nov 2009
Distribution: Slackware / Arch
Posts: 10

Rep: Reputation: 2
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.

ex.
dd if=/dev/urandom of=blank.img
rm blank.img
dd if=/dev/zero of=blank.img
rm blank.img

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
 
1 members found this post helpful.
Old 05-03-2010, 03:18 PM   #8
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,982

Rep: Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625
I think WeirdOne has it.
 
Old 05-04-2010, 12:01 AM   #9
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by pixellany View Post
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
 
1 members found this post helpful.
Old 05-04-2010, 08:36 AM   #10
cantab
Member
 
Registered: Oct 2009
Location: England
Distribution: Kubuntu, Ubuntu, Debian, Proxmox.
Posts: 553

Rep: Reputation: 115Reputation: 115
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.
 
Old 05-04-2010, 01:43 PM   #11
PeterJD
LQ Newbie
 
Registered: Dec 2009
Posts: 8

Original Poster
Rep: Reputation: 0
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.

PeterJD
 
Old 05-04-2010, 01:54 PM   #12
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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
 
Old 05-04-2010, 01:57 PM   #13
cantab
Member
 
Registered: Oct 2009
Location: England
Distribution: Kubuntu, Ubuntu, Debian, Proxmox.
Posts: 553

Rep: Reputation: 115Reputation: 115
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.

And dd can create a file that does not exist.
 
Old 05-05-2010, 06:57 AM   #14
PeterJD
LQ Newbie
 
Registered: Dec 2009
Posts: 8

Original Poster
Rep: Reputation: 0
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.

PeterJD
 
Old 05-05-2010, 07:04 AM   #15
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
I just don't understand what you want to do.

Quote:
Originally Posted by PeterJD View Post
Thank you. What I am interested in wiping is files which I have "deleted" and browser history which I have "deleted".

PeterD
So you want to empty your trash so it doesn't take up space?

Or do you mean you want to actually wipe the bit patterns off your drive for privacy's sake?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
A faster way to wipe free space? taylorkh Linux - Software 13 04-19-2009 10:21 AM
Need Detailed Instructions On How To Customise Fbpanel Mark7 Linux - Desktop 0 02-06-2008 01:49 PM
detailed instructions for getting HPg85xi to work through USB lazarys Linux - Newbie 5 05-05-2006 03:03 PM
Complete Linux Newbie, Need Detailed Instructions For Problems srparke Linspire/Freespire 8 03-19-2005 01:08 AM
wipe free space with Linux? bigrobot Linux - Software 2 02-19-2005 04:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration