Jump to content

Linux clean wipe?

Go to solution Solved by dhumes05,

Hello,

From a arch live environment:

You can open a terminal and run:

Command: lsblk

What it will do:  Show you your installed drives.

If you want to Zero out the drive you can then run:

Command: shred -vfz -n 3 /dev/sdx

Side note: The "x" represents your install drive, example sda) the command would then write over the drive three times twice with random data, then the last with a pass of zeroes.

 

If you are not worried about completely wiping the drive, you can run:

Command: cfdisk /dev/sdx

Side note: The "x" represents your install drive, example sda. Then from the screen selection you can select the partitions and delete them and then save your writes you made.

 

 

Hi does anyone know the code to enter into the terminal to compleatly wipe all hard drives in Linux Including Linux itself Thanks :)

Link to comment
Share on other sites

Link to post
Share on other sites

Hello,

From a arch live environment:

You can open a terminal and run:

Command: lsblk

What it will do:  Show you your installed drives.

If you want to Zero out the drive you can then run:

Command: shred -vfz -n 3 /dev/sdx

Side note: The "x" represents your install drive, example sda) the command would then write over the drive three times twice with random data, then the last with a pass of zeroes.

 

If you are not worried about completely wiping the drive, you can run:

Command: cfdisk /dev/sdx

Side note: The "x" represents your install drive, example sda. Then from the screen selection you can select the partitions and delete them and then save your writes you made.

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

23 hours ago, Fluxcabury said:

Hi does anyone know the code to enter into the terminal to compleatly wipe all hard drives in Linux Including Linux itself Thanks :)

2 hours ago, dhumes05 said:

Hello,

From a arch live environment:

You can open a terminal and run:

Command: lsblk

What it will do:  Show you your installed drives.

If you want to Zero out the drive you can then run:

Command: shred -vfz -n 3 /dev/sdx

 

If you do that, make sure that the drive you're booting of is the last one to erase, otherwise you won't have an operating system to erase the rest anymore :D

 

Of course, if you have a hard drive (NOT an SSD!), stuff like DBAN is always an option.

Link to comment
Share on other sites

Link to post
Share on other sites

sudo rm -rf /

Cuz who's needs anything more sophisticated?

Sudo make me a sandwich 

Link to comment
Share on other sites

Link to post
Share on other sites

You say "all hard drives" .... well, of course that depends on how many hard drives you have and sometimes even on what type they are.

 

All advices already given are sound.  In short, to account for ALL hard drives, something like this will work for most systems:

 

for HARDDISK in /dev/sd? ; do dd if=/dev/zero of=$HARDDISK ; done

But, this command, too, will also erase the running OS. It should work if you tweak the command so that the hard disk with the OS is the last erased (or exclude it!). While erasing the running OS, you might run into something like a Kernel Panic which might interrupt the erase. Just to keep my sanity, I'd do this kind of operations from some other live enviroment (USB / CD / DVD / network bootable Linux). I don't like to pull out the carpet of a running OS, but in case you are on a OS killing mission, I suppose it wouldn't matter ?

 

A bit of background: all SATA (EDIT: this is not conclusive - usually also USB, and possibly others are here!) drives are named as /dev/sdX (where X is a, b, c, d etc.); partitions are sdXN, where N is the partition number. With the above command you will be writing all /sd? with zeroes (EDIT: it will take quite a long time - depending on the size of the disks!). But it can be the case, there are other hard drives besides /dev/sdX; for example, M.2 NVME disks will be named /dev/nvmeAnB - and there's no reason there couldn't be others. In case you haven't tinkered with your distribution and don't use exotic hardware, you are good. Historically, hard disks were named /dev/hdX (IDE drives) and the device nodes could be renamed various ways. To make sure, you might want to run commands such as "lsblk" and "blkid" as root, to see what block devices the Kernel has found on the running system.

 

Also, there are different ways to erase. If you just want to erase partitions, removing the label is enough (i.e. the first 512 bytes should do, for DOS partition tables and probably GPT too, though I'm not sure - just increase to few kilo-megabytes and every disk label will be erased for sure). If you want to do it securely, i.e. make impossible to retrieve files, then DDing zeros to the whole disk is enough for civilian usage, but in case the hard disks contain secrets which might interest the FBI, NSA, CIA, KGB or some industrial espionage organizations, that might not be enough (EDIT: The shred command suugested by @dhumes05 will probably be enough, or at least make it very difficult / infeasible to retrieve data even in a very advanced laboratory). Also, SSDs are another thing altogether (use some TRIM command to actually erase it, wear leveling might preserve data even though one thinks it is erased).

 

EDITX: Talking bout secure erasing ....

Link to comment
Share on other sites

Link to post
Share on other sites

If you want to be sure that you erased everything, boot up a live-linux (grml or similar) and mount/erase the drives from that to prevent the kernel from panicking because you're deleting a file it needs.

Intel i7 5820K (4.5 GHz) | MSI X99A MPower | 32 GB Kingston HyperX Fury 2666MHz | Asus RoG STRIX GTX 1080ti OC | Samsung 951 m.2 nVME 512GB | Crucial MX200 1000GB | Western Digital Caviar Black 2000GB | Noctua NH-D15 | Fractal Define R5 | Seasonic 860 Platinum | Logitech G910 | Sennheiser 599 | Blue Yeti | Logitech G502

 

Nikon D500 | Nikon 300mm f/4 PF  | Nikon 200-500 f/5.6 | Nikon 50mm f/1.8 | Tamron 70-210 f/4 VCII | Sigma 10-20 f/3.5 | Nikon 17-55 f/2.8 | Tamron 90mm F2.8 SP Di VC USD Macro | Neewer 750II

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×