You are not logged in.

#1 2012-08-08 14:35:40

lynix
Member
From: Karlsruhe, Germany
Registered: 2008-04-23
Posts: 230

How to mount encrypted multi-device BTRFS-volumes using systemd?

I recently switched to systemd and have some issues with a multi-device (raid1) btrfs volume.

My fstab contains this line for the volume:

/dev/mapper/archive1	/mnt/archive	btrfs	device=/dev/mapper/archive1,device=/dev/mapper/archive2,device=/dev/mapper/archive3,device=/dev/mapper/archive4,defaults,noatime,nodiratime	0 0

As you can see, the volume consits of four LUKS mapper devices, which must all be present for the volume to be mounted.
The problem now is that systemd doesn't recognize the dependency for my volume to all four crypto mappers. It tries to mount the volume as soon as /dev/mapper/archive1 is in place, which fails very often.

So how do I manually set the dependency? I tried adding cryptsetup.target to /etc/systemd/system/local-fs.target.wants without success.


Thanks

lynix

Offline

#2 2012-08-08 20:53:09

tomegun
Developer
From: France
Registered: 2010-05-28
Posts: 661

Re: How to mount encrypted multi-device BTRFS-volumes using systemd?

With the most recent btrfs-utils package, this should in theory "just work". However, I believe there is a kmod bug that means that we are not correctly auto-assembling btrfs devices.

Offline

#3 2012-08-08 20:58:13

lynix
Member
From: Karlsruhe, Germany
Registered: 2008-04-23
Posts: 230

Re: How to mount encrypted multi-device BTRFS-volumes using systemd?

tomegun wrote:

With the most recent btrfs-utils package, this should in theory "just work".

I don't see a package named "btrfs-utils", did you mean "btrfs-progs"? I'm using version 0.19.20120328-4 of that package.

I'm thinking about writing a .mount file for the volume in question, or simply fix it quick'n'dirty by adding a manual mount in rc.local...

Offline

#4 2012-08-08 22:05:14

tomegun
Developer
From: France
Registered: 2010-05-28
Posts: 661

Re: How to mount encrypted multi-device BTRFS-volumes using systemd?

I meant btrfs-progs yes, but I see now that the bug I have in mind is probably a different one. It would be worthwhile to try making a custom .mount unit and see if that fixes your issue. If it does, we should probably improve the upstream fstab parsing code to deal with this case.

Offline

#5 2012-08-09 20:10:03

lynix
Member
From: Karlsruhe, Germany
Registered: 2008-04-23
Posts: 230

Re: How to mount encrypted multi-device BTRFS-volumes using systemd?

I found the time to write the custom .mount file and it seems to fix the issue, indeed smile

[Unit]
Description=/mnt/archive
Wants=cryptsetup.target
After=cryptsetup.target

[Mount]
What=/dev/mapper/archive1
Where=/mnt/archive
Type=btrfs
Options=defaults,noatime,nodiratime

The mount point in question is still listed in my /etc/fstab, the .mount file takes precedence like stated in `man systemd.mount`.

Offline

Board footer

Powered by FluxBB