LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   UUID in /etc/fstab for luks partition (https://www.linuxquestions.org/questions/linux-newbie-8/uuid-in-etc-fstab-for-luks-partition-4175425909/)

malak33 09-06-2012 04:21 AM

UUID in /etc/fstab for luks partition
 
hey,
I'm using CentOS and I'm banging my head on the wall as to how to get the luks partition to mount on boot while using the UUID of the device. It is working with using the /dev/mapper/cryptPart.

here is /etc/fstab right now
Code:

#
#
# /etc/fstab
# Created by anaconda on Wed Sep  5 08:38:18 2012
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=13e31a3e-d1d6-4092-85ac-205e1b13ce11 /                      ext4    defaults        1 1
UUID=14ef3e84-2d3b-417a-be7f-a73cb06c56f2 /boot                  ext4    defaults        1 2
UUID=3de803fc-3e0d-43c8-821f-af3b957cd6e5 /home                  ext4    defaults        1 2
/dev/mapper/cryptPart /cryptDir                                  ext4    defaults        1 2
tmpfs                  /dev/shm                tmpfs  defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                  /sys                    sysfs  defaults        0 0
proc                    /proc                  proc    defaults        0 0

here is /etc/fstab with UUID
Code:

#
#
# /etc/fstab
# Created by anaconda on Wed Sep  5 08:38:18 2012
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=13e31a3e-d1d6-4092-85ac-205e1b13ce11 /                      ext4    defaults        1 1
UUID=14ef3e84-2d3b-417a-be7f-a73cb06c56f2 /boot                  ext4    defaults        1 2
UUID=3de803fc-3e0d-43c8-821f-af3b957cd6e5 /home                  ext4    defaults        1 2
###/dev/mapper/cryptPart /cryptDir                                  ext4    defaults        1 2
UUID=713450fb-0c30-4ff6-a3a7-e88d4638c621 /cryptDir
ext4    defaults        1 2
tmpfs                  /dev/shm                tmpfs  defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                  /sys                    sysfs  defaults        0 0
proc                    /proc                  proc    defaults        0 0

here is /etc/crypttab
Code:

cryptPart /dev/vda4
here is /etc/cryptab w/UUID
Code:

cryptPart UUID=713450fb-0c30-4ff6-a3a7-e88d4638c621
I've also tried this in /etc/crypttab
Code:

luks-713450fb-0c30-4ff6-a3a7-e88d4638c621 UUID=713450fb-0c30-4ff6-a3a7-e88d4638c621
the error that i keep on getting while trying to boot is this(it asks me for my password though first)
Code:

fsck.ext4: Device or resource busy while trying to open /dev/vda4
Filesystem mounted or opened exclusively by another program? [FAILED]
***An error occurred during the file system check.
***Dropping you to a shell; the system will reboot
***when you leave the shell.
***Warning - - SELinux is active
***Disabling security enforcement for system recover.
*** Run 'setenforce 1' to reenable.
Give root password for maintenance
(or type Control-D to continue):

edit: here is the output to cryptsetup luksDump /dev/vda4 | grep UUID
Code:

UUID=713450fb-0c30-4ff6-a3a7-e88d4638c621

malak33 09-11-2012 11:22 PM

bump

VDP76 09-12-2012 05:27 AM

I do not have experience with luks, but my wild guess would be to try the following entry in fstab...
Code:

UUID=luks-713450fb-0c30-4ff6-a3a7-e88d4638c621 /cryptDir  ext4    defaults        1 2
does it work?

michaelk 09-12-2012 09:26 AM

You still need /dev/mapper/ in your fstab.
What happens when you try:
/etc/fstab
Quote:

/dev/mapper/cryptPart /cryptDir ext4 defaults 1 2
/etc/cryptab
Quote:

cryptPart UUID=713450fb-0c30-4ff6-a3a7-e88d4638c621

doublejoon 09-12-2012 11:11 AM

michaelk is on to something here. I would do it his way.

In addition to avoid being prompted for passphrase on boot I would use a key file as a slot



cd /root
dd if=/dev/urandom of=.keyfile bs=1024 count=4
chmod 400 .keyfile
chattr +i .keyfile (Makes the file immutable to prevent accidential deletion)

cryptsetup luksAddKey /dev/vda4 /root/.keyfile

/etc/crypttab
cryptPart UUID=713450fb-0c30-4ff6-a3a7-e88d4638c621 /root/.keyfile luks

malak33 09-12-2012 11:20 PM

VDP76- tried what you suggested and it doesn't work for me

michaelk- i tried what you suggested and it works. However, the reason I'm trying to get this to work is for the RHCSA exam I'm taking on Monday this is about the only thing i don't know how to do on their list of Exam objectives
Quote:

Configure local storage

List, create, delete, and set partition type for primary, extended, and logical partitions.
Create and remove physical volumes, assign physical volumes to volume groups, and create and delete logical volumes.
Create and configure LUKS-encrypted partitions and logical volumes to prompt for password and mount a decrypted file system at boot.
Configure systems to mount file systems at boot by Universally Unique ID (UUID) or label.
Add new partitions and logical volumes, and swap to a system non-destructively.
thats from Red Hat
as you can see from my /etc/fstab everything else is using the UUID, do you think I'll be fine or am i overthinking this?

michaelk 09-13-2012 08:02 AM

You will be fine. You also need /dev/mapper for mounting logical volumes. Have you tried LVM yet?

rfreiberger 11-23-2012 05:20 PM

Apologies for posting on a old thread but I was stuck on this issue studying for the RHCSA. I tried everything and know that the luks was working as I could mount it manually but not through /etc/fstab. I found that my fsck selection was too low, which I think caused some issues checking the mount before checking the passphrase.

All I did to this fix this was change the last /etc/fstab setting from 4 to 2. Below is the current setting which works, but when I had the fsck setting to 4 (the last column), I got the prompt to enter the passphrase, but right after that it reverts to maintenance mode.

Code:

UUID=83a523b1-71b5-4e59-926e-126086d47a9b /                      ext4    defaults        1 1
UUID=332e4077-dcfb-4da6-ad63-bf669c5f7042 /boot                  ext4    defaults        1 2
UUID=e2c66d36-f298-40f2-bd63-78eb2e25f72d swap                    swap    defaults        0 0
tmpfs                  /dev/shm                tmpfs  defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                  /sys                    sysfs  defaults        0 0
proc                    /proc                  proc    defaults        0 0
/dev/vg1/lv100          /lv100mnt              ext4    defaults        1 3
/dev/mapper/sdd1luks    /sdd1luks              ext4    defaults        1 2

As a side note, for any one stuck with the filesystem in read only, you can't edit the /etc/fstab file.
Code:

#mount -o remount,rw /
I am pretty sure this is the reason why it failed but not 100% sure. Maybe someone can post the real reason?

Thanks,
Rob


All times are GMT -5. The time now is 01:34 AM.