Drive mounted on boot through /etc/fstab causes crash

I can mount the following disk manually:
└─18rabb80-20a1-5dab-a646-86summ9at6c3 253:1 0 931.5G 0 crypt /mnt/myHDD

It is an HHD, luks, and to be unlocked with a keyphrase or keyfile. I formatted it using ext4, I am fairly sure, though there’s some chance of it being ext2. I’ve failed to find this exact info.

I’ve tried to get the disk mounted automatically on boot by making an entry in /etc/fstab for it and, if I recall, what I added to the fstab file was as follows, only with a different actual name and ID:

18rabb80-20a1-5dab-a646-86summ9at6c3 /mnt/myHDD ext4 default

I am fairly certain ext4 is correct, and I may have tried omitting both ‘ext4’ and ‘default’ on my second attempt. EIther way, on boot, as I’m trying to unlock the HDD with the passphrase having already unlocked my boot drive, I enter an Emergency Mode reboot loop.

So, considering that twice already I’ve had to boot off a USB in order to unlock my boot drive and re-edit the fstab, I’d rather ask for advice before trying this again.

1 Like

Revert the /etc/fstab changes, boot Fedora as usual and then do the following:

# List disks by UUID
ls -l /dev/disk/by-uuid

# Define parameters
LUKS_UUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
LUKS_NAME="luks-drive"

# Open the LUKS drive
sudo cryptsetup open UUID=${LUKS_UUID} ${LUKS_NAME}

# Configure /etc/crypttab
sudo sed -i -e "/${LUKS_UUID}/d" /etc/crypttab
sudo tee -a /etc/crypttab << EOF > /dev/null
${LUKS_NAME} UUID=${LUKS_UUID} none timeout=20
EOF

# Fetch the filesystem UUID
FS_UUID="$(lsblk -n -o UUID /dev/mapper/${LUKS_NAME})"

# Configure /etc/fstab
sudo sed -i -e "/${FS_UUID}/d" /etc/fstab
sudo tee -a /etc/fstab << EOF > /dev/null
UUID=${FS_UUID} /mnt auto defaults,nofail 0 2
EOF

# Mount the filesystem
sudo mount -a

See also:

2 Likes

Thanks for your clear and thorough reply.

I’d forgotten about /etc/crypttab entirely, but whatever I did with that file previously was certainly different from what I see here.

I’ll be testing this a little later and then report back.

2 Likes

If that is the line format you placed in /etc/fstab it should be more like

UUID=18rabb80-20a1-5dab-a646-86summ9at6c3 /mnt/myHDD ext4 defaults,nofail 0 0

I added the ‘nofail’ option so it would not prevent the boot from completing if the mount fails. The line should be formatted similar to all others already in /etc/fstab, and does require the 6 distinct fields.

With the device unmounted, one may test the fstab entry by doing the following with the system booted normally.
Make the entry in /etc/fstab, then run the command mount -a. It should bring up the password prompt for that device, then mount it. If it fails then modify the line and repeat until it does properly mount.

2 Likes

Alright, I followed the advice of both of you and now everything works.

It seems to me, the main problem was that I didn’t put in all the options in fstab, and in the end I did put in all of em as per Jeff V’s reply, having followed Vladislav’s instructions perfectly as well.

I learnt some things from both of you, so thank you guys!

1 Like