Hi, I’m just starting exploring btrfs volume concepts; currently my testing setup has three subvolumes: root, var, home; is it possible have user home folder (I mean /home/user, not all /home) in a different partition? Thanks for suggestions

  • @nous@programming.dev
    link
    fedilink
    English
    1113 days ago

    The Linux directory system is a single tree from the root /. You can mount any filesystem to any directory inside it to extend it and have all writes to that location be handled by that FS. This is all irrespective of what filesystem the is present at that location in the tree. It does not matter if it is BTRFS, ext4 or anything else mounting a filesystem into the directory structure is handled by the kernel separately from the FS implementation. So, yes, you can mount any partition that contains a filesystem to /home/user no matter what you have done with / or even /home.

    But, any writes to that location will be handled by the filesystem driver for that partition. So any subvolumes or anything else the main filesystem/partition has wont be available inside that directory. You can have a BTRFS filesystem mounted there from a separate partition if you want. Though a big benefit of BTRFS is the ability to use subvolumes instead of full partitions so you are not segregating the space on the disk (ie, any subvolume can use what space it requires and you wont have one running out of space because you didn’t make it large enough). So if you are going for BTRFS subvolumes I would just have one main partition and use subvolumes to split up the space if you wish. Though really the only benefit to that is you can snapshot them separately and I think you can set different quotas and settings on each one.

    • @gcalaOP
      link
      213 days ago

      Thanks for the detailed answer. If i go with one partition/multiple subvolumes, is it possible create a subvolume for my “user” home that is encrypted with luks?

      • @nous@programming.dev
        link
        fedilink
        English
        3
        edit-2
        13 days ago

        subvolumes are integral to btrfs. You cannot have a layer like luks between them. You can encrypt the whole partition with luks before btrfs or you can encrypt specific directories after btrfs with something like encfs or truecrypt, though doing so loses some of the benefits of btrfs as it can no longer see your individual files.

        If you wanted just /home encrypted with luks it would need to be a separate partition (which you could then have btrfs inside with subvolumns on that). Though IMO that gets a bit complicated - I would just opt for encrypting everything (except boot) on the root partition and have one btrfs fs on that partition with as many subvolumes inside that as you like.

  • Possibly linux
    link
    fedilink
    English
    213 days ago

    I would but /home in a btrfs subvolme and / (root) in another subvolume. That’s how Fedora does it and its worked fine for years

  • Ephera
    link
    1
    edit-2
    13 days ago

    openSUSE used to have the /home folder (so, not a specific user subfolder) on a different partition as the default setup some years ago, with 40 GB for the root partition.

    They changed it, because it meant people’s root partitions would sometimes fill up from the snapshots being stored there and that’s really annoying to recover from.
    Not only can a full root partition irreparably damage your Linux system, it also meant that people would try to uninstall packages to free up space, which wouldn’t actually free up space, because those packages were still contained in differential snapshots.

    To actually free up space, you have to either delete old snapshots (so that there’s less difference to your current install) or delete intermediate snapshots where you happened to install a load of packages, which you uninstalled afterwards.

    • @gcalaOP
      link
      113 days ago

      I’m not asking this for limited space. My long term purpose is having just my home with granted space and luks encryption (and obviously decryption on login).

      • Ephera
        link
        1
        edit-2
        13 days ago

        Hmm, as in you only want your home-partition to be encrypted, nothing else? Because you can do filesystem encryption for the entire btrfs (including both root and home) and that works perfectly fine.

        Not sure, if it uses LUKS for that, but there’s an option in the installer for encryption…

  • Yes. This is not a btrfs feature, it’s just a partitioning scheme. Lots of people keep their /home on a different partition for easy portability.

    Example: you have two 1TB nvme drives on your machine, and you’re planning on downloading a lot of games from Steam, but also might switch distros. Separate /home partition allows you a simple space to do all this, and also wipe out your OS installed on the / drive, and install a new one. Just have to mount your existing/home during, or after installs.