Skip to content

Instantly share code, notes, and snippets.

@edouard-lopez
Last active May 31, 2018 09:27
Show Gist options
  • Save edouard-lopez/00aa05913dbb473cb64b to your computer and use it in GitHub Desktop.
Save edouard-lopez/00aa05913dbb473cb64b to your computer and use it in GitHub Desktop.
sudo cryptsetup luksOpen /dev/sda5 luks_container
sudo lvdisplay
--- Logical volume ---
LV Path /dev/mint-vg/root
LV Name root
VG Name mint-vg
LV UUID ZXld2t-7wOU-Vw5p-4h4Q-w8is-yhCf-z7hLX2
LV Write Access read/write
LV Creation host, time mint, 2014-05-22 00:01:06 +0000
LV Status available
# open 0
LV Size 8.55 GiB
Current LE 2188
Segments 3
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:1
--- Logical volume ---
LV Path /dev/mint-vg/home
LV Name home
VG Name mint-vg
LV UUID 89jWuf-uKik-4JDF-BJUp-GbyM-UPje-WyotAG
LV Write Access read/write
LV Creation host, time mint, 2014-05-22 00:53:52 +0000
LV Status available
# open 0
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:2
--- Logical volume ---
LV Path /dev/mint-vg/data
LV Name data
VG Name mint-vg
LV UUID 1P2oWP-WEmN-2tKD-wkfh-GAlC-iCWv-XPTL3b
LV Write Access read/write
LV Creation host, time mint, 2014-05-22 00:55:13 +0000
LV Status available
# open 0
LV Size 100.00 GiB
Current LE 25600
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:3
--- Logical volume ---
LV Path /dev/mint-vg/swap
LV Name swap
VG Name mint-vg
LV UUID HfQVJv-giT3-81W1-JJdY-kM4l-19uI-DVAlIX
LV Write Access read/write
LV Creation host, time mint, 2014-05-31 19:47:33 +0000
LV Status available
# open 0
LV Size 1.00 GiB
Current LE 256
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:4
sudo blkid /dev/sda5
# /dev/sda5: UUID="db83deac-8302-47f0-804b-fb2b95f2b8fc" TYPE="crypto_LUKS"
# http://www.webupd8.org/2014/01/how-to-fix-non-bootable-ubuntu-system.html
sudo mkdir /mnt/
sudo mount /dev/mint-vg/root /mnt
# # # following command is CRITICAL! Otherwise you won't edit the correct config file
sudo mount /dev/sda1 /mnt/boot
# ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
sudo mount /dev/mint-vg/home /mnt/home
for p in /sys /proc /run /dev /dev/pts; do sudo mount --bind "$p" "/mnt$p"; done
sudo cp /etc/resolv.conf /mnt/etc/
sudo chroot /mnt
# create: nano /etc/crypttab
# <target name> <source device> <key file> <options>
luks_container UUID=db83deac-8302-47f0-804b-fb2b95f2b8fc none luks,retry=1,lvm=mint-vg
# create: nano /etc/initramfs-tools/conf.d/cryptroot
#CRYPTROOT=target=luks_container,source=/dev/disk/by-uuid/db83deac-8302-47f0-804b-fb2b95f2b8fc
CRYPTROOT=target=luks_container,source=/dev/disk/by-uuid/db83deac-8302-47f0-804b-fb2b95f2b8fc,lvm=mint-vg
# see http://ubuntuforums.org/showthread.php?t=2222993
# in /etc/initramfs-tools/modules add f
update-initramfs -k all -c
# set GRUB_CMDLINE_LINUX in : nano /etc/default/grub
GRUB_CMDLINE_LINUX="cryptopts=target=luks_container,source=/dev/disk/by-uuid/db83deac-8302-47f0-804b-fb2b95f2b8fc,lvm=mint-vg"
# or try (working on Linux Mint 17.2)
GRUB_CMDLINE_LINUX="cryptopts=target=luks_system,source=/dev/disk/by-uuid/db83deac-8302-47f0-804b-fb2b95f2b8fc,lvm=mint-vg"
update-grub
# if you got the following error, try:
# /usr/sbin/grub-mkconfig: 250: /usr/sbin/grub-mkconfig: cannot create /boot/grub/grub.cfg.new: Directory nonexistent
grub-install /dev/sda; update-grub
# If you got trouble with grub try re-creating the grub.cfg file,
# see http://edoceo.com/notabene/grub-probe-error-cannot-find-device-for-root
sh -x /usr/sbin/grub-mkconfig -o /boot/grub/grub.cfg
@ad-m
Copy link

ad-m commented Jan 26, 2016

@edouard-lopez, 07a.grub is redundant if 05.cryptroot done.
In 07a.grub you should use target=luks_container.

@ad-m
Copy link

ad-m commented Jan 26, 2016

I want mark ubuntu 15.10 doesn't support partitioned lvm with swap, because graphic installator crash. I recommend use ubuntu 14.04.3 ( http://releases.ubuntu.com/14.04.3/ ) and upgrade.

@edouard-lopez
Copy link
Author

Thanks @ad-m, I edited following your comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment