Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Wipe free spaces of a partition.

If none of the specific sub-forums seem right for your thread, ask here.
Message
Author
hack3rcon
Posts: 746
Joined: 2015-02-16 09:54
Has thanked: 48 times

Wipe free spaces of a partition.

#1 Post by hack3rcon »

Hello,
How can I wipe the free spaces of a partition and not whole of it? Any tool exist?

Thank you.

User avatar
dilberts_left_nut
Administrator
Administrator
Posts: 5346
Joined: 2009-10-05 07:54
Location: enzed
Has thanked: 13 times
Been thanked: 66 times

Re: Wipe free spaces of a partition.

#2 Post by dilberts_left_nut »

Code: Select all

dd if=/dev/zero of=/mountpoint/file; rm /mountpoint/file
AdrianTM wrote:There's no hacker in my grandma...

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Wipe free spaces of a partition.

#3 Post by p.H »

hack3rcon wrote:How can I wipe the free spaces of a partition and not whole of it?
It depends on the partition contents type (filesystem, LVM...).

hack3rcon
Posts: 746
Joined: 2015-02-16 09:54
Has thanked: 48 times

Re: Wipe free spaces of a partition.

#4 Post by hack3rcon »

I guess it just fill the free spaces with a file and then remove it. It may cause some problems.

User avatar
Ardouos
Posts: 1077
Joined: 2013-11-03 00:30
Location: Elicoor II
Has thanked: 1 time
Been thanked: 4 times

Re: Wipe free spaces of a partition.

#5 Post by Ardouos »

dilberts_left_nut wrote:

Code: Select all

dd if=/dev/zero of=/mountpoint/file; rm /mountpoint/file
This is the most effective solution, just ensure that you have the correct names and locations (and backup your data beforehand).
There is only one Debian | Do not break Debian | Stability and Debian | Backports

⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Wipe free spaces of a partition.

#6 Post by p.H »

hack3rcon wrote:I guess it just fill the free spaces with a file and then remove it. It may cause some problems.
Yes and yes.
What is your actual goal ?

hack3rcon
Posts: 746
Joined: 2015-02-16 09:54
Has thanked: 48 times

Re: Wipe free spaces of a partition.

#7 Post by hack3rcon »

p.H wrote:
hack3rcon wrote:I guess it just fill the free spaces with a file and then remove it. It may cause some problems.
Yes and yes.
What is your actual goal ?
I like to make free spaces unrecoverable.

User avatar
GarryRicketson
Posts: 5644
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Wipe free spaces of a partition.

#8 Post by GarryRicketson »

With all due respect, did the OP do any kind of search on this before asking ?
I was going to answer , back before the first reply was made, my answer was the same, but worded different, and did not include the example,
dilberts_left_nut wrote:

Code: Select all

dd if=/dev/zero of=/mountpoint/file; rm /mountpoint/file
No special tools, etc needed, the dd command is all one needs, and is very effective, it comes with almost any normal Linux or Debian default installation, ...since it is a relatively
simple , common sort of task, and the dd command is available in any linux distro, I figured for some reason this is not good enough for the OP. So, I did some searches, used the key words,:

Code: Select all

Toolls to wipe free spaces of a partition on a Debian system
To my surprise there are a few so called "tools", or aps also available, but also, since it was so easy to find them, but I have no first hand experience with any of them, only the dd command, which also was in the results, and with some various examples.
Well, when I came back, I saw that a good answer was posted, To use the 'dd' command,
I kind of figured that should solve or answer the question.
Guess I was wrong, but the OP should tell us which of the other tools they have tried and why the 'dd' is not good enough, this way we will know which utilities/tools they tried, and then , if there is one in the results that they did not yet try, I will be happy to share a link to it, however we really need to know which ones have been tried or at least looked at.
Each tool has it's own manual and tutorials, but if we know which tool or utility the OP decides to use, maybe then some one can give more details on using it, if the OP does not understand the guides available. The dd command also has a manual 'man dd', but there is more detailed tutorials available, I agree the Linux manual, that comes with dd command is not very complete, ....

User avatar
dilberts_left_nut
Administrator
Administrator
Posts: 5346
Joined: 2009-10-05 07:54
Location: enzed
Has thanked: 13 times
Been thanked: 66 times

Re: Wipe free spaces of a partition.

#9 Post by dilberts_left_nut »

To be fair, man dd describes exactly the usage syntax and options of the dd tool.
It's application in a greater task is beyond the scope of a man page and there are numerous documented procedures on the net utilising it in various ways.

You wouldn't expect the instructions for a hammer to describe how to build a house would you?
AdrianTM wrote:There's no hacker in my grandma...

hack3rcon
Posts: 746
Joined: 2015-02-16 09:54
Has thanked: 48 times

Re: Wipe free spaces of a partition.

#10 Post by hack3rcon »

GarryRicketson wrote:With all due respect, did the OP do any kind of search on this before asking ?
I was going to answer , back before the first reply was made, my answer was the same, but worded different, and did not include the example,
dilberts_left_nut wrote:

Code: Select all

dd if=/dev/zero of=/mountpoint/file; rm /mountpoint/file
No special tools, etc needed, the dd command is all one needs, and is very effective, it comes with almost any normal Linux or Debian default installation, ...since it is a relatively
simple , common sort of task, and the dd command is available in any linux distro, I figured for some reason this is not good enough for the OP. So, I did some searches, used the key words,:

Code: Select all

Toolls to wipe free spaces of a partition on a Debian system
To my surprise there are a few so called "tools", or aps also available, but also, since it was so easy to find them, but I have no first hand experience with any of them, only the dd command, which also was in the results, and with some various examples.
Well, when I came back, I saw that a good answer was posted, To use the 'dd' command,
I kind of figured that should solve or answer the question.
Guess I was wrong, but the OP should tell us which of the other tools they have tried and why the 'dd' is not good enough, this way we will know which utilities/tools they tried, and then , if there is one in the results that they did not yet try, I will be happy to share a link to it, however we really need to know which ones have been tried or at least looked at.
Each tool has it's own manual and tutorials, but if we know which tool or utility the OP decides to use, maybe then some one can give more details on using it, if the OP does not understand the guides available. The dd command also has a manual 'man dd', but there is more detailed tutorials available, I agree the Linux manual, that comes with dd command is not very complete, ....
I found some tools like "Scrub" but it wipe whole partition. Are you sure "dd" command is unrecoverable? Some tools like "Scrub" have special methods for wipe a partition. I found https://linoxide.com/linux-command/comm ... isk-linux/.

hack3rcon
Posts: 746
Joined: 2015-02-16 09:54
Has thanked: 48 times

Re: Wipe free spaces of a partition.

#11 Post by hack3rcon »

dilberts_left_nut wrote:To be fair, man dd describes exactly the usage syntax and options of the dd tool.
It's application in a greater task is beyond the scope of a man page and there are numerous documented procedures on the net utilising it in various ways.

You wouldn't expect the instructions for a hammer to describe how to build a house would you?
If you run "dd" on a server then it causes some performance problem.

User avatar
dilberts_left_nut
Administrator
Administrator
Posts: 5346
Joined: 2009-10-05 07:54
Location: enzed
Has thanked: 13 times
Been thanked: 66 times

Re: Wipe free spaces of a partition.

#12 Post by dilberts_left_nut »

What performance problem?
AdrianTM wrote:There's no hacker in my grandma...

hack3rcon
Posts: 746
Joined: 2015-02-16 09:54
Has thanked: 48 times

Re: Wipe free spaces of a partition.

#13 Post by hack3rcon »

dilberts_left_nut wrote:What performance problem?
System become slow.
This command just fill free spaces? For example, if I run it for "/home" then my files in "home" directory will be safe?

User avatar
dilberts_left_nut
Administrator
Administrator
Posts: 5346
Joined: 2009-10-05 07:54
Location: enzed
Has thanked: 13 times
Been thanked: 66 times

Re: Wipe free spaces of a partition.

#14 Post by dilberts_left_nut »

hack3rcon wrote:System become slow.
Well, of course. Continuously writing zeros as fast as it can is an I/O intensive process.
This command just fill free spaces? For example, if I run it for "/home" then my files in "home" directory will be safe?
Yes.
AdrianTM wrote:There's no hacker in my grandma...

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Wipe free spaces of a partition.

#15 Post by p.H »

hack3rcon wrote:make free spaces unrecoverable
You are just paraphrasing. What do you really mean ?

hack3rcon
Posts: 746
Joined: 2015-02-16 09:54
Has thanked: 48 times

Re: Wipe free spaces of a partition.

#16 Post by hack3rcon »

dilberts_left_nut wrote:
hack3rcon wrote:System become slow.
Well, of course. Continuously writing zeros as fast as it can is an I/O intensive process.
This command just fill free spaces? For example, if I run it for "/home" then my files in "home" directory will be safe?
Yes.
Thank you.

User avatar
GarryRicketson
Posts: 5644
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Wipe free spaces of a partition.

#17 Post by GarryRicketson »

