HOWTO - GPT/UEFI install with full disk encryption: BTRFSonLUKS with separate root, home and pkg subvolumes; hibernation with a swapfile; auto-snapshots with easy system rollback (GUI); boot into snapshots

This works! However, RAID1 works only if you disable the swapfile as btrfs-RAID1 is not compatible with swapfiles. So instead one creates an encrypted swap partition and adds this line to the /etc/crypttab:
cryptswap UUID=${UUIDOFSWAPPARTITION} /dev/urandom swap,offset=1024,cipher=aes-xts-plain64,size=512
and this one to /etc/fstab:

/dev/mapper/cryptswap  none  swap  defaults  0  0

I plan to make a video on this soon (similar to my guides and videos for Pop!_OS) and will post them here: https://mutschler.eu/linux/install-guides/

2 Likes

I changed the post above with the steps to set up RAID1 that work for me on Manjaro. If you want to only have one prompt for the pass-phrase you should create an encrypted partition for boot (without RAID1) and a btrfs-raid1 for the root filesystem which are then both unlocked using keyfiles. Either way, works nicely. Hope to have the videos and guide up this week on my homepage.

Hi @2000,

A newbie question:

Is it possible to have the same setup without encrypted root partition ? If so, what changes to the scripts need to be made?

I do not have a need to encrypt the root partition but is interested in the ability to quickly get back to a snapshot on a btrfs file system.

Thanks in advance,
-Newt

If you ever have the need, it probably is too late. :wink:


Well. if you really insist on not encrypting, :cry: the following should work.

Follow steps #01 to #05 but adjust like described below:

#03
Don’t choose ‘Encrypt’. :grinning:

#05

btrfsonluks=`sudo blkid -o device | grep luks`

automatically assigns the encrypted partition to the variable ‘btrfsonluks’. You won’t have this device, so
you’ll have to set the variable manually to your btrfs partition, e. g. /dev/sda2, like this

btrfsonluks=/dev/sda2

Continue with
V-09
V-10

Then you can optionally continue with step #06, beginning with where it says
max_snapshots=13

followed by #07 (optional)

Done!


Off-topic: Why one wouldn’t choose to encrypt their data is beyond me; :thinking:. You won’t notice it performance-wise and you’ll just have to enter a single password once at boot. If a device is lost, stolen or confiscated by law enforcement you can rest assured that your or your companies data is secure as long as you chose a secure password.

@2000
Appreciate your quick respond to my post.

By the way, this is for an old cheapo laptop that I plan to use at home only as a media player for my TV, thus it does not have any sensitive data on it. A few days ago, it did not reboot properly after a system update and I had to reinstall EOS, but with your setup, I guess I no longer need to reinstall :grin:.

For my other laptop of course I will follow your full HOWTO to make it secure with full encryption.
Thanks!

@nhutnn
Hope the modified steps work. If not, just post the error message(s) and I’ll try to work out where I got it wrong.

2 Likes

@2000

Success!!! :smile:
I completed the modified HOWTO successfully and confirmed that Timeshift (btrfs) is working on my old laptop.

Really appreciate your help and creating of this wonderful HOWTO.
Thanks!

3 Likes

I’m trying not to get my hopes up too high, however having that said…
99% of everything I just read in this post made complete sense to me, so I think I may actually be learning a thing or two (finally) about how filesystems work, or at least, how btrfs works.

1 Like

Hi there,

I tried a new install following your excellent guide with the current iso from July, but the resume parameter missed in the resulting grub. There was only the resume_offset parameter.

Christoph

Thanks for letting me know! I’ll have a look into it.

Sadly, I won’t be able to check the July iso until the end of next week as I’m currently on vacation in Paris and my partner is enforcing a strict “no quick problem solving” regime … :roll_eyes:

As a quick fix it should suffice to add the following line

sudo sed -i "s#loglevel=3#resume=$btrfsonluks loglevel=3#" /mnt/btrfs/@/etc/default/grub

before or after

sudo sed -i "s/loglevel=3/loglevel=3 resume_offset=$offset/" /mnt/btrfs/@/etc/default/grub

in #05 of the first post, if the resume partition isn’t added automatically anymore.

1 Like

You should stick to this :sunglasses:. Vacation is vacation especially in those strange times.

I added the resume manually, but I will try your suggestion on the next Install.

Have a good time in Paris,

Christoph

2 Likes

Hmmm, sounds familiar somehow… :thinking: :rofl:

3 Likes

I’m going to try it the encrypted way, what about other devices in the machine though? I have a data drive that holds my videos and music which I symlink to /home. Should I be using BTRFS for that as well and if so, how would I go about encrypting it as I don’t want to have to enter a password everytime I want to play a song from the drive?

Thanks in advance

You can unlock additional encrypted devices/partitions automatically during boot. These partitions need to be LUKS (dm-crypt) encrypted and can contain the filesystem of your choice (ext4, btrfs, zfs, …); so they needn’t be btrfs.

Note that you can’t encrypt a device while keeping it’s data. You would have to

  1. backup your existing data partitions files
  2. create/encrypt your data partition
  3. choose a filesystem (e. g. ext4) and format
  4. (re-)copy your backuped files to the encrypted partition

To have the partition automatically unlock during boot you could

  1. create a random key-file stored on your encrypted /root
  2. add this keyfile as a second password to your encrypted data partition
  3. create a mapper in /etc/crypttab that can then be referenced in the fstab
  4. mount the device in fstab (you could mount-bind or try a symlink like before)

This way you would only be asked for your encrypted root devices password once at boot and your data partition would be automatically “chain-unlocked” by the system.
You could still access your encrypted data device manually with the password you chose during creation, if you ever need to (e. g. data device is an external usb-drive and you plug it into another linux system).

If you need help in setting this up, feel free to ask.

1 Like

@2000
I followed your guide here to try this as i don’t have any experience setting this up. I never bothered with it before as i found it to be just a little too involved. This does make it easy but not saying i understand all the ins and outs of it. :grin:

Anyway it shows no device for hibernation. I guess you have to set that up too? If i run hibernation it shuts off and its just a normal start up. I’m only doing this to try to understand it a bit. The encryption takes too long to decrypt on boot i find.

Edit: What is the difference with the verbose mode?

Yes, @csteinforth already noticed this in post #49. The July ISO doesn’t seem to add the resume device automatically anymore.

Quick fix if you haven’t installed yet: see post #50

Quick fix if you already installed EOS following the above guide:

  1. get resume device info
    sudo blkid -o device | grep luks
    ( e. g. /dev/mapper/luks-7cb97d17-7dbc-44a1-831f-af49012345d7

  2. add this resume device (resume=) to /etc/default/grub
    GRUB_CMDLINE_LINUX_DEFAULT="[...] resume=/dev/mapper/luks-7cb97d17-7dbc-44a1-831f-af49012345d7 resume_offset=[...]"

  3. update grub
    sudo grub-mkconfig -o /boot/grub/grub.cfg


No difference, just a bit more information on what all those commands you copy & paste in the shorter version do.

This is one of the caveats to having an encrypted /boot. At this early in the boot process Grub takes its time to decrypt the root partition to get to the initramfs and kernel. This can’t be sped up AFAIK.


(Sort of) Off-topic question for @moderators:
The initial post being to old for me to edit, what would be the best way to update the guide so that users not reading 50+ posts get a working version? (Once I have the time to figure out what is actually going wrong, that is.)
If an edit isn’t possible a moderator could at least maybe flag the initial post as obsolete/outdated etc. This would be less frustrating for people not reading the whole thread.

You should be able to edit it by clicking the … symbol for show more and then the edit symbol which is a pencil.

Edit: Already had it installed so i will try to fix this. What is the offset=[ ] What do i put in there?

Edit2: Tried this and still the same so obviously i didn’t do it properly!

@2000
I put it at the end of this line?

GRUB_CMDLINE_LINUX_DEFAULT=“quiet cryptdevice=UUID=c2711aa5-335d-45c6-ad4a-613eecc21422:luks-c2711aa5-335d-45c6-ad4a-613eecc21422 root=/dev/mapper/luks-c2711aa5-335d-45c6-ad4a-613eecc21422 loglevel=3 resume_offset=1840384 /dev/mapper/luks-c2711aa5-335d-45c6-ad4a-613eecc21422 nowatchdog”

No pencil for the initial post. I assume the forum software doesn’t allow editing a post after a certain time. That’s why I was asking how to address this issue.

I assumed the resume-offset was already correctly added to /etc/default/grub.
If not, this wiki entry describes how to get the resume-offset for btrfs.


For reference, here is my /etc/default/grub entry:
GRUB_CMDLINE_LINUX_DEFAULT="cryptdevice=UUID=7cb97d99-7dbc-44a1-831f-af49044855d7:luks-7cb97d99-7dbc-44a1-831f-af49044855d7:allow-discards root=/dev/mapper/luks-7cb97d17-7dbc-44a1-831f-af49041234d7 resume=/dev/mapper/luks-7cb97d17-7dbc-44a1-831f-af49041234d7 loglevel=3 resume_offset=2626816 nowatchdog"


Your entry should be something like
GRUB_CMDLINE_LINUX_DEFAULT="quiet cryptdevice=UUID=c2711aa5-335d-45c6-ad4a-613eecc21422:luks-c2711aa5-335d-45c6-ad4a-613eecc21422 root=/dev/mapper/luks-c2711aa5-335d-45c6-ad4a-613eecc21422 resume=/dev/mapper/luks-c2711aa5-335d-45c6-ad4a-613eecc21422 loglevel=3 resume_offset=1840384"