Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Installing Gentoo
  • Search

btrfs raid1 with luks encryption

Having problems with the Gentoo Handbook? If you're still working your way through it, or just need some info before you start your install, this is the place. All other questions go elsewhere.
Post Reply
Advanced search
9 posts • Page 1 of 1
Author
Message
duxsco
n00b
n00b
Posts: 45
Joined: Sat Jun 05, 2010 6:48 am

btrfs raid1 with luks encryption

  • Quote

Post by duxsco » Tue Jul 28, 2015 3:48 pm

Hi.
I wish to have the following setup:

Code: Select all

/dev/sda1: mdadm ___
                    \
                     |---> /dev/md0 (raid1) -> ext4 -> /boot
/dev/sdb1: mdadm ___/


/dev/sda2: mdadm ___
                    \
                     |---> /dev/md1 (raid1) -> luks -> swap
/dev/sdb2: mdadm ___/

/dev/sda3: luks ---> /dev/mapper/root   ---> btrfs raid 1 parition  ___
                                                                       \
                                                                        |---> btrfs raid1 ---> /
/dev/sdb3: luks ---> /dev/mapper/root2 ---> btrfs raid 1 partition  ___/
I couldn't find a way to specify two or more encrypted root partitions in "/etc/default/grub" with "crypt_root=" in order to get a password prompt for each of them upon boot or unlock them with a keyfile. Arch Linux supports this with minor changes to two files (https://wiki.archlinux.org/index.php/Dm ... partitions). Is there a way to realise this on Gentoo Linux? I want to use the btrfs raid functionality in order to cope with badblocks. Afaik, btrfs handles them better than mdadm.

Best regards,
onndsd
Top
frostschutz
Advocate
Advocate
User avatar
Posts: 2978
Joined: Tue Feb 22, 2005 11:23 am
Location: Germany

  • Quote

Post by frostschutz » Tue Jul 28, 2015 5:28 pm

Using LUKS below RAID means encrypting everything twice.
Top
duxsco
n00b
n00b
Posts: 45
Joined: Sat Jun 05, 2010 6:48 am

  • Quote

Post by duxsco » Tue Jul 28, 2015 6:35 pm

I have AES-NI and fault tolerance is more important for me than some loss of performance. If one block has gone bad, btrfs recovers by using the healthy block from the other hard drive upon read time. Afaik, mdadm doesn't store checksums on data and metadata like btrfs does (https://btrfs.wiki.kernel.org/index.php ... rfs_use.3F).
Top
trubicoid
Tux's lil' helper
Tux's lil' helper
Posts: 86
Joined: Tue Aug 04, 2009 6:42 pm

  • Quote

Post by trubicoid » Mon Mar 28, 2016 6:51 pm

any news with this particular setup onndsd?
I think the easiest solution would be a custom script in initrd, which decrypts the two partitions.
Top
astroe
n00b
n00b
Posts: 17
Joined: Thu Aug 12, 2004 10:10 am
Location: Bucharest, Romania

  • Quote

Post by astroe » Tue Mar 29, 2016 7:38 am

I have a simpler setup, with just encrypted drives, no RAID. I have dmcrypt added to the boot runlevel. In /etc/conf.d/dmcrypt I specified which drive maps to which logical name and it asks for all the passwords during booting.
Top
duxsco
n00b
n00b
Posts: 45
Joined: Sat Jun 05, 2010 6:48 am

  • Quote

Post by duxsco » Fri Apr 01, 2016 10:40 am

I couldn't find a solution. If you have both a SSD and HDD, you can use the SSD hardware encryption and LUKS on HDD. Then, mirror boot, root etc. over both drives. Unfortunately, btrfs doesn't support the "--write-mostly" option, known from mdadm. Or, you patch the bootup files like astroe.
Top
davidm
Guru
Guru
User avatar
Posts: 557
Joined: Sun Apr 26, 2009 4:05 pm
Location: US

Re: btrfs raid1 with luks encryption

  • Quote

Post by davidm » Sun Apr 03, 2016 8:30 pm

onndsd wrote: I couldn't find a way to specify two or more encrypted root partitions in "/etc/default/grub" with "crypt_root=" in order to get a password prompt for each of them upon boot or unlock them with a keyfile.
I know this is an old post but I know usually with grub I just specified one of the drives and then it figured out the rest. This was unencrypted. When I moved to LUKS in encryption I actually used a separate boot along with a separate / partition which was on ext4 (new hdd) so I can't say I have experience exactly with that however (with systemd) when I booted it would prompt me for the passwords to the other drives when I tried to mount the separate btrfs volume. Of course this happened beyond GRUB, probably because of the contents of my /etc/fstab and perhaps /etc/crypttab

I think anyone trying this is probably going to have to bite the bullet and do a separate /boot partition although you could probably encrypt that with LUKS as I believe grub2 can handle that -- only on one disk though and not over multiple volumes with LUKS.

Alternately before giving up you might try specifying one of the drives in the LUKS btrfs array to see if it can automatically figure it out based on that. I take it something like crypt_root=/dev/sda,/dev/sdb,dev/sdc won't work? You might try asking one of the Grub2 developers or perhaps doing a feature request if this is really unimplemented.

Hopefully this helps someone searching.
Top
rini17
n00b
n00b
Posts: 25
Joined: Wed Jan 04, 2006 9:59 pm
Location: Bratislava, Slovakia
Contact:
Contact rini17
Website

  • Quote

Post by rini17 » Wed May 11, 2016 5:33 pm

I have similar setup (btrfs raid1 on LUKS devices with separate unencrypted /boot on ext4). Every boot I am currently mounting the encrypted devices by hand in initramfs shell (I drop into busybox shell, run cryptsetup luksOpen + btrfs dev scan, then resume normal startup). If you configure genkernel to include busybox, btrfs and luks support, all needed tools to do so will get installed there.

I have looked into genkernel initramfs scripts so that above can be done automatically but fixing these is not trivial, as the functions use global variables like CRYPT_ROOT :roll: They can't simply be called multiple times with multiple devices.
Top
E14n
n00b
n00b
Posts: 1
Joined: Fri Jul 17, 2020 12:57 pm

genkernel patch to support btrfs raid on luks

  • Quote

Post by E14n » Fri Jul 17, 2020 1:07 pm

I have posted a patch[1] for genkernel that allows its initramfs to load multiple luks encrypted volumes on boot. This will allow you to use btrfs raid on luks encrypted block devices. The patch uses the crypt_roots command line flag to mark the devices.

1. https://bugs.gentoo.org/694778
Top
Post Reply

9 posts • Page 1 of 1

Return to “Installing Gentoo”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic