digint / btrbk

Tool for creating snapshots and remote backups of btrfs subvolumes
https://digint.ch/btrbk/
GNU General Public License v3.0
1.64k stars 120 forks source link

Doc: /mnt is intended for temporary mounts only... #461

Open camoz opened 2 years ago

camoz commented 2 years ago

As far as I can see, according to the Filesystem Hierarchy Standard, /mtn is intended for temporary mounts only. See e.g. then man page hier(7):

/mnt This directory is a mount point for a temporarily mounted filesystem. In some distributions, /mnt contains subdirectories intended to be used as mount points for several temporary filesystems.

Or https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s12.html :

This directory is provided so that the system administrator may temporarily mount a filesystem as needed. The content of this directory is a local issue and should not affect the manner in which any program is run.

This directory must not be used by installation programs: a suitable temporary directory not in use by the system must be used instead.

The btrbk documentation currently rather encourages to permanently mount subvolumes there, e.g. in the README:

/etc/fstab:

/dev/sda1 /mnt/btr_pool btrfs subvolid=5,noatime 0 0

Now changing all the documentation would be tedious, and for demonstration and explaining how it works it's maybe good to use /mnt in the examples, but maybe the fstab example should be removed, or changed to noauto. Or a note somewhere about the FHS not recommending mounting filesystems permanently at /mnt would be useful.

digint commented 2 years ago

I kind of agree with what you say. For the examples in the documentation I would say it's ok, at least I would not know what other directory I should propose as "standard" for btrbk (probably something like /var/btrbk/mnt would be FHS conform? Sounds wrong to me as well...).

I'm not sure if I should confuse the users with FHS recommendations. Every linux user should know that the examples in the documentation are interchangeable, and /mnt is merely a suggestion.

I will happily add a note about the FHS conform, "correct" path for the mount points, but I would need some good arguments on where it should be.

zilexa commented 2 years ago

Actually I disagree. Every Linux distro I used doesn't actually mount temporary filesystems to /mnt. Instead, media or /run/username/media is used for temporary mounts such as external drives.

/mnt literally stands for "mount" making it the most logical top level folder for your drives. I actually have:

/mnt/drives containing a folder (mountpoint) for each drive. For example my btrfs root subvolume of the OS drive is mounted with noauto to /mnt/drives/system. But my backup drive is also there (also with noauto). These are actually only mounted for backup actions or maintenance.

I also have /mnt/pool containing the filesystem of my data storage (user data and media downloads), which could have multiple underlying drives/subvolumes. That's a permanent one.

There simply isn't another top level folder that makes sense and creating one yourself while /mnt is there to use doesn't make much sense..

camoz commented 2 years ago

I actually have a very similar setup, except that I don't have permanent mounts under /mnt. But I guess there is no immediate harm done by doing that, even if it's not conforming to the FHS. In any case, /mnt ist intended for manual mounts by the system administrator only, but as btrbk is not doing any mount operations there, this is also fine.

I just noticed it and wanted to bring it up, as I think following common standards is a good idea. But I admit it's more of a minor nitpick...

What do you think about adding noauto to the fstab example? The words mnt and fstab are not contained in any of the man pages, the only place that mentions fstab is here in the README. Currently it reads like this:

The examples below assume that the btrfs subvolume containing home and rootfs is mounted at /mnt/btr_pool. This is usually the btrfs root subvolume, which always has subvolid=5.

Mounting subvolid=5 is recommended (mandatory for btrbk < v0.32.0) if you want to backup your root filesystem /.

/etc/fstab:

/dev/sda1 /mnt/btr_pool btrfs subvolid=5,noatime 0 0

At the beginning it is already stated that "the examples below assume that the btrfs subvolume containing home and rootfs is mounted at /mnt/btr_pool", so the fstab line is kind of optional and maybe unnecessary. Some thoughts about it:

Alternatively, as I said, the fstab example could just be removed.

What do you think?

zilexa commented 2 years ago

@camoz But noauto is what you should already use when adding those mounts (the ones you only need to run btrbk) to fstab. Because they (root filesystems) do not have any need to be mounted for any other purpose, and this way you can always easily mount via sudo mount /mnt/drives/data1 instead of the whole mount command. This will also allow you to use btrbk-mail.sh since that requires you to add all necessary mountpoints to fstab.

camoz commented 2 years ago

@zilexa Maybe we are talking past each other? As I wrote, I am already using noauto. This issue is about adding it to the btrbk documentation.

zilexa commented 2 years ago

But these are basic tasks/best practices. it seems weird to ask this to be added to btrbk documentation. If we would want that level of detail, the documention needs a whole lot more.. Instead, it makes more sense to not expect such detailed level.. since this info is easy to find, either Arch wiki (even if you are on Ubuntu, the Ubuntu wiki often forwards you to Arch wiki) or fstab man.

wolfgangrupprecht commented 2 years ago

The problem I see with using /mnt/btr_pool is that the user might have multiple disks with separate btrfs filesystems. The question then becomes which disk is the /mnt/btr_pool for? I'm not sure what the answer is, just throwing it out there so folks can keep that issue in mind while deciding the best solution.

camoz commented 2 years ago

@wolfgangrupprecht That should be clear after reading the README:

The examples below assume that the btrfs subvolume containing home and rootfs is mounted at > /mnt/btr_pool. This is usually the btrfs root subvolume, which always has subvolid=5.

@zilexa Why not just adapt the fstab example to follow the best practices? Why show bad practices instead? It only changes one line...