Skip to content

Recommended partitioning strategy (encryption and btrfs)?

I'm coming to Arch from Ubuntu where I always used to use ext4, LVM, and full-disk encryption on LUKS. It would look like this:

sda                       disk  
├─sda1                    part  /boot
└─sda2                    part  
  └─encrypted (dm-0)      crypt 
    ├─ubuntu-root  (dm-1) lvm   /
    ├─ubuntu-home  (dm-2) lvm   /home
    ├─ubuntu-swap  (dm-3) lvm   [SWAP]
    └─ubuntu-stuff (dm-4) lvm   /stuff

Since I'll be learning a lot about Arch during my transition from Ubuntu, I figure it's a good opportunity to also try btrfs instead of LVM. Also a good time to get ideas on better ways to partition things since I've been doing it the way above for years.

If I still want full-disk encryption, and want swap to continue to be encrypted as well (for security if the memory is persisted to swap during hibernation), what would you recommend?

Would you keep everything identical and just use btrfs subvolumes instead of LVM volumes (if swap can even be a btrfs subvolume), or would you do it differently?

1 points22 comments
Open on Reddit
About this post
Posted
Archived
Score
1 · 100% up
Kind
Text
ID
331wpy

Author

109
posts
183
comments
0
media
View profile

28 comments

My last install involved a plain dm-crypt root with btrfs subvolumes on top of it.

sda1 /boot
sda2 swap
sda3 cryptroot

During the install I took these steps for sda3:

Use cryptsetup to format the partition.
Open the encrypted volume.
Format the volume for btrfs.
Mount the partition to /mnt and cd there.
Create the root subvolume.
Cd out and umount /mnt.
Mount again with the subvol=root option and cd back in.
Create the rest of the subvolumes you want.
Continue install.

I used plain dm-crypt, but you can use that wiki page to setup the volume however you'd like. Also follow the BTRFS wiki. Your boot entry gets a bit complex.

options    root=UUID=[UUID of the btrfs volume /dev/mapper/cryptroot] cryptdevice=UUID=[UUID of the encrypted volume /dev/sda3]:cryptroot rootflags=subvol=root rw quiet blah blah

Ideally you'd just make a swapfile instead of a swap partition, but it doesn't work with btrfs right now. Here is how to use dm-crypt to encrypt your swap partition.

Look over the btrfs mount options. I used rw,noatime,compress=lzo,ssd,space_cache,inode_cache. If you have an SSD you may still want to leave out discard if you are encrypting the entire root volume. You do not want autodefrag on an SSD as there is no performance loss and it only performs unnecessary writes.

2 points

Question:

  • Why are you using inode_cache?
2 points

I um... I need to listen to my own advice and thoroughly read the btrfs options. Ignore that inode_cache and I'll go hide in shame.

1 points

Thanks! Btw on the encrypted swap wiki you linked to, which of the 3 options under 'with suspend to disk' did you go with?

1 points

With his set up, suspend to disk would be a pain in the ass.

Honestly, I'm in the same boat as you. I'm about to redo my laptop's partitions and I can't decide if having btrfs on top of LVM is the best option. It's probably fine, though, but you'll need a separate swap logical volume and then a btrfs logical volume, which can have subvolumes for your partitions.

1 points

I don't use suspend to disk on my system. I really only use the swap as a buffer in case compiling something with a bunch of things open and using /tmp steps over the RAM total. I either shutdown the computer or suspend to RAM, which doesn't require swap.

1 points

I have that setup (btrfs with dm-crypt- no LVM, mbr, no uefi, grub, dual boot, no swap)

sda 8:0 0 238.5G 0 disk

├─sda1 8:1 0 350M 0 part (win boot loader)

├─sda2 8:2 0 90G 0 part (windows8.1)

├─sda3 8:3 0 250M 0 part /boot (->grub)

├─sda4 8:4 0 1K 0 part (logical partition)

├─sda5 8:5 0 140G 0 part

└─crypt 254:0 0 140G 0 crypt /

1 points

No swap, so you don't hibernate your system?

2 points

If you do choose to go the btrfs route, you should note that it does not support swap at this time. You can patch it in apparently, but it does not come out of the box.

1 points

correct - I dont see the advantage of hibernating over suspending to ram.

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.