<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Spider</id>
	<title>Alpine Linux - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Spider"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Spider"/>
	<updated>2026-04-26T12:03:52Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Btrfs&amp;diff=31968</id>
		<title>Btrfs</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Btrfs&amp;diff=31968"/>
		<updated>2026-01-15T21:59:56Z</updated>

		<summary type="html">&lt;p&gt;Spider: /* Configuration */   Does the tip mean if you REuse a btrfs filesystem?  I&amp;#039;m assuming yes since this is an article about using that filesystem.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://wikipedia.org/wiki/Btrfs Btrfs] is a CoW (copy on write) filesystem with checksums, snapshots, compression and more.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
The {{pkg|btrfs-progs}} package provides a number of user-space tools. To install the package:{{Cmd|# apk add {{pkg|btrfs-progs}}}}&lt;br /&gt;
&lt;br /&gt;
When [[Installation|Installing Alpine linux]], &amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt; can automatically set up a root filesystem with Btrfs using [[Alpine_setup_scripts#Environment_Variables|environment variables]]. Export &amp;lt;code&amp;gt;ROOTFS&amp;lt;/code&amp;gt; before running &amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt; like so: {{Cmd|&amp;lt;nowiki&amp;gt;# export ROOTFS=btrfs&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
The filesystem utilities and modules will automatically be set up.&lt;br /&gt;
&lt;br /&gt;
=== Manual Installation ===&lt;br /&gt;
&lt;br /&gt;
If btrfs is used for root filesystem, ensure that the initramfs is generated with the btrfs module, otherwise the system may fail to boot. &lt;br /&gt;
&lt;br /&gt;
To do so edit the {{path|/etc/mkinitfs/mkinitfs.conf}} and ensure that &amp;quot;btrfs&amp;quot; is in the list of features as follows:{{Cat|/etc/mkinitfs/mkinitfs.conf|features{{=}}&amp;quot;ata base cdrom ext4 keymap kms mmc nvme raid scsi usb virtio btrfs&amp;quot;}}&lt;br /&gt;
&lt;br /&gt;
After making the above change, issue the command to regenerate the initramfs:{{Cmd|# mkinitfs}} &lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
To load the btrfs kernel module immediately, use the following command: {{Cmd|# modprobe btrfs}}&lt;br /&gt;
&lt;br /&gt;
To mount non-root partitions with btrfs filesystem automatically on startup:{{Cmd|&amp;lt;nowiki&amp;gt;# echo btrfs &amp;gt;&amp;gt; /etc/modules&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Enabling {{ic|btrfs-scan}} service from the {{pkg|btrfs-progs}} package loads the btrfs kernel module and scans for and registers Btrfs devices with the kernel. To enable it: {{Cmd|# rc-update add btrfs-scan boot}}&lt;br /&gt;
&lt;br /&gt;
{{Tip| Using {{ic|btrfs-scan}} service is recommended if btrfs file system is reused.}}&lt;br /&gt;
&lt;br /&gt;
=== Mounting a subvolume ===&lt;br /&gt;
&lt;br /&gt;
To mount a subvolume {{ic|@alpine}} located in the btrfs partition {{Path|/dev/nvme0n1p3}}, the command is: {{Cmd|&amp;lt;nowiki&amp;gt;# mount -o subvol=@alpine /dev/nvme0n1p3 /mnt&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Mounting a subvolume on boot ===&lt;br /&gt;
&lt;br /&gt;
To mount a volume on boot, add a new entry to your {{path|/etc/fstab}} file as follows: {{cat|/etc/fstab|&amp;lt;nowiki&amp;gt;...&lt;br /&gt;
UUID=abcdef-0055-4958-990f-1413ed1186ec  /var  btrfs  defaults,nofail,subvol=@var  0  0&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
If you use more specific mounting options like for example:{{cat|/etc/fstab|&amp;lt;nowiki&amp;gt;...&lt;br /&gt;
UUID=005f5994-f51c-4360-8c9b-589fa59ea6fc  /mnt/hddext  btrfs  nofail,rw,noatime,commit=64,autodefrag,compress=zstd:10  0 2&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
The option {{ic|defaults}} is recommended for most use cases. More information about mounting can be found in the official [https://btrfs.readthedocs.io Btrfs wiki]&lt;br /&gt;
&lt;br /&gt;
=== apk-snap  ===&lt;br /&gt;
&lt;br /&gt;
The {{ic|apk-snap}} script from {{pkg|apk-snap}} package triggers filesystem snapshots before and after every apk commit using {{ic|snapper}} utility. &lt;br /&gt;
&lt;br /&gt;
The {{pkg|apk-snap}} package is currently available in [[Repositories#Testing|testing]] repository.  It can be safely installed by following the [[Repositories#Using_testing_repository|guidelines]]. &lt;br /&gt;
&lt;br /&gt;
The {ic|apk-snap}} script provides necessary apk hooks and script that causes {{ic|snapper}} utility to automatically take a pre and post snapshot before and after apk transactions, similar to how YaST does with OpenSuse. This provides a simple way to undo changes to a system after an apk transaction. &lt;br /&gt;
&lt;br /&gt;
By default the &#039;&#039;&#039;/&#039;&#039;&#039; (root) snapshots taken by snapper are saved in the &#039;&#039;&#039;/.snapshot&#039;&#039;&#039; folder. To make it easier to manage the snapshots created by snapper, it is better to mainain it outside of &#039;&#039;&#039;/(root)&#039;&#039;&#039; folder. To achieve this, create a subvolume {{ic|@snaps_root}} in the btrfs partition and mount the above subvolume on &#039;&#039;&#039;/.snapshot&#039;&#039;&#039; folder by having an entry in {{Path|etc/fstab}} file as follows: {{Cat|/etc/fstab|&amp;lt;nowiki&amp;gt;...&lt;br /&gt;
UUID=823a3283-30a7-4fef-b50b-8a2230c71b5b /.snapshots  btrfs defaults,subvol=@snaps_root 0 0&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Bootloader ===&lt;br /&gt;
&lt;br /&gt;
If the initrd and kernel are installed inside the btrfs root subvolume instead of EFI partition, configuring the bootloader properly is important. For sample configuration, refer to the following pages for [[Bootloaders#Manual_configuration|rEFInd]] and [[Immutable root with atomic upgrades#GRUB|GRUB]] bootloaders.&lt;br /&gt;
&lt;br /&gt;
=== Btrbk ===&lt;br /&gt;
&lt;br /&gt;
The backup tool [https://github.com/digint/btrbk btrbk] can be used to take backups using btrfs specific capabilities to create atomic snapshots and transfer them incrementally to your backup locations.&lt;br /&gt;
&lt;br /&gt;
To install the package {{pkg|btrbk}}, issue the command:{{Cmd|# apk add {{pkg|btrbk}}}}&lt;br /&gt;
&lt;br /&gt;
To use default [[BusyBox]], use the following global option in {{Path|/etc/btrbk/btrbk.conf}} as follows:{{Cat|/etc/btrbk/btrbk.conf|&amp;lt;nowiki&amp;gt;...&lt;br /&gt;
# activate the busybox compatibility&lt;br /&gt;
compat busybox &lt;br /&gt;
...&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== Mount failed ===&lt;br /&gt;
&lt;br /&gt;
If you try mounting a Btrfs volume via your {{path|/etc/fstab}} and if it doesn&#039;t show up, this is related to {{Issue|9539|Can&#039;t mount BTRFS volume using fstab}}. This could be because Btrfs does not know about the drives during boot. To avoid this issue [[#Configuration|enable the btrfs-scan]] service. The volume should mount correctly after a reboot.&lt;br /&gt;
&lt;br /&gt;
=== Failed to fetch subvolume detail ===&lt;br /&gt;
&lt;br /&gt;
In Alpine Linux, when running [[#Btrbk|btrbk]] with [[BusyBox]] defaults, you may encounter the above error &#039;Skipping subvolume &amp;quot;/mnt/btrfs/@myvolume&amp;quot;: Failed to fetch subvolume detail&#039;. To troubleshoot, run the command {{Cmd|# btrbk -n -l debug -L -S run}}&lt;br /&gt;
&lt;br /&gt;
If you see the error {{Cmd|WARNING: ... sh: readlink -v -e &#039;/mnt/btrfs/@myhome&#039;&lt;br /&gt;
WARNING: ... readlink: unrecognized option: e}}&lt;br /&gt;
&lt;br /&gt;
To resolve, either use the {{ic|compat busybox}} option as mentioned in [[#Btrbk|btrbk]] section or install the {{pkg|coreutils}} package.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://btrfs.readthedocs.io Btrfs documentation]&lt;br /&gt;
* [https://garrit.xyz/posts/2021-12-31-btrfs-on-alpine BTRFS on Alpine Linux]&lt;br /&gt;
* [https://web.archive.org/web/20221127043947/https://nparsons.uk/blog/using-btrfs-on-alpine-linux Using BTRFS on Alpine Linux]&lt;br /&gt;
* [https://wiki.archlinux.org/title/Btrfs ArchWiki]&lt;br /&gt;
* [https://wiki.gentoo.org/wiki/Btrfs Gentoo Wiki]&lt;br /&gt;
* [[Install Alpine on a btrfs filesystem with refind as boot manager]]&lt;br /&gt;
* [[Immutable root with atomic upgrades|Immutable root with atomic upgrades using btrfs snapshots]]&lt;br /&gt;
[[Category:Filesystems]]&lt;/div&gt;</summary>
		<author><name>Spider</name></author>
	</entry>
</feed>