You are not logged in.

#1 2014-01-03 02:14:01

LeftyAce
Member
Registered: 2012-08-18
Posts: 162

[solved] Grub fails to open dm-crypt+luks volume

Hi all,

I followed the old dmcrypt+luks tutorial (which no longer exists?) a week ago and got things working on an old drive. Then I decided to start over, copying my whole / partition from my live system to attempt a migration to an encrypted drive. I copied /, re-did the grub install and mkinitcpio, and now grub doesn't attempt to decrypt anything. It skips straight to looking for /dev/mapper/cryptroot and drops me to a shell prompt when it can't find that device.

At the shell prompt I can run cryptsetup luksOpen, etc and unlock the volume. I then exit the shell and the system boots correctly.

My configuration is:
/boot is on the second partition on a USB thumb drive.
/ is an encrypted dm-crypt container.

Here's my /etc/default/grub:

GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="Arch"
GRUB_CMDLINE_LINUX_DEFAULT="cryptdevice=UUID=fcd054db-f1b5-41b5-b21e-468e3f590384:cryptroot rw"
GRUB_CMDLINE_LINUX=""

# Preload both GPT and MBR modules so that they are not missed
GRUB_PRELOAD_MODULES="part_gpt part_msdos"

# Uncomment to enable Hidden Menu, and optionally hide the timeout count
#GRUB_HIDDEN_TIMEOUT=5
#GRUB_HIDDEN_TIMEOUT_QUIET=true

# Uncomment to use basic console
GRUB_TERMINAL_INPUT=console

# Uncomment to disable graphical terminal
#GRUB_TERMINAL_OUTPUT=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
GRUB_GFXMODE=auto

# Uncomment to allow the kernel use the same resolution used by grub
GRUB_GFXPAYLOAD_LINUX=keep

# Uncomment if you want GRUB to pass to the Linux kernel the old parameter
# format "root=/dev/xxx" instead of "root=/dev/disk/by-uuid/xxx"
GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
GRUB_DISABLE_RECOVERY=true

# Uncomment and set to the desired menu colors.  Used by normal and wallpaper
# modes only.  Entries specified as foreground/background.
#GRUB_COLOR_NORMAL="light-blue/black"
#GRUB_COLOR_HIGHLIGHT="light-cyan/blue"

# Uncomment one of them for the gfx desired, a image background or a gfxtheme
#GRUB_BACKGROUND="/path/to/wallpaper"
#GRUB_THEME="/path/to/gfxtheme"

# Uncomment to get a beep at GRUB start
#GRUB_INIT_TUNE="480 440 1"

#GRUB_SAVEDEFAULT="true"
GRUB_DISABLE_SUBMENU=y

Here is the output of blkid:

/dev/sda1: UUID="fcd054db-f1b5-41b5-b21e-468e3f590384" TYPE="crypto_LUKS"
/dev/sdb1: UUID="D078-439E" TYPE="vfat" PARTUUID="90909090-01"
/dev/sdb2: UUID="d9fdd09f-aa89-40a6-b99b-e4d89f238408" TYPE="ext2" PARTUUID="90909090-02"
/dev/mapper/cryptroot: UUID="26f65140-10c1-4f45-b039-ba077a45005f" TYPE="ext4"

