Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Problems mounting btrfs subvolumes within a dm_crypt volume
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
jbiggs12
n00b
n00b


Joined: 09 Mar 2012
Posts: 29

PostPosted: Wed Aug 01, 2012 4:14 am    Post subject: Problems mounting btrfs subvolumes within a dm_crypt volume Reply with quote

Hello all,

I've installed gentoo, and unfortunately I'm having a bit of a problem with dm_crypt. Within the dm_crypt volume is a btrfs filesystem with 3 subvolumes: one for /, one for /var, and one for /home. In my custom initramfs I have the line:
Code:
mount -o ro,subvol=root /dev/mapper/crypt /mnt/root

Which works just fine with mounting the filesystem, however, once I've booted it I notice that when I try to touch anything within /var, I get a "read-only filesystem" error. This goes away when I run
Code:
mount -o remount,rw /var

But then when I try to mount /home with
Code:
mount -o subvol=home /dev/mapper/crypt /home

it tells me that the device node /dev/mapper/crypt doesn't exist, and, sure enough, when I run "ls /dev/mapper", all I see is "control." Which makes no sense, because when I run "df", it clearly says that / and /var are mounted on /dev/mapper/crypt.

What is going on? :oops:
Back to top
View user's profile Send private message
wildbug
n00b
n00b


Joined: 07 Oct 2007
Posts: 73

PostPosted: Wed Aug 08, 2012 7:17 pm    Post subject: Reply with quote

I came here looking to solve exactly the same problem. I can't solve it, but I think I can explain it.

In your initramfs, when you mount your dm-crypt volume, it's mounted under /dev/mapper/crypt; this is your btrfs root (subvolid=0). You mount your system root subvolume (subvol=root) at /mnt/root, and presumably issue something like "switch_root /mnt/root /sbin/init" at the end of your initramfs init script. switch_root puts your /mnt/root over the current /, masking it and also masking the /dev/mapper/crypt mountpoint, which is why you can't see it once your system's up.

Is there any way to access the btrfs root volume after switch_root masks /dev/mapper?

I suppose you could mount other filesystems on mountpoints under your root in initramfs before switch_root, but that seems wrong, and I'd like to optionally mount the btrfs root instead of always having it available.
Back to top
View user's profile Send private message
wildbug
n00b
n00b


Joined: 07 Oct 2007
Posts: 73

PostPosted: Wed Aug 08, 2012 8:14 pm    Post subject: Solved Reply with quote

Using devtmpfs instead of busybox's mdev solves this for me. You'll need to compile it into your kernel (CONFIG_DEVTMPFS under Device Drivers > Generic Driver Options) and mount it with "mount -t devtmpfs none /dev" in your initramf's /init script.
Back to top
View user's profile Send private message
jbiggs12
n00b
n00b


Joined: 09 Mar 2012
Posts: 29

PostPosted: Wed Aug 08, 2012 9:16 pm    Post subject: Reply with quote

Well hate to burst your bubbles but I got impatient after nobody replied, gave up, and now have a different setup. Instead of having a separate subvolume for the root directory, I made /var, /usr, and /home all subvolumes within the main one and simply mounted subvolid 0, addressing all of the subvolumes as folders.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum