Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Wipe a flash drive!
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo Chat
View previous topic :: View next topic  
Author Message
The_Great_Sephiroth
Veteran
Veteran


Joined: 03 Oct 2014
Posts: 1602
Location: Fayetteville, NC, USA

PostPosted: Tue Apr 07, 2015 7:33 pm    Post subject: Wipe a flash drive! Reply with quote

I wiped it alright. I normally use 4MiB blocks since most modern flash drives use that erase-block size. This time however, I only want to erase the first 128MiB.
Code:

dd if=/dev/zero of=/dev/sda bs=4M count=32

Now, what did I do wrong there? Oh wait, /dev/sda would be my internal HDD! So I caught it after I went to partition the flash drive and it told me the old partition table was still there. Oops! I calmly backed up all of my data and then turned off the laptop. Reloading it now. Doh!
_________________
Ever picture systemd as what runs "The Borg"?
Back to top
View user's profile Send private message
The Doctor
Moderator
Moderator


Joined: 27 Jul 2010
Posts: 2678

PostPosted: Wed Apr 08, 2015 2:30 am    Post subject: Reply with quote

May I point out how pointless this is to do to flash memory or an SSD? You will not wipe the data due to wear leveling. In fact, I strongly suspect that this approach is actually harmful to the flash drive because you are writing data to it instead of instructing the drive to consider the sections as available.
_________________
First things first, but not necessarily in that order.

Apologies if I take a while to respond. I'm currently working on the dematerialization circuit for my blue box.
Back to top
View user's profile Send private message
The_Great_Sephiroth
Veteran
Veteran


Joined: 03 Oct 2014
Posts: 1602
Location: Fayetteville, NC, USA

PostPosted: Wed Apr 08, 2015 12:23 pm    Post subject: Reply with quote

It works. We have used this method to securely erase them in government locations. We actually do a random, then a zero there, however. Remember, even with wear-levelling, 16GB is still 16GB. So if it reports that it wiped 16GB, then it had to have written all blocks.

Either way the company hired to check behind us has never been able to recover data after we do this.
_________________
Ever picture systemd as what runs "The Borg"?
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2977
Location: Germany

PostPosted: Wed Apr 08, 2015 12:35 pm    Post subject: Reply with quote

With an SSD, you can just blkdiscard. You're trusting the hardware at this point, but if TRIM actually erases the cells, it should not be recoverable. It renders data inaccessible by software, which should be sufficient for most people.

If you don't trust the hardware, the best option is to write random data using shred or by writing through an encryption layer. Unlike zeroes, random data can not be compressed or optimized away in other ways.

So at least you know you're overwriting everything except for whatever reserves the device has internally. So if a device has a 5% reserve, you killed 95%. And the reserve is usually erased since you'd get lousy performance otherwise.
Back to top
View user's profile Send private message
The Doctor
Moderator
Moderator


Joined: 27 Jul 2010
Posts: 2678

PostPosted: Wed Apr 08, 2015 4:59 pm    Post subject: Reply with quote

It shouldn't work. The flash drive remaps the sectors you are commanding writes to. It does this for wear leveling and to increase performance.

MY point is, you have no way of knowing if you are writing to the address you think you are, or if you are writing to a new one. And as for "government efficiency," you know what that is really worth, right?
_________________
First things first, but not necessarily in that order.

Apologies if I take a while to respond. I'm currently working on the dematerialization circuit for my blue box.
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2977
Location: Germany

PostPosted: Wed Apr 08, 2015 5:46 pm    Post subject: Reply with quote

The Doctor wrote:
It does this for wear leveling and to increase performance.


The only way you get increased performance, is if you actually erase the remapped cells at some point. The erase is what takes the longest amount of time.

It doesn't matter if the cells get remapped, as long as they get erased as well. This erase happens in the background when the device is idle, which should not be a problem either as drives are idle all the time (in a desktop environment).

The Doctor wrote:
MY point is, you have no way of knowing


Yes, certainly. You have to trust the hardware here. Outside of a laboratory, you can't check what it really does. Same goes for secure erase - in theory it's supposed to erase everything properly, in practice it depends on the implementation.

But the hardware has limits, it can only store so much data; if you don't trust the hardware, overwriting everything with random data is still the best option. The only thing left after a random data pass is the reserve and this can't be very large (simply due to cost) and even if that reserve does not consist of erased blocks it's unlikely to hold useful data (random snippets from all over the place rather than consecutive information).

Quote:
Either way the company hired to check behind us has never been able to recover data after we do this.


You won't be able to recover anything after a simple blkdiscard either.



Wiping a HDD is much more complicated and time consuming... in terms of data recovery, SSD is a total nightmare, because of TRIM being executed wantonly everywhere. Most filesystem's mkfs do a TRIM by default without asking you so an accidental mkfs, which is hard enough to recover from on HDD, is impossible to recover on SSD. People set issue_discards=1 in their lvm.conf since they mistakenly believe that trim won't work otherwise, when all it really does is TRIM on lvremove/lvresize, so suddenly a wrong action in LVM which should be as harmless as a partitioning change, is irrecoverable on SSD as well. Worst of all is the discard mount option of filesystems, which does not help performance at all, but makes a simple rm also impossible to recover from.

If you're using flash media (the kind that supports TRIM) you should double your backup efforts. Unlike HDDs, there are no second chances and filesystem carvers such as PhotoRec are useless after discard already happened.
Back to top
View user's profile Send private message
The_Great_Sephiroth
Veteran
Veteran


Joined: 03 Oct 2014
Posts: 1602
Location: Fayetteville, NC, USA

PostPosted: Wed Apr 08, 2015 8:15 pm    Post subject: Reply with quote

Guys, this is a USB flash drive, not an SSD. I do not believe these things have all that nice functionality a SATA/SAS SSD has. I plugged it in, it was assigned /dev/sdb, and I accidentally zeroed 128MiB (134MB) of /dev/sda. Again, oops!

Correct me if I am wrong about USB flash drives and TRIM and such. These are 16GB sticks, not external SSDs or something.

*EDIT*

Quote:
If you're using flash media (the kind that supports TRIM) you should double your backup efforts.

We do not use SSDs yet. Things like bit-creep (electrons moving between areas on the media), complete, sudden, unrecoverable failure, and so many minor thigns resulting in lost data have kept both our backups (RAID/NAS) and systems running mechanical disks. I can get some warning from them and I can recover lost data on them. Flash may be great, but it is not where I want it to be just yet.
_________________
Ever picture systemd as what runs "The Borg"?
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3136

PostPosted: Wed Apr 08, 2015 9:36 pm    Post subject: Reply with quote

Pendrives are SSDs. SSD = Solid State Drive. This term refers to any semiconductor-based memory. Flash drive is a flash drive, be it one with PCIe interface or one with USB, no difference. What makes a flash drive is the ability to erase a block in a single operation instead of erasing a single cell at a time like the other kind of EEPROM (yes, flash is EEPROM as well). And those SSDs with PCIe sockets are flash drives too.

Now, what the point of this topic actually is? Bragging about a typo on dd line? :D
Back to top
View user's profile Send private message
davidm
Guru
Guru


Joined: 26 Apr 2009
Posts: 557
Location: US

PostPosted: Thu Apr 09, 2015 1:03 am    Post subject: Reply with quote

The old Disk Destroyer (dd). Always make it a policy to triple check before hitting enter when dealing with it. In fact maybe a mandatory count to ten aloud might also be good along with a short prayer. ;)
Back to top
View user's profile Send private message
The_Great_Sephiroth
Veteran
Veteran


Joined: 03 Oct 2014
Posts: 1602
Location: Fayetteville, NC, USA

PostPosted: Thu Apr 09, 2015 2:17 am    Post subject: Reply with quote

I use dd on a daily basis. I was in a hurry. In fact i hurried so much I was without my Gentoo laptop for two days. The lesson? Don't rush!
_________________
Ever picture systemd as what runs "The Borg"?
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2977
Location: Germany

PostPosted: Thu Apr 09, 2015 11:18 am    Post subject: Reply with quote

You could make it a habit to use one of the /dev/disk/by-*/* instead of /dev/sda. There are usually good identifiable names available there that include the type/model/serial of the device.

Then again, I don't do this myself :lol:

It could probably be done with a dd alias that displays the disk information of your chosen if= and of= devices and asks for confirmation.
Back to top
View user's profile Send private message
The_Great_Sephiroth
Veteran
Veteran


Joined: 03 Oct 2014
Posts: 1602
Location: Fayetteville, NC, USA

PostPosted: Thu Apr 09, 2015 12:08 pm    Post subject: Reply with quote

I was thinking of an alias that somehow prevented me from using /dev/sda as the "of" parameter. Then again, in all my years of Linux use, this is the FIRST screw-up with dd I can recall.
_________________
Ever picture systemd as what runs "The Borg"?
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7470

PostPosted: Thu Apr 09, 2015 1:16 pm    Post subject: Reply with quote

The_Great_Sephiroth wrote:
It works. We have used this method to securely erase them in government locations.

What government is stupid enough to pay someone to erase a 16g flash?
You can burn it and use a new one: datas clean, ~10$ cost (as i don't think your company take only 10$ for the op)
Back to top
View user's profile Send private message
pilla
Bodhisattva
Bodhisattva


Joined: 07 Aug 2002
Posts: 7729
Location: Underworld

PostPosted: Wed Apr 22, 2015 1:43 pm    Post subject: Reply with quote

krinn wrote:
The_Great_Sephiroth wrote:
It works. We have used this method to securely erase them in government locations.

What government is stupid enough to pay someone to erase a 16g flash?
You can burn it and use a new one: datas clean, ~10$ cost (as i don't think your company take only 10$ for the op)


I don't know how it works in sane places, but here in Brazil government institutions receive money to spend in certain areas and it is not usually possible to move it around. For example, we may have money to fix a computer but not to buy a new one, even though the last option is cheaper.
_________________
"I'm just very selective about the reality I choose to accept." -- Calvin
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo Chat All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum