Add systemd.mount for Btrfs

This commit is contained in:
Jeffrey Serio 2024-09-27 15:07:23 -05:00
parent 36efa5ed3c
commit 8dcda8ab13

View File

@ -1,6 +1,50 @@
#+title: Btrfs #+title: Btrfs
#+setupfile: ../org-templates/page.org #+setupfile: ../org-templates/page.org
** Create systemd.mount unit for Btrfs on external HDD
#+BEGIN_QUOTE
internet_archive is used here as an example.
#+END_QUOTE
Get the UUID of the Btrfs partition.
#+BEGIN_SRC shell
sudo blkid -s UUID -o value /dev/sda1
d3b5b724-a57a-49a5-ad1d-13ccf3acc52f
#+END_SRC
Edit ~/etc/systemd/system/mnt-internet_archive.mount.
#+BEGIN_SRC systemd
[Unit]
Description=internet_archive Btrfs subvolume
DefaultDependencies=yes
[Mount]
What=/dev/disk/by-uuid/d3b5b724-a57a-49a5-ad1d-13ccf3acc52f
Where=/mnt/internet_archive
Type=btrfs
Options=subvol=@internet_archive,compress=zstd:1
[Install]
WantedBy=multi-user.target
#+END_SRC
- ~DefaultDependencies=yes~ : The mount unit automatically acquires ~Before=umount.target~ and ~Conflicts=umount.target~. Local filesystems automatically gain ~After=local-fs-pre.target~ and ~Before=local-fs.target~. Network mounts, such as NFS, automatically acquire ~After=remote-fs-pre.target network.target network-online.target~ and ~Before=remote-fs.target~.
- ~Options=subvol=@internet_archive,compress=zstd:1~ : Use the subvolume ~@internet_archive~ and use zstd compression level 1.
#+BEGIN_QUOTE
Note that the name of the unit file, e.g. ~mnt-internet_archive.mount~, must correspond to the ~Where=/mnt/internet_archive~ directive, such that the filesystem path separator / in the ~Where~ directive is replaced by an en dash in the unit file name.
#+END_QUOTE
Reload the daemons and enable the mount unit.
#+BEGIN_SRC shell
sudo systemctl daemon-reload
sudo systemctl enable --now mnt-internet_archive.mount
#+END_SRC
** Setup encrypted external drive for backups ** Setup encrypted external drive for backups
*** Prepare the external drive *** Prepare the external drive
#+begin_src shell #+begin_src shell