Is the "dd" command is unrecoverable?
Most say :https://security.stackexchange.com/ques ... e-on-linux
It depends what level of "unrecoverable" you are going for. ... your data from a live-boot OS, then things like shred , dd ---snip---
In a nut shell, it would also depend on who was trying to recover it and what technology or tools they have.
from: https://www.marksanborn.net/howto/wipin ... e-with-dd/
So, in order to make deleted data unrecoverable we must write over it.
Wiping the Drive

Using dd to write over your entire drive with 0s:

dd if=/dev/zero of=/dev/hda

This would effectively write over the entire drive with ascii code 0x00 characters.

At this point the chances for recovering any data would be almost hopeless to most data recovering techniques.
All though this is referring to a entire drive, the same can be applied or said about a partition, or directory, ...
This is the main reason it is recommended to use extreme caution when using the dd command, be sure you only zero the area you want to wipe, and only write over the correct area. All though some say repeating the process a few times makes it even more unrecoverable, I don't think it is necessary, Kind of like over kill, even though the first bullet killed the target, some people keep firing over and over just to be more sure.
If it is really critical,probably best to completely destroy the drive, I mean like break it into tiny pieces with a hammer, and then melt it in a furnace,...
from: https://ask.fedoraproject.org/en/questi ... coverable/Afterwards remove the file by executing : rm -f zerofillfile

Depending on how sensitive the deleted data was, consider to repeat it multiple times.

hack3rcon
Posts: 746
Joined: 2015-02-16 09:54
Has thanked: 48 times

Re: Wipe free spaces of a partition.

#18 Post by hack3rcon »

GarryRicketson wrote:Is the "dd" command is unrecoverable?
Most say :https://security.stackexchange.com/ques ... e-on-linux
It depends what level of "unrecoverable" you are going for. ... your data from a live-boot OS, then things like shred , dd ---snip---
In a nut shell, it would also depend on who was trying to recover it and what technology or tools they have.
from: https://www.marksanborn.net/howto/wipin ... e-with-dd/
So, in order to make deleted data unrecoverable we must write over it.
Wiping the Drive

Using dd to write over your entire drive with 0s:

dd if=/dev/zero of=/dev/hda

This would effectively write over the entire drive with ascii code 0x00 characters.

At this point the chances for recovering any data would be almost hopeless to most data recovering techniques.
All though this is referring to a entire drive, the same can be applied or said about a partition, or directory, ...
This is the main reason it is recommended to use extreme caution when using the dd command, be sure you only zero the area you want to wipe, and only write over the correct area. All though some say repeating the process a few times makes it even more unrecoverable, I don't think it is necessary, Kind of like over kill, even though the first bullet killed the target, some people keep firing over and over just to be more sure.
If it is really critical,probably best to completely destroy the drive, I mean like break it into tiny pieces with a hammer, and then melt it in a furnace,...
from: https://ask.fedoraproject.org/en/questi ... coverable/Afterwards remove the file by executing : rm -f zerofillfile

Depending on how sensitive the deleted data was, consider to repeat it multiple times.
Some tools can recover the data that destroyed by "dd" ?
I guess my command can't working properly:

Code: Select all

$ lsblk /dev/sdb
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sdb      8:16   0 465.8G  0 disk 
├─sdb1   8:17   0   200G  0 part /mnt/c
└─sdb2   8:18   0 265.8G  0 part /mnt/d

$ sudo dd if=/dev/zero |pv| dd of=/mnt/c/file;
1647831304+0 records in/s] [                                   <=>           ]
1647831303+0 records out
843689627136 bytes (844 GB) copied, 64564.8 s, 13.1 MB/s
As you see, the "sdb1" partition size is "200G" but "dd" did "844 GB" and I canceled it manually.

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Wipe free spaces of a partition.

#19 Post by p.H »

hack3rcon wrote:Some tools can recover the data that destroyed by "dd" ?
Short answer : no.
But dd may not destroy all the data that you would like to destroy.

Note : sudo is useless in your command. it applies only to the first dd command but root privilege is not needed to read /dev/zero.

hack3rcon
Posts: 746
Joined: 2015-02-16 09:54
Has thanked: 48 times

Re: Wipe free spaces of a partition.

#20 Post by hack3rcon »

p.H wrote:
hack3rcon wrote:Some tools can recover the data that destroyed by "dd" ?
Short answer : no.
But dd may not destroy all the data that you would like to destroy.

Note : sudo is useless in your command. it applies only to the first dd command but root privilege is not needed to read /dev/zero.
Why my "dd" command copied 844 GB?

Post Reply