I have read a few tutorials on setting up an encrypted file system using cryptsetup. They all start with the following creation of a random file

dd if=/dev/urandom of=/etc/cryptfile bs=1M count=10

This file would be further used to create a loopback device. The reason given for the randomising the file is generally given that the attacker won't be able to find what parts of the file are used to write and what parts are empty. My question is that since the loop back device is any way going to be formatted when we write the file system on it then why would we care about randomizing it in the first place?

  • I'm not sure, but I've always used /dev/zero, it's quicker, and if there's no reason to randomize it, I don't see why not. This might change depending on the answer to this question though.. – Azz Nov 22 '10 at 0:39

When you format a drive you don't erase any of the data that on it. You only overwrite the part that keeps track of where files are (the filesystem). The only way to get rid of the data is to overwrite it. If you overwrite it with zeros as Azz suggests, an attacker will know which parts are information and which parts are zeroes instantly. Random data looks just like encrypted data however (all else being equal).

  • Ahh, makes sense now. Thanks mate! +1 – Azz Nov 22 '10 at 0:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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