0

I would like to install Linux on PC through USB flash drive. But there is already old operating system. I want to clean HDD using command line. In windows, I just use diskpart > list disk > select disk > clean. Is there any way to clean HDD as easy as Windows does?

4
  • 1
    I'm unfamiliar with Windows. Do you want to remove everything off the hard drive? Repartitioning the drive will do that (although it wouldn't strictly speaking be a "secure clean"). That's usually one of the steps of installing Linux. – Kusalananda Sep 15 '17 at 17:02
  • 1
    Liu Bei here Guan Yu ;-p...Usually open installing the installer will ask if you want to use the whole disk or not. – Rui F Ribeiro Sep 15 '17 at 17:23
  • What do you mean by "clean"? Do you want to delete the partition, the files, or to do a secure erase so the files can not be recovered or what? – ventsyv Sep 15 '17 at 18:37
  • I mean all of the things you said @ventsyv – Liu Bei Sep 16 '17 at 8:07
1

It is not necessary to completely wipe a Hard Drive before installing Linux over it. As it alludes to in the comments above, it is enough to tell the Installer to use the whole disk and it will totally replace Windows with Linux.

If, however, you are concerned with security and any Windows files being recovered either you can use Linux commands such as those shown at http://how-to.wikia.com/wiki/How_to_wipe_a_hard_drive_clean_in_Linux or use a seperate program like DBAN - https://dban.org/

To totally obliterate a Hard Disk Drive you need to run these alternatives several times. ---Although some people say that the only really secure method of dealing with a HDD is to physically destroy it. Sledge hammer anyone?

1
  • Depends how much the data is worth. If very valuable then grinding to dust, and burning may be the only option. However in most cases, use shred, or just write the new OS over the top. If you were happy for the data to be on the disk yesterday, then what has changed? – ctrl-alt-delor Sep 19 '17 at 16:42
0

Boot from your installation media and usually there is an option to run a command line prompt. Recovery CDs like SystemRescueCd can also be used, but I do believe most installation CDs do support this. Alternatively, you can use the "try without installing" option that many live CDs have.

Once you have your terminal running, you can use the shred command to erase the partition you want. For example: shred -vzn 3 <device_here> will overwrite your files 3 times with random numbers.

This answer on AskUbuntu goes in some more details on how to use shred.

You can also use Gparted. I haven't used Gparted in a while but I found this article explains that explains it well.

If you are only concerned with the files from the old OS somehow interfering with the new OS I suggest using the default partitioning that the installer suggest. While it will not securely erase your files, it will threat the disk as empty space and will install the new OS on top of it. The new OS will have no knowledge of the old files, but someone with the right knowledge and tools might be able to recover some of those files if they have access to your hard drive.

0

All you have to do is boot from the USB and begin the installation and it will prompt you to install alongside or wipe existing partition and install a new fresh install.

Not the answer you're looking for? Browse other questions tagged or ask your own question.