5

How can I delete all data that is on stick?

For example I have this problem:

My stick has two partitions A (3.7 GB) and B (330 MB). How can I merge the two partitions in one and to delete all data that they contain?

I guess they have read-only properties... How can I force deleting them?

I see this in GParted:

3 Answers 3

8

How to erase / delete / blank or wipe a disk

I’m sure there are other methods, but the one I prefer to use is the one that uses dd to copy zeros, or random data in the file system I want to wipe.

So, run this command if you want to erase your… let’s say microSD card.

Suppose it is mounted on /dev/sdd1:

dd if=/dev/urandom of=/dev/sdd1

If you do not want to wait too much, you can fill the partition with zeros instead of random data:

dd if=/dev/zero of=/dev/sdd1

Both are secure, but IMHO the first one may be better, but of course I can be wrong.

Once again, be sure to double check, or better triple check on which partition you are going to apply this, you will not be warned by Linux, and the result can not be undone.

A good practice could be to first make an image of the disk and then wipe it. If you want to proceed that way, do this.

dd if=/dev/[partition-to-wipe] of=/tmp/backup.img

Then wipe it

dd if=/dev/urandom of=/dev/[partition-to-wipe]

You can then recover the data by doing

dd if=/tmp/backup.img of=/dev/[partition-to-wipe]

Info taken from this site.

8
  • I get: dd: opening ‘/dev/sr1’: Read-only file system. Dec 16, 2013 at 16:33
  • 1
    For /dev/random vs /dev/zero, see here - @Johnツ, you need to use the command with sudo in front.
    – Wilf
    Dec 16, 2013 at 16:33
  • Urrr... Doesn't restoring the image restore anything that was removed by wiping it with /dev/random or /dev/zero?
    – Wilf
    Dec 16, 2013 at 16:36
  • @wilf Nope. /dev/zero is just a place where data gets dumped and destroyed. If you reboot, nothing will be left, might even be before! Dec 16, 2013 at 16:37
  • 1
    @wilf True. I think he just included that in case John ツ wants to restore the data in case he accidentally didn't want to wipe that stick. Dec 16, 2013 at 16:44
7

Just use GParted. GParted

Unmount all the partitions on the USB stick, and then delete them. You can then create partitions as you like. The is some documentation here if you need any.

This should effectively wipe any partitions. - remember to click this green button, or it won't do anything:

enter image description here


If you just want to wipe it, you could also find the device name in sudo fdisk -l in terminal, and then run:

sudo dd /dev/zero /dev/sdX1

Where sdX1 is the name and partition number of the device, which you can find in GParted or fdisk. This is not that necessary if you just use GParted, but you may need to use GParted afterwards to reformat it anyway... smiley

9
  • Seems that the other partition is not visible... :-( How can I merge it? Dec 16, 2013 at 16:39
  • If is not visible, it is probably not there in the first place. Just delete everything, and some new partitions (FAT32 is best if you want it to work with Windows as well) - Having copied anything you want off first - :-)
    – Wilf
    Dec 16, 2013 at 16:43
  • I can see it in Nautilus and access its files. After formatting the USB drive they are still there. Dec 16, 2013 at 16:44
  • Is this a common-or-garden USB stick? Wiping the partition table would get rid of everything as well. Note that you have to click the tick in GParted before it does anything...
    – Wilf
    Dec 16, 2013 at 16:45
  • It contains a read-only partition... How can I delete or merge it? Dec 16, 2013 at 16:47
1

Simple! Start up gparted via the terminal (Ctrl+Alt+T) and entering sudo gparted

terminal.

Once you do that gparted will start.

gparted starting

The USB stick should show in the disks area (upper-right-hand corner) as something like /dev/usb or /dev/sdb. Make sure the disk selected is the USB stick, the following steps will wipe ALL data on the selected disk.

  1. Go to Device>Create Partition Table This window will come up:

new partition window

click Apply . You may have to also start this process by clicking the check-mark button.

This will create a new partition table and will make the data unrecoverable by most people.

3
  • You may want to use gksudo gparted instead of sudo...
    – Wilf
    Dec 16, 2013 at 16:40
  • Depends on personal preference I guess. Dec 16, 2013 at 16:41
  • Nahhh... Its more that some want it that way on this forum, and like editing answers to be the way they want them.
    – Wilf
    Dec 16, 2013 at 16:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .