30

How can I verify if a hard drive is encrypted in Fedora 20?

If not, does it mean I have to re install Fedora to encrypt it?

1 Answer 1

41

Assuming that the drive is /dev/sdb, and the partition you want to check is /dev/sdb1, run this command:

$ blkid /dev/sdb1 

the output will change if the partition is encrypted or not:

/dev/sdb1: UUID="xxxxxxxxxxxx" TYPE="crypto_LUKS" #encrypted /dev/sdb1: UUID="xxxxxxxxxxxx" TYPE="ext4" #not encrypted, fs is ext4 

If the partition is not encrypted, and assuming that you are NOT trying to encrypt the / partition, you have to:

  • Make a backup of the data on that partition
  • Initialize the partition as encrypted

    $ cryptsetup luksFormat /dev/sdb1 

BEWARE: this command will wipe all the contents of the partition!!! It will ask you for a passphrase to open the volume; now if you try to run blkid, the output should be TYPE="crypto_LUKS"

  • Open the encrypted partition to use it

    $ cryptsetup luksOpen /dev/sdb1 secret 

where "secret" is the name of the volume we are opening

  • Format the new "secret" volume

    $ mkfs.ext4 /dev/mapper/secret 
  • Mount it providing the passphrase created before

    $ mount /dev/mapper/secret /whereyouwant 

    Now you should be able to use the encrypted partition!

Optionally, if you want to mount it at reboot, you should edit /etc/crypttab and insert a line similar to this (it will request the password at boot):

secret /dev/sdb1 none 

Where secret is the name of the volume we created before.

Or something like this, if you want to put your password in some plain text file:

secret /dev/sdb1 /whereyouwant-sdb1-luks-pwdfile 

Just keep in mind for this, you also have to add the key:

$ cryptsetup luksAddKey /dev/sdb1 /whereyouwant-sdb1-luks-pwdfile 

And edit the /etc/fstab and insert a line similar to this:

/dev/mapper/secret /whereyouwant ext4 defaults 1 2 
10
  • many thanks, but what should I do if I need the whole disk be encrypted. Commented Jan 9, 2014 at 13:26
  • Just repeat the blkid /dev/sdbx command for each partition. Commented Jan 9, 2014 at 13:36
  • 1
    it's obvious =), I mean what to do if I need to encrypt the whole disk. To reinstall Fedora and chose encrypted LVM during installation will be the only option? Commented Jan 9, 2014 at 13:39
  • 1
    Sorry, my bad :) Yes, the only option is to reinstall Fedora, sadly. Commented Jan 9, 2014 at 13:41
  • yeah, sadly. Many thanks for the information, ludiegu. Commented Jan 9, 2014 at 13:48

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.