0

How can we delete the contents of the partition without deleting the partition table.

For example, if I have few files and folders which i need to clear and remove from the partition.

Running rm -rf in the folder will allow to recover using recovery tools. Using dd with /dev/zero we will wipe the partition table

dd if=/dev/zero of=/dev/sda1

What's the best way to delete the files and write zeroes in the same memory location, so it cannot be retrieved, without formatting the partition

md.jamal
  • 291
  • Why would you want to mess with your block device if all you want to do is remove a folder? Recipe for disaster right there – Panki Jul 21 '22 at 07:38
  • 3
    Your dd command does not wipe the partition table; it references /dev/sda1 so it will wipe the content of the first partition. But you'd be better off either using a decent block size (512 bytes is so small these days) or even just cat /dev/zero >/dev/sda1 – Chris Davies Jul 21 '22 at 08:02
  • 3
    Writing zeroes to the whole of /dev/sda (without a number at the end) would wipe the partition table, as that device refers to the whole drive. /dev/sda1 (with the number at the end) is an individual partition described by the partition table. – ilkkachu Jul 21 '22 at 08:47

0 Answers0