8

I wiped the disk using

wipefs -a /dev/sda.

I happily formatted the disk, and it seems that when I'm about to mount /dev/sda3 it says "unknown file system type crypto_LUKS".

I did no encryption on this partition, so it's like the previous configuration is saved somehow. If I apparently wiped or reset the disk, how can this be possible?

Do I have to open and decrypt and remove encryption on that drive first?

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
Lorthas
  • 257
  • 3
  • 9

2 Answers2

11

wipefs -a /dev/sdx only wipes magic signatures on that device, not on its partitions. So at best, it only wipes your partition table, but if you then proceed to re-create the partitions at the same offsets at before, the old data is still there. You'd have to wipe the partitions as well.

wipefs -a /dev/sdx[1-9]* # wipe old partitions
wipefs -a /dev/sdx       # wipe the disk itself
parted /dev/sdx          # create new partitions
wipefs -a /dev/sdx[1-9]* # wipe the new partitions, just in case
# create filesystems or whatever

That aside it's also entirely possible for wipefs to not wipe something if it doesn't know the signature. Or for another program to still recognize the data on the partition despite the signature being damaged. wipefs only overwrites a few magic bytes, which is reversible in most cases.

frostschutz
  • 48,978
-1

Use the much more simple wipe command:

cat /dev/zero > /dev/sda

But BE CAREFULL, all files are history after that.

hschou
  • 2,910
  • 13
  • 15
  • I don't get it. Why is that after removing partitions and reseting a partition scheme the information is still there on the background like invisible? I could not even use wipefs cause apparently there was something still existing encrypted. I thought simply removing partitions or doing "o" in gdisk or fdisk wiped everything as well.ç – Lorthas Sep 28 '17 at 15:19
  • I don't why wipefs does not work. The command above or dd if you like will work. gdisk or fdisk does not erase the data area at all as they just re-organize the partition table. – hschou Sep 28 '17 at 16:31
  • 2
    @hschou, your command will work indeed, but it will take an "eternity" to run. wipefs takes only a couple of seconds, not hours or days. – Cristian Ciupitu Apr 07 '18 at 16:45