Yes. I will assume you have some way of attaching the drive to the Pi via an external enclosure. Then, you will need to get the device ID of the external drive with this command:
This command will return something like the following:
Code:
/dev/sda1: UUID="d88b67c5-fba8-4bb8-8756-f79eb11e4b5c" TYPE="ext4" PARTUUID="580e7198-691e-4ba0-84a5-7fc5fe6e8647"
/dev/sda2: UUID="d88b67c5-fba8-4bb8-8756-f79eb11e4b5c" TYPE="ext4" PARTUUID="580e7198-691e-4ba0-84a5-7fc5fe6e8647"
/dev/sdb1: UUID="d88b67c5-fba8-4bb8-8756-f79eb11e4b5c" TYPE="ext4" PARTUUID="580e7198-691e-4ba0-84a5-7fc5fe6e8647
The "/dev/sda1", "/dev/sda2", and "/dev/sdb1" part is what you need to watch. That is the device identifier for each attached disk. A different disk will have a different letter. Partitions are noted by the numbers. So /dev/sda1 is the first partition on disk sda, /dev/sda2 is the second partition, etc. /dev/sdb1 is the first partition on a
different disk (/dev/sdb in this case). You may also be able to glean some info about which identifier is for your external HDD by running
This will dump the kernel message buffer to the console, search through it for lines containing "sd", and only display those lines. Look for a disk ID related to your external drive in that output. You can also replace "sd" with the search term of your choice.
Once you have the device ID of your external drive (say it's /dev/sdb for this example), you're ready to overwrite it with random data. Note that you do not include the partition number in this command because you want to overwrite the whole drive, not just a single partition.
Code:
sudo dd if=/dev/urandom of=/dev/sdb bs=1M
The dd command copies data from an input file ("if") to an output file ("of"). In this case, we are copying pseudorandom data from the pseudorandom device /dev/urandom and using it to overwrite everyhting on the external disk that we identified as /dev/sdb. This is why getting the device identifier is so important. If you picked the wrong one, such as /dev/sda, you could end up overwriting the internal system storage for your Linux system. dd will not give you a chance to confirm before it starts writing, so make sure you get the right device identifier before running this command.
This command will simply overwrite everything on the disk with random data 1 time. On a traditional HDD, this is probably good enough. While you could be paranoid and run this command again once it's finished, it's not clear that multiple passes accomplish much in the way of security. Finally, on a SSD, it is better to issue a secure erase command to the controller that will clear all the data held in the storage cells than to try overwriting it.