Btrfs: Difference between revisions

From Alpine Linux
No edit summary
(link to arch and gentoo wiki)
 
(6 intermediate revisions by 4 users not shown)
Line 5: Line 5:
Installing [https://wikipedia.org/wiki/Btrfs Btrfs] is relatively straight forward. Install the package and tell Alpine to load the module on startup:
Installing [https://wikipedia.org/wiki/Btrfs Btrfs] is relatively straight forward. Install the package and tell Alpine to load the module on startup:


{{Cmd|apk add btrfs-progs
{{Cmd|# apk add {{pkg|btrfs-progs}}
echo btrfs >> /etc/modules}}
<nowiki># echo btrfs >> /etc/modules</nowiki>}}


To load the module right away, you can use the following command:
To load the module right away, you can use the following command:


{{Cmd|modprobe btrfs}}
{{Cmd|# modprobe btrfs}}


== Mounting a volume ==
== Mounting a volume ==
Line 16: Line 16:
To mount a volume on boot, add a new entry to your fstab:
To mount a volume on boot, add a new entry to your fstab:


UUID=abcdef-0055-4958-990f-1413ed1186ec  /var/data  btrfs  defaults,nofail,subvol=@  0  0
{{cat|/etc/fstab|<nowiki>...
UUID=abcdef-0055-4958-990f-1413ed1186ec  /var/data  btrfs  defaults,nofail,subvol=@  0  0
</nowiki>}}


If you use more specific mounting options like for example:
If you use more specific mounting options like for example:


UUID=005f5994-f51c-4360-8c9b-589fa59ea6fc  /mnt/hddext  btrfs  nofail,rw,noatime,commit=64,nossd,autodefrag,compress=zstd:10  0 2
{{cat|/etc/fstab|<nowiki>...
UUID=005f5994-f51c-4360-8c9b-589fa59ea6fc  /mnt/hddext  btrfs  nofail,rw,noatime,commit=64,nossd,autodefrag,compress=zstd:10  0 2
</nowiki>}}


do not forget to install additional dependencies. If you enabled on the fly compression you need to install zstd:
do not forget to install additional dependencies. If you enabled on the fly compression you need to install zstd:


apk add zstd
{{cmd|# apk add {{pkg|zstd}}}}


More information about mounting can be found in the official [https://btrfs.wiki.kernel.org/index.php/Main_Page Btrfs wiki]
More information about mounting can be found in the official [https://btrfs.readthedocs.io Btrfs wiki]


== Troubleshooting ==
== Troubleshooting ==
Line 32: Line 36:
=== Mount failed ===
=== Mount failed ===


If you try mounting a Btrfs volume via your /etc/fstab and it doesn't show up, it could be because Btrfs does not know about the drives during boot.
If you try mounting a Btrfs volume via your {{path|/etc/fstab}} and it doesn't show up, it could be because Btrfs does not know about the drives during boot.


To work around this, you can create an OpenRC service that runs a ''btrfs scan'' to detect the drives. To do so, create a new service under /etc/init.d/btrfs-scan with the following content:
To work around this, you can create an OpenRC service that runs a <code>btrfs scan</code> to detect the drives. To do so, create a new service under {{path|/etc/init.d/btrfs-scan}} with the following content:


#!/sbin/openrc-run
{{cat|/etc/init.d/btrfs-scan|<nowiki>#!/sbin/openrc-run
 
name="btrfs-scan"
name="btrfs-scan"
 
depend() {
depend() {
  before localmount
  before localmount
}
}
 
start() {
start() {
  /sbin/btrfs device scan
  /sbin/btrfs device scan
}
}
</nowiki>}}


Make the service executable and register it:
Make the service executable and register it:


{{Cmd|chmod +x /etc/init.d/btrfs-scan
{{Cmd|<nowiki># chmod +x /etc/init.d/btrfs-scan
rc-update add btrfs-scan boot
# rc-update add btrfs-scan boot
}}
</nowiki>}}


The volume should mount correctly after a reboot.
The volume should mount correctly after a reboot.


== Other Resources ==
== See also ==
 
* [https://garrit.xyz/posts/2021-12-31-btrfs-on-alpine BTRFS on Alpine Linux]
* [https://web.archive.org/web/20221127043947/https://nparsons.uk/blog/using-btrfs-on-alpine-linux Using BTRFS on Alpine Linux]
* [https://gitlab.alpinelinux.org/alpine/aports/-/issues/9539 Can't mount BTRFS volume using fstab]
* [https://wiki.archlinux.org/title/Btrfs ArchWiki]
* [https://wiki.gentoo.org/wiki/Btrfs Gentoo Wiki]


# [https://garrit.xyz/posts/2021-12-31-btrfs-on-alpine BTRFS on Alpine Linux]
[[Category:File systems]]
# [https://nparsons.uk/blog/using-btrfs-on-alpine-linux Using BTRFS on Alpine Linux]
# [https://gitlab-test.alpinelinux.org/alpine/aports/-/issues/9539 Can't mount BTRFS volume using fstab]

Latest revision as of 11:32, 10 November 2023

Documentation how to use Btrfs on Alpine Linux.

Install

Installing Btrfs is relatively straight forward. Install the package and tell Alpine to load the module on startup:

# apk add btrfs-progs # echo btrfs >> /etc/modules

To load the module right away, you can use the following command:

# modprobe btrfs

Mounting a volume

To mount a volume on boot, add a new entry to your fstab:

Contents of /etc/fstab

... UUID=abcdef-0055-4958-990f-1413ed1186ec /var/data btrfs defaults,nofail,subvol=@ 0 0

If you use more specific mounting options like for example:

Contents of /etc/fstab

... UUID=005f5994-f51c-4360-8c9b-589fa59ea6fc /mnt/hddext btrfs nofail,rw,noatime,commit=64,nossd,autodefrag,compress=zstd:10 0 2

do not forget to install additional dependencies. If you enabled on the fly compression you need to install zstd:

# apk add zstd

More information about mounting can be found in the official Btrfs wiki

Troubleshooting

Mount failed

If you try mounting a Btrfs volume via your /etc/fstab and it doesn't show up, it could be because Btrfs does not know about the drives during boot.

To work around this, you can create an OpenRC service that runs a btrfs scan to detect the drives. To do so, create a new service under /etc/init.d/btrfs-scan with the following content:

Contents of /etc/init.d/btrfs-scan

#!/sbin/openrc-run name="btrfs-scan" depend() { before localmount } start() { /sbin/btrfs device scan }

Make the service executable and register it:

# chmod +x /etc/init.d/btrfs-scan # rc-update add btrfs-scan boot

The volume should mount correctly after a reboot.

See also