Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] LUKS+LVM+GPT Initramfs trouble
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
Zazzman
n00b
n00b


Joined: 09 May 2012
Posts: 32

PostPosted: Wed Feb 19, 2014 6:03 pm    Post subject: [SOLVED] LUKS+LVM+GPT Initramfs trouble Reply with quote

I've seen this topic addressed frequently, but not specifically with GPT, and not in any way which presents a single cohesive, direct action. Grub2 and Grub-Legacy both seem able to load the initramfs, which *STOPS* after trying to load the LVM, but before asking for any LUKS key to unlock those partitions - file or password. LILO simply refuses to compile.

So far, I've only managed to use the Genkernel initramfs - I have yet to put together the time it takes to invest the hours/days of manual reading the other solutions seem to demand.

Mkinitramfs-ll looks promising, but where is the g#%d@&^ed manual? "info mkinitramfs" has some useful info, but nothing that could be used to *learn how* to make an initramfs with it.


As for the LVM side:
https://wiki.gentoo.org/wiki/DM-Crypt_LUKS this suggests that I need LVM built with a USE="static" flag to use the initramfs presented - for finally booting on my own!

https://wiki.gentoo.org/wiki/LVM Meanwhile, over here in that package's useflag descriptions, I get a nice big warning not to do that until I'm already booting on my own /boot, no bootstraps involved.


Is there something I'm missing? Is there some kernel configuration that I'm not doing? Is there some other relatively simple option for an initramfs that would work?


Last edited by Zazzman on Thu Feb 20, 2014 6:06 am; edited 1 time in total
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Wed Feb 19, 2014 7:44 pm    Post subject: Re: LUKS+LVM+GPT Initramfs trouble (I know its beaten to dea Reply with quote

Zazzman wrote:
Is there something I'm missing? Is there some kernel configuration that I'm not doing? Is there some other relatively simple option for an initramfs that would work?

Zazzman ... better-initramfs ... IMO its the best availible in terms of initramfs generation. The resulting initramfs.cpio.gz will not need to be rebuilt (as its kernel agnostic and contains no modules) and supports LVM within a LUKS container (and other features such as rescue shell, ssh, swsusp ... using TuxOnIce, raid and UUID disk id).

Code:
# cd /usr/src
# git clone https://bitbucket.org/piotrkarbowski/better-initramfs.git initramfs
# cd initramfs
### optionally edit 'bootstrap/bootstrap-all.conf' to disable unrequired features
# bootstrap/bootstrap-all
# make prepare
# make image
# mount /dev/sda1 /boot
# cp output/initramfs.cpio.gz /boot/

Then all you need do it edit grub.conf, specify the initramfs, and add the following options:

Code:
luks enc_root=/dev/sda2 lvm root=/dev/mapper/vg-root

... assuming 'sda2' is the LUKS volume and 'vg-root' is whatever you've named the root lv.

At boot you will be prompted for the LUKS password for sda2 and once the password is provided the LVM will be setup and boot process passed over to init.

Note that as better-initramfs builds its own lvm2 (using Rob Landley's Aboriginal Linux) you will not need to make the package installed version USE="static".

HTH & best ... khay
Back to top
View user's profile Send private message
Zazzman
n00b
n00b


Joined: 09 May 2012
Posts: 32

PostPosted: Thu Feb 20, 2014 6:11 am    Post subject: Reply with quote

Wow that was easier than I thought it could be!

Why is this not in the portage tree?

using grub2. I have a bios partition on sda1, boot on sda2, and the lvm on sda3.

Here, lemme save a few other users some trouble. Here's my /boot/grub/grub.cfg:
[marked the only line I changed with an arrow, You will need to delete that if you want to copypasta it. Note that /dev/sda1 is mbr partition, /dev/sda2 is /boot, and /dev/sda3 is the encrypted volume group. The 'nomodeset' option is set for the benefit of ati-drivers.]

Code:


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

### BEGIN /etc/grub.d/00_header ###
insmod lvm
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_output gfxterm
if sleep --interruptible 0 ; then
  set timeout=10
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Gentoo GNU/Linux' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-/dev/mapper/vg-root' {
   load_video
   insmod gzio
   insmod part_gpt
   insmod ext2
   set root='hd0,gpt2'
   if [ x$feature_platform_search_hint = xy ]; then
     search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2  e9af842a-4997-4556-af96-41ca70fafa59
   else
     search --no-floppy --fs-uuid --set=root e9af842a-4997-4556-af96-41ca70fafa59
   fi
   echo   'Loading Linux 3.13.3-gentoo ...'
---------------------->   linux   /kernel-3.13.3-gentoo luks enc_root=/dev/sda3 lvm root=/dev/mapper/vg-root nomodeset
   echo   'Loading initial ramdisk ...'
   initrd   /initramfs.cpio.gz
}
submenu 'Advanced options for Gentoo GNU/Linux' $menuentry_id_option 'gnulinux-advanced-/dev/mapper/vg-root' {
   menuentry 'Gentoo GNU/Linux, with Linux 3.13.3-gentoo' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.13.3-gentoo-advanced-/dev/mapper/vg-root' {
      load_video
      insmod gzio
      insmod part_gpt
      insmod ext2
      set root='hd0,gpt2'
      if [ x$feature_platform_search_hint = xy ]; then
        search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2  e9af842a-4997-4556-af96-41ca70fafa59
      else
        search --no-floppy --fs-uuid --set=root e9af842a-4997-4556-af96-41ca70fafa59
      fi
      echo   'Loading Linux 3.13.3-gentoo ...'
      linux   /kernel-3.13.3-gentoo luks enc_root=/dev/sda3 root=/dev/mapper/vg-root ro 
      echo   'Loading initial ramdisk ...'
      initrd  /initramfs.cpio.gz
   }
   menuentry 'Gentoo GNU/Linux, with Linux 3.13.3-gentoo (recovery mode)' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.13.3-gentoo-recovery-/dev/mapper/vg-root' {
      load_video
      insmod gzio
      insmod part_gpt
      insmod ext2
      set root='hd0,gpt2'
      if [ x$feature_platform_search_hint = xy ]; then
        search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2  e9af842a-4997-4556-af96-41ca70fafa59
      else
        search --no-floppy --fs-uuid --set=root e9af842a-4997-4556-af96-41ca70fafa59
      fi
      echo   'Loading Linux 3.13.3-gentoo ...'
      linux   /kernel-3.13.3-gentoo luks enc_root=/dev/sda2 lvm root=/dev/mapper/vg-root ro single
      echo   'Loading initial ramdisk ...'
      initrd  /initramfs.cpio.gz
   }
}

### 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 ###




Last edited by Zazzman on Thu Feb 27, 2014 5:42 am; edited 2 times in total
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Thu Feb 20, 2014 10:57 am    Post subject: Reply with quote

Zazzman wrote:
Why is this not in the portage tree?

Zazzman ... I couldn't say, the developer, slashbeast, is infact a gentoo dev.

I'm not sure that there is any real benefit from it being package managed as its a build-system in itself (with sources pulled to its 'bootstrap/distfiles', etc). It doesn't make sense to manage versions as the distfiles, sourceroot, and output, would end up duplicated, and/or being left orphaned when updated.

If you want to update you can run 'git pull' in the repository, but it doesn't recieve much in the way of changes (not due to it being unworked on, but from the lack of necessity).

best ... khay
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum