Linux – CentOS / Redhat 6 Mount Encrypted Partition After Boot

centosdisk-encryptionlinuxpartitionredhat

I have an encrypted partition that I setup during install for CentOS 6 that I want to mount manually after boot. By default it prompts me for a password at boot time. I was able to get it to not prompt me for a password at boot by commenting the drive out from /etc/fstab and /etc/crypttab (although this is probably the wrong way to do it). I tried adding noauto to both the crypttab and fstab but that didn't seem to help. So I guess my question is a two-parter:

1) How do I properly disable an encrypted partition from mounting automatically on boot?

2) How do I manually mount the partition after boot?

For reference I've enclosed the relevant lines from my fstab and crypttab (as they were setup by default):

fstab:

/dev/mapper/luks-4fa25d53-0dcd-44ab-9f4d-bee5d6f90fce /sec                    ext4    defaults        1 2

crypttab:

luks-4fa25d53-0dcd-44ab-9f4d-bee5d6f90fce UUID=4fa25d53-0dcd-44ab-9f4d-bee5d6f90fce none

Best Answer

You need to add the noauto option to the filesystem in your fstab. That will prevent the automounter, or anything that calls or simulates a mount -a, from mounting it. However, since auto is part of the defaults option set, you should replace it entirely with the explicit options, minus auto. Pulling the full set from the man page, your new entry should look something like:

/dev/mapper/luks-4fa25d53-0dcd-44ab-9f4d-bee5d6f90fce /sec   ext4    rw,suid,dev,exec,nouser,async,noauto     1 2

Now, whether including dev, suid, and exec are appropriate for your file system is something you should consider.

Related Topic