Despite setting DISABLE_LINUX_UUID=t, my /boot/grub/grub.cfg shows a bunch of uuids. I even set cryptdevice=/dev/sda1:cryptroot, and this is the result: (EDIT: the only UUID there is for the /boot partition, so that's probably a false alarm).

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
insmod part_gpt
insmod part_msdos
if [ -s $prefix/grubenv ]; then
  load_env
fi
if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="0"
fi

if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

if loadfont unicode ; then
  set gfxmode=auto
  load_video
  insmod gfxterm
  set locale_dir=$prefix/locale
  set lang=en_US
  insmod gettext
fi
terminal_input console
terminal_output gfxterm
set timeout=5
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Arch Linux, with Linux core repo kernel' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-core repo kernel-true-26f65140-10c1-4f45-b039-ba077a45005f' {
	load_video
	set gfxpayload=keep
	insmod gzio
	insmod part_msdos 
	insmod ext2
	set root='hd1,msdos2'
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos2 --hint-efi=hd1,msdos2 --hint-baremetal=ahci1,msdos2  d9fdd09f-aa89-40a6-b99b-e4d89f238408
	else
	  search --no-floppy --fs-uuid --set=root d9fdd09f-aa89-40a6-b99b-e4d89f238408
	fi
	echo	'Loading Linux core repo kernel ...'
	linux	/vmlinuz-linux root=/dev/mapper/cryptroot rw  cryptdevice=/dev/sda1:cryptroot rw
	echo	'Loading initial ramdisk ...'
	initrd	/initramfs-linux.img
}
menuentry 'Arch Linux, with Linux core repo kernel (Fallback initramfs)' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-core repo kernel-fallback-26f65140-10c1-4f45-b039-ba077a45005f' {
	load_video
	set gfxpayload=keep
	insmod gzio
	insmod part_msdos 
	insmod ext2
	set root='hd1,msdos2'
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos2 --hint-efi=hd1,msdos2 --hint-baremetal=ahci1,msdos2  d9fdd09f-aa89-40a6-b99b-e4d89f238408
	else
	  search --no-floppy --fs-uuid --set=root d9fdd09f-aa89-40a6-b99b-e4d89f238408
	fi
	echo	'Loading Linux core repo kernel ...'
	linux	/vmlinuz-linux root=/dev/mapper/cryptroot rw  cryptdevice=/dev/sda1:cryptroot rw
	echo	'Loading initial ramdisk ...'
	initrd	/initramfs-linux-fallback.img
}

### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###

### BEGIN /etc/grub.d/60_memtest86+ ###
### END /etc/grub.d/60_memtest86+ ###

Any idea why grub won't try to open the volume? I never get prompted for a passphrase or anything...

Last edited by LeftyAce (2014-01-05 02:00:51)

Offline

#2 2014-01-04 21:22:09

LeftyAce
Member
Registered: 2012-08-18
Posts: 162

Re: [solved] Grub fails to open dm-crypt+luks volume

Not sure if this is the right forum for this, but I've got some more information:

As it boots, I see

:: running early hook [udev]
:: running hook [udev]
:: Triggering uevents...
Waiting 10 seconds for device /dev/mapper/cryptroot ... 

It seems the encrypt hook is not being run at all and should be. Any suggestions on how I can figure out why?

Thanks,

Lefty

Offline

#3 2014-01-04 21:37:16

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: [solved] Grub fails to open dm-crypt+luks volume

LeftyAce wrote:

It seems the encrypt hook is not being run at all and should be. Any suggestions on how I can figure out why?

Why do you think it should be run? Did you add it to /etc/mkinitcpio.conf and regenerate the images?

Offline

#4 2014-01-04 21:58:03

LeftyAce
Member
Registered: 2012-08-18
Posts: 162

Re: [solved] Grub fails to open dm-crypt+luks volume

Thanks for the reply falconindy,

I just double checked, and moved the encrypt hook earlier in the sequence. Now my HOOKS line looks like this:

Hooks="base encrypt udev autodetect modconf block filesystems keyboard fsck shutdown"

The boot sequence now says:

:: running early hook [udev]
:: running hook [encrypt]
Waiting 10 seconds for device /dev/sda2 ...
:: running hook [udev]
:: triggering uevents...
Waiting 10 seconds for device /dev/mapper/cryptroot ...
ERROR: device '/dev/mapper/cryptroot' not found. Skipping fsck.

I am able to open /dev/sda2 using cryptsetup from the prompt I get dumped to.
So it seems the encrypt hook gets run but I don't get prompted?

Does any of that make sense?

Offline

#5 2014-01-04 22:33:22

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: [solved] Grub fails to open dm-crypt+luks volume

Sure. I've no idea why you've moved the encrypt hook before udev. This almost guarantees the device won't exist when the encrypt hook runs.

Offline

#6 2014-01-05 02:00:31

LeftyAce
Member
Registered: 2012-08-18
Posts: 162

Re: [solved] Grub fails to open dm-crypt+luks volume

Thanks, I moved the encrypt hook to right in front of the filesystems hook and it seems to work.

Thanks for the help!

Offline

Board footer

Powered by FluxBB