-
Notifications
You must be signed in to change notification settings - Fork 567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider changing the BTRFS subvolume layout #781
Comments
Thank you for this very detailed feedback! Really awesome to see everyone suggesting good things to improve the btrfs subvolume support. We'll track it in this issue and in #718 where the topic came up during an issue of re-using btrfs subvolumes that was anything other than what we supply. |
@KhalilSantana Great explanation for what i also do empirically, With a slightly different layout (i don't care -still- for snapshooting but more for usage flexibility. At the end of issue #718 you will find an unoffical patch that allows archinstall to work with flat layouts IF they are defined and mounted previously. I would be glad i could have some feedback about it. I could make a PR of it, but i'm not that sure of its quality (works for me, but this is what i can guarantee). |
It's coming in a bit : ) Gathering my thoughts to not just blurp out unfinished thoughts :) |
This is definitely important. Btrfs is a bit of a pain to remember how to use when doing the arch install "the old way", and one of my main reasons to use EndeavourOS right now. |
Just to put it out there as well, why not go with opensuse's layout, so that snapper can be fully utilized? Timeshift works, but the last time I tested it, it left like it lacked alot that Snapper has; rolling back with snapper is as easy as booting a snapshot of your working system, and running From https://en.opensuse.org/SDB:BTRFS
What this ends up looking like (with the top-level subvolume mounted at /btrfs)
Putting the root subvolume in .snapshots makes using snapshots much cleaner, as the original root subvolume is essentially a snapshot, so what happens after you boot into a read-only snapshot and run It is more complicated to wrap your head around to begin with, but once you understand it, it makes way more sense. If it helps make it understandable at all, I just finished fixing a (janky) script that installs arch with this layout (albeit with a lot of separation of /var) https://github.com/ShaunTheQuietGamer/Arch-Setup-Script/blob/main/install.sh EDIT: I didn't fully understand how this whole thing worked, and still probably don't, but isn't it theoretically possible to add both layouts as an option for users? Instead of it asking Yes or No if they want a default subvolume layout, it could ask if they
(Something else to look at is possibly adding an extra Y/N if the Opensuse layout is selected to also install and set up snapper, grub-btrfs, and snap-pac with |
Before we close this, and you'll have to correct me if I'm wrong because there's almost too much context here so I might have gotten a bit lost in all the reading. But the desired outcome is:
Which we currently can't support because we don't support a mountpoint ( If we can live without mountpoints inside subvlumes, this issue is fulfilled. Otherwise I'll keep this open but I'll move it for |
With the code just merged you can create almost any setup you can imagine (most of them dead wrong). Subvolume hierachy and File System hierachies can (and should be) totally distinct. The only things to take care are:
|
Commenting a little bit on @ShaunTheQuietGamer's layout:
I also do this on my system, but omitted from my original proposal for KISS principles, but it's a pretty sound suggestion in my opinion.
While I can understand the point you are making, I also think this is somewhat of a foot gun: applications seldom exist within a vacuum, they have dependencies that may be scattered elsewhere on the filesystem, thus rolling back the rootfs without also rolling back these may not lead to a working (read: consistent) set of packages. And yes, one could configure snapper to also snapshot this in sync with the rootfs subvol, then figure out a way to rollback from that (either manually, or via snapper itself somehow??), but that feels like overcomplicating things.
I'm not sure what openSUSE does with /tmp, but on ArchLinux,
I don't fully understand how Archlinux package manager (libalpm) works, but I believe it uses If my understanding is correct, splitting the entire /var into a subvol should be avoided, as it would break pacman each and every time you rollback. -- Regarding CoW vs no-CoW I also disagree,
Those are very big downsides which should be decided on a per-application basis, either by the user or by the application itself, not a blanket disable on the entire /var directory. |
(To Khalil) Your points make total sense, I see no issue with modifying the layout to work better with arch, every distro is different and is going to require different things. I guess I should specify/have specified that it was more that I think it's worth looking at opensuse's layout to see if anything they are doing would makes sense to add for the (or one of the) defaults for arch. I think the only thing that is absolutely required (subvolume wise) for snapper is for the original root be mounted in /@/.snapshots/1/snapshot, having .snapshots mounted at /@/.snapshots may also be required. Speaking as the one that's not having to do any of the work, (you or others may have a different opinion as the ones actually implemented this,) I would think is important to give choices. Rather than have the only default option be timeshift, give the choice between the two (or a totally manual layout, obviously.) Part of the problem with choosing one over the other is that, for snapper at least, you have to modify some configs during the installation to make it function correctly. (Setting an option to true in grub, modifying fstab to not force /@/.snapshots/1/snapshot to be mounted, and instead tell it to mount the default subvolume, etc.) |
I really suck at explaining things, and snapper doesn't have nearly enough documentation on the required layout...
just for the sake of clarity from here down, Actually, I think I might have an analogy. Think of each of the subvolumes as physical disks on a normal system within Anyways, the filesystem root is mounted as @/.snapshots/1/snapshots (1 is just a folder in the @/.snapshsots subvolume,) because it is essentially the first snapshot of the system. When you cd into @/.snapshots/1/snapshots its your current filesystem. The next snapshot that is created is @/.snapshots/2/snapshot/ and if you cd into it, its a copy, a snapshot, of a root filesystem. |
This looks pretty similar to what we got with the exception of the root subvolume not being mounted and a separate |
Happy New Year to all !
The sad true is that most of us lack, for the time being, serious experience with Btrfs and the impact of alternatives. At least, since yesterday, when PR #787 was merged we can play the different alternatives on "real metal" (well, VMs) with easy - if you don't mind editing json files. If you read the comments there, we have tried to document what and how it can do it. Let's play for a while before taking some decision (and try to involve in the discussion the more wide Archlinux communiy) |
I think this might be a good idea. |
Sounds good to me. I've kind of been creating a mental image of how I was thinking i'd set up the configuration menus for subvolumes and snapshots. I'm almost certainly getting ahead of myself (and everything else,) but I though I would but it out there regardless. This is once again coming from someone that doesn't know how to do the work, or the standards/rules being followed, so I'm sure changes/tweaks would be necessary, if you all think it fits into the scope of this installer at all. First it would ask what layout the user wants
The the manual configuration would again be similar to the manual configuration for partitions. If 1 or 2 are selected, there could be a yes/no question for people to manually adjust the layout for certain use-cases as @wllacer outlined.
If yes, it would go into the same manual configuration menu as selecting 3 in the prior step, but with the previously selected layout already configured. ( After This is where i'm thinking it might start to get away from the scope of the installer. ) After either skipping manual adjustment, or finishing it, then it would have another Yes/No pulling the user input from the first question
and then if no, it just moves on to the next step of the install, if yes it sets up timeshift or snapper, (this is were I might actually be able to help with the snapper configuration, as its not just installing the package, you have to change some configs for snapper to fully function.) |
We could have this menu instead of the "Do you want to use subvolumes?" as this one packs more information but would add no additional steps. |
Hi, just a quick question, why |
It's probably to strictly snapshot package states, for easier rollbacks or to use snapper (etc) to snapshot a point in time of a package store. For instance a stable snapshot when you knew packages were working, and you could (wild pseudo commands to follow) do something like |
Anything in the subvolume is not included in snapshots... that will be true, whether the subvol is |
Then I've got it backwards. I for sure would rather like to have it included in snapshots. Or at least I looked at it as a great way to take snapshots of known states :) But I guess then again, you could just snapshot your installation folders instead and store the known states there.. But then you'd might lose data if they're stored alongside the binaries etc, then those snapshotted installation packages would come in handy for a rollback. Anyway, that's why I thought peopled wanted that subvolume :) |
I think the installed state is in
They don't need to be backed up. |
Btrfs snapshot stops at the subvolume boundary, so putting By excluding Regarding |
I agree it doesn't add too much, but it still adds a little and makes it simpler at the same time, that's why I don't really see any reason not to use it instead of
It's a little off-topic so feel free to ignore, but in which scenario would you re-download the same installers for packages which are most likely still installed ? I struggle to understand why the usage is to keep so much cached packages, if I install something I most likely want to download the latest version, and if I uninstall something I'm unlikely to change my mind and install it again. Back to the topic, is any thought given to suggesting a subvolume layout for @home ? There are also good candidates for excluding from snapshots, like |
@clavelc
It depends on the user really. If someone's building a "golden image" of their Arch install, perhaps they'll want to test multiple drivers/settings before committing to it, so the user builds their install step-by-step using snapshots as checkpoints. Creating this "golden image" might take several attempts before figuring out which exact packages are required, which ones are bloat, and which settings or quirks to apply due to their hardware. So having an unchanging |
My original proposal was rather simple, but as everyone is suggesting their own (more advanced/sophisticated) layouts, I'll dabble a bit on my own more featured layout, mostly for my own uses, but I'll try to make an effort to make this cover as many use cases as I can. (I'll also edit this comment as ideas come along). I'll also use a table to make this more readable. The priority column is how much I care about that particular choice, or how much I think it's going to matter for users of specific software.
EDIT-0: Added the EDIT-1: Changed the |
@ShaunTheQuietGamer
Consider using "toplevel" or "subvolid=5" to describe filesystem root of all roots, using
I didn't really understand your analogy, for one it "compares" subvols to block devs, which is a rather bad way of understanding it in my opinion because subvols aren't block devs, they are independently mountable filesystem roots. The best way to explain a subvol to a newbie would be something like "subvols are like normal directories with special semantics such as atomic snapshots and separate inode numbering, thus they share the same free space".
Not really needed. KDE already does this on its own. Try this on your system and see for yourself:
@clavelc
This is a more tricky subject in my opinion, for one, subvols have a few quirks associated with them that might not be immediately obvious to newbies, sometimes resulting in data loss. See this borgbackup issue as an example. This doesn't mean I don't think subvols can't be used on homedirs, they can, it just requires the user to understand its quirks. For example, fragmentation is a common issue when torrenting on BTRFS, so you can (ab)use the same feature/bug (subvols being treated as different filesystems) to have your torrent copied + unliked when it finishes, thus defragging the file without the torrent client being aware of BTRFS itself. |
The reason it didn't make sense to you was because I wasn't trying to explain subvolumes, I was trying to explain what's i'm guessing the thinking was behind opensuse's use of |
I didn't read the code (Python doesn't click for me sadly), but just going by observing the final output, Archinstall needs to:
The checked boxes are seemingly done/correct from my point of view, while the unchecked ones need to be addressed for a functional Arch system that works out-of-the-box with Timeshift (or anything else that expects the Flat layout with the Ubuntu-style naming scheme). Regarding [1] - Try using |
@KhalilSantana Thank you! We'll stick to |
I've created a draft PR that hopefully solves this. I suspect wllacer would solve this in 5 minutes. |
Yes , I never needed to call it as I create standard partition dictionary entries in *manage_btrfs_... for each mountable subvolume since day one. There is (i believe) where I mounted / unmonted the root partition @KhalilSantana misses. |
Thank you @wllacer. Since the variable was called I could have this done within the hour probably if you're busy. And the PR is almost done. |
Got the problem archinstall/archinstall/lib/disk/btrfs.py Lines 134 to 136 in becb423
look at the generated json },
{
"btrfs": {
"subvolumes": {
"@": "/",
"@.snapshots": "/.snapshots",
"@home": "/home",
"@log": "/var/log",
"@pkg": "/var/cache/pacman/pkg"
}
},
"encrypted": false,
"filesystem": {
"format": "btrfs"
},
"format": true,
"mountpoint": "/", #here is the culprit
"size": "100%",
"start": "513MiB",
"type": "primary"
} I never touched the part where the entry is generated (ny bad at user_guides and, as the partition entry has a mountpoint in the partition entry , all the procedures to create subvolumes don't work. I think i documented it somewhere, but never got to the code. archinstall/archinstall/lib/disk/user_guides.py Lines 36 to 44 in becb423
at line 42 something like
Can you do it ? Else I have to make a path for master and then you've to port it back |
I can try it : ) I can't see how that would work with the current code that is in my PR. Here's the current state:
|
I got it fine
PR #906 for master |
.snapshots should not be mounted according to the SuSe people, but is just fine ;-) |
Weird, it didn't work for me (Edit: just realized because I'm testing against Where do we call |
I'll try to fix this in Currently I got:
|
At mount_ordered_partition (just like normal partitions). The result of manage_btrfs_subvolumes is a bunch of new entries there, one for each subvolume to be mounted. |
Just for documentation
done at btrfs.manage_btrfs_subvolumes, where it also decides which subvolumes are to be mounted (there is no need for a 1:1 correspondency)
(The umount was done at the previous routine in 2.3.1, IIRC). This both are done at installer.mount_ordered_partition: We have a list (dict in in 2.3.1) of partition entries to be mounted and each of them are mounted in lexicographical order (so / is always the first)
It is done at installer.add_bootloader. Currently only for
We can generate whatever subvolume/partition scheme I could think of -sadly, still no UI, but working directly with the Json files-. The only restriction at 2.3.1 is that we didn't allowed to encrypt a btrfs partition with subvolumes. We have this restriction lifted already in master
|
This is the current state of the code in
Not sure this is enough, I'm missing the Fstab looks ok I think:
|
I suspect
|
The state of the PR is that it appears to do everything we expect. Most likely because a lack of I'm still performing some last tweaks, mainly compatibility between |
Grub appears broken with UEFI, and I think the reason for the screenshot was simply because fstab wasn't properly generated (due to a setting of timezone issue at the very last step of the installer) |
Funny. When i tried grub i had a lot of environmental troubles, (could only
execute It inside virtualbox) but the execution of grub-mkconfig (in the
add_bootloader) created everything fine without need of me touching
anything.
El mar., 25 ene. 2022 23:15, Anton Hvornum ***@***.***>
escribió:
… The state of the PR is that it appears to do everything we expect.
However, GRUB does not boot with subvolumes (encrypted or otherwise).
Most likely because a lack of rootflags=subvol=/@, which I haven't
figured out how to "put in" yet.
I'll adopt the systemd-boot logic to the GRUB section of the code, but
I'm very unfamiliar with GRUB as I haven't used it in somewhat 10 years.
I'm still performing some last tweaks, mainly compatibility between GRUB
and systemd-boot.
But PR and release of v2.3.1 should be ready by tomorrow. Got my hopes up
now! : )
—
Reply to this email directly, view it on GitHub
<#781 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACSDTYHL6REO3NR7YOZ6FW3UX4OJ7ANCNFSM5JF3YX3A>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Yepp, it was just |
Giving up for today. I'll try again tomorrow, but chances are slim that I understand GRUB well enough to sort this out. |
It works either way, one is an absolute path, the other is a relative path to toplevel, both point to the same subvolume in the end.
I also don't use GRUB, but the ArchWiki details how to use The outputs show on this comment look correct for me, I'll probably test this again on my other SSD soon just to be sure. |
@KhalilSantana Glad to hear! Then I feel more confident merging the PR. I'll test a little bit more with GRUB + UEFI tomorrow before merging. After which, release time : ) |
I'd like to thank everyone that contributed to this pretty large thread. This change has now made it's way into |
Hello,
I'm very happy to see that v2.3.X includes BTRFS subvolume support as a beta feature! This was a major blocker for me and now it's (mostly) gone.
However, I would like to comment on the current subvolume layout used by Archinstall's guided mode, and why (and how) I think it could be improved.
The Current Layout
For reference this is the current layout used by guided mode as of 2021-12-1 using archinstall v2.3.0:
How BTRFS handles subvolumes, and snapshots
(this section exists mostly to add context, skip it if you are familiar with BTRFS)
In BTRFS, each subvolume has an ID and a path, relative to the toplevel (a.k.a subvolid=5), these subvolumes can be mounted anywhere, and can be used for many things just like folders, however, the main differentiator between a regular folder and a subvol is that the later has special powers: atomic snapshots, etc.
Snapshots are just a clone of that filesystem root (subvol) at that time, and it shares extents with the snapped subvol, this is one of reasons snaps are so useful: they are fast and small.
However, there are some important quirks/behaviors that BTRFS currently does:
btrfs subvol snap
won't recurse into nested subvolumes. So you cannot create atomic snaps of nested subvolumes and their parents at once.btrfs subvol snap
doesn't recurse, the resulting subvolume (the snapshot) won't contain ANY of it's nested subvols.With this in mind, I hope the next section becomes easy to understand.
What's wrong with the current layout?
The current layout basically prohibits using snapshots as a rollback feature, why?
btrfs sub set-default
, your homedir will be empty! You'd need to manually snap RW the old home subvol into the right place.In short the main issues with the current subvol layout are:
What would be a better layout?
This is often called the "flat-layout", often used with the ubuntu-style naming scheme (@ as /, @home as /home), and it's documented on the wiki
What other distros are using?
My layout suggestion
Follow the flat layout, with the Ubuntu-style naming scheme, but keep the extra subvols (/var/log & /var/cache/pacman/pkg), those extras not nested, of course.
Basically, this:
In tree view for clarity's sake:
Why the Ubuntu naming scheme? Why not Fedora's? Or something else entirely?
Mostly because of Timeshift, as it only supports that standard. And while it might seem like a silly reason, I feel like it's reasonable: Timeshift is the one of the few snapshot utilities that has an incredibly easy to use restore button, which makes undoing changes incredibly easy, and also un-breaking a system after a bad upgrade.
Thank you for your time!
The text was updated successfully, but these errors were encountered: