<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://onnocenter.or.id/wiki/index.php?action=history&amp;feed=atom&amp;title=UseCases</id>
	<title>UseCases - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://onnocenter.or.id/wiki/index.php?action=history&amp;feed=atom&amp;title=UseCases"/>
	<link rel="alternate" type="text/html" href="https://onnocenter.or.id/wiki/index.php?title=UseCases&amp;action=history"/>
	<updated>2026-05-04T06:01:31Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.4</generator>
	<entry>
		<id>https://onnocenter.or.id/wiki/index.php?title=UseCases&amp;diff=27881&amp;oldid=prev</id>
		<title>Onnowpurbo: New page: There have been quite a few questions about how to accomplish ZFS tasks in Btrfs, as well as just generic &quot;How do I do X in Btrfs?&quot;.  This page aims to answer those questions.  Simply add ...</title>
		<link rel="alternate" type="text/html" href="https://onnocenter.or.id/wiki/index.php?title=UseCases&amp;diff=27881&amp;oldid=prev"/>
		<updated>2011-08-28T02:50:25Z</updated>

		<summary type="html">&lt;p&gt;New page: There have been quite a few questions about how to accomplish ZFS tasks in Btrfs, as well as just generic &amp;quot;How do I do X in Btrfs?&amp;quot;.  This page aims to answer those questions.  Simply add ...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;There have been quite a few questions about how to accomplish ZFS tasks in Btrfs, as well as just generic &amp;quot;How do I do X in Btrfs?&amp;quot;.  This page aims to answer those questions.  Simply add your question to the &amp;quot;Use Case&amp;quot; section of the table.&lt;br /&gt;
&lt;br /&gt;
= RAID =&lt;br /&gt;
&lt;br /&gt;
See also the [[Using Btrfs with Multiple Devices]] page for more detailed information on RAID under Btrfs.&lt;br /&gt;
&lt;br /&gt;
== How do I create a RAID1 mirror in Btrfs? ==&lt;br /&gt;
&amp;lt;pre&amp;gt;mkfs.btrfs -m RAID1 -d RAID1 /dev/sda1 /dev/sdb1&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How do I create a RAID10 striped mirror in Btrfs? ==&lt;br /&gt;
&amp;lt;pre&amp;gt; mkfs.btrfs -m RAID10 -d RAID10 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How can I create a RAID-1 filesystem in &amp;quot;degraded mode&amp;quot;? ==&lt;br /&gt;
&lt;br /&gt;
Create a filesystem with a small, empty device, and then remove it:&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/tmp/empty bs=1 count=0 seek=4G&lt;br /&gt;
 losetup /dev/loop1 /tmp/empty&lt;br /&gt;
 mkfs.btrfs -m raid1 -d raid1 /dev/sda1 /dev/loop1&lt;br /&gt;
 losetup -d /dev/loop1&lt;br /&gt;
 rm /tmp/empty&lt;br /&gt;
&lt;br /&gt;
You can add in the real mirror device(s) later:&lt;br /&gt;
&lt;br /&gt;
 mount /dev/sda1 /mnt&lt;br /&gt;
 btrfs dev add /dev/sdb1 /mnt&lt;br /&gt;
&lt;br /&gt;
(kernel 2.6.37) Simply creating the filesystem with too few devices will result in a RAID-0 filesystem. (This is probably a bug).&lt;br /&gt;
&lt;br /&gt;
== How do I determine the raid level currently in use? ==&lt;br /&gt;
&lt;br /&gt;
On a 2.6.37 or later kernel, use&lt;br /&gt;
&lt;br /&gt;
 btrfs fi df /mountpoint&lt;br /&gt;
&lt;br /&gt;
The required support was broken accidentally in earlier kernels, but has now been fixed.&lt;br /&gt;
&lt;br /&gt;
== How do I change RAID levels? ==&lt;br /&gt;
&lt;br /&gt;
At the moment, you can't change the RAID level after a filesystem is created. The filesystem design doesn't rule this feature out, but it's not yet implemented yet.&lt;br /&gt;
&lt;br /&gt;
See the [[Project_ideas#Changing_RAID_levels|Project Ideas]] page.&lt;br /&gt;
&lt;br /&gt;
= Snapshots and subvolumes =&lt;br /&gt;
&lt;br /&gt;
== I want to be able to do rollbacks with Btrfs ==&lt;br /&gt;
&lt;br /&gt;
If you use yum you can install the yum-plugin-fs-snapshot plugin and it will take a snapshot before doing any yum transaction.  You can also take a snapshot manually by running&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;btrfs subvolume snapshot /path/to/subvolume /path/to/subvolume/snapshot_name&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then if something goes wrong you can either mount using the mount option subvol=&amp;lt;snapshot name&amp;gt; or the subvolid=&amp;lt;id&amp;gt; option.  You can determine the ID of a snapshot by running&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;btrfs subvolume list /path/to/subvolume&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you wish to default to mounting from the rollback snapshot you can run either&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;btrfs subvolume set-default &amp;lt;id&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using the subvolume ID, or alternatively if you already have the snapshot mounted, you can run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;btrfs subvolume set-default /path/to/snapshot&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How do I mount the real root of the filesystem once I've made another subvolume the default? ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;mount -o subvolid=0 &amp;lt;filesystem&amp;gt; &amp;lt;mount-point&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Can a snapshot be replaced atomically with another snapshot? ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;btrfs subvolume snapshot first second&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
creates a snapshot of the subvolume ''first''.  After changing ''second'' in some way, I'd like to replace ''first'' with ''second'' e.g. using&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;btrfs subvolume snapshot second first&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This isn't currently allowed.  I would need to delete ''first'' before snapshotting, but this leaves a period of time when there is no directory by that name present, hence the need for atomic replacement á la rename(2).&lt;br /&gt;
&lt;br /&gt;
Is this possible with current btrfs?&lt;br /&gt;
&lt;br /&gt;
* No, and it's going to be pretty much impossible to achieve. You would have to ensure that all users of the volume being replaced have stopped using it before you replaced it. If you're going to do that, you might as well do an unmount/mount.&lt;br /&gt;
&lt;br /&gt;
== Are there a similar commands in BTRFS like ZFS send/receive? ==&lt;br /&gt;
&lt;br /&gt;
You can use&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;btrfs subvolume find-new &amp;lt;path&amp;gt; &amp;lt;last_gen&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to find the files modified since the last generation.  This uses the searching ioctl which is much faster than doing find, and equivalent to ZFS send.  There is nothing for ZFS receive yet.&lt;br /&gt;
&lt;br /&gt;
== How I can know how much space is used by a volume? ==&lt;br /&gt;
&lt;br /&gt;
This is a complex question. Since snapshots are subvolumes, storage can be shared between subvolumes, so how do you assign ownership of that storage to any specific subvolume?&lt;br /&gt;
&lt;br /&gt;
It does make sense to ask &amp;quot;how much space would be freed if I deleted this subvolume?&amp;quot;, but this is expensive to compute (it will take at least as long as &amp;quot;du&amp;quot; to run), and currently there is no code that will do the calculation for you.&lt;br /&gt;
&lt;br /&gt;
== Are there a similar commands in BTRFS like ZFS export/import? ==&lt;br /&gt;
&lt;br /&gt;
Your answer here....&lt;br /&gt;
&lt;br /&gt;
== Can we create virtual block device in BTRFS? ==&lt;br /&gt;
&lt;br /&gt;
No. Btrfs doesn't support the creation of virtual block devices or other non-btrfs filesystems within its managed pool of space.&lt;br /&gt;
&lt;br /&gt;
== How do we implement quota in BTRFS? ==&lt;br /&gt;
&lt;br /&gt;
A proposal being discussed (2011/06)&lt;br /&gt;
http://comments.gmane.org/gmane.comp.file-systems.btrfs/11095&lt;br /&gt;
&lt;br /&gt;
Disk structure proposal (2011/07)&lt;br /&gt;
http://permalink.gmane.org/gmane.comp.file-systems.btrfs/11845&lt;br /&gt;
&lt;br /&gt;
= Other questions =&lt;br /&gt;
&lt;br /&gt;
== How do I label a filesystem? ==&lt;br /&gt;
&lt;br /&gt;
The label on a filesystem can only be set at creation time, using the &amp;lt;code&amp;gt;-L&amp;lt;/code&amp;gt; option to &amp;lt;code&amp;gt;mkfs.btrfs&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There are patches that have been developed to set the label after creation, but they haven't been merged yet: https://patchwork.kernel.org/patch/175392/&lt;br /&gt;
&lt;br /&gt;
== How do I resize a partition? (shrink/grow) ==&lt;br /&gt;
{{Note|'''btrfsctl''' is now deprecated in favour of '''[[btrfs(command)|btrfs]]'''. In the examples below both commands are shown.}}&lt;br /&gt;
&lt;br /&gt;
In order to demonstrate and test the back references, Btrfs devel team has added an online&lt;br /&gt;
resizer, which can both grow and shrink the filesystem via [[btrfsctl]] or [[btrfs(command)|btrfs]] commands.&lt;br /&gt;
&lt;br /&gt;
First, ensure that your filesystem is mounted. See elsewhere for the full list of btrfs-specific [[Getting_started#Mount_Options|mount options]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
mount -t btrfs /dev/xxx /mnt&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Growing ===&lt;br /&gt;
&lt;br /&gt;
Enlarge the filesystem by 2 GiB:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
btrfs filesystem resize +2G /mnt&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
btrfsctl -r +2g /mnt&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The parameter &amp;quot;max&amp;quot; can be used instead of (e.g.) &amp;quot;+2G&amp;quot;, to grow the filesystem to fill the whole block device.&lt;br /&gt;
&lt;br /&gt;
=== Shrinking ===&lt;br /&gt;
&lt;br /&gt;
To shrink the filesystem by 4 GiB:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
btrfs filesystem resize -4g /mnt&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
btrfsctl -r -4g /mnt&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Set the FS size ===&lt;br /&gt;
&lt;br /&gt;
To set the filesystem to a specific size, omit the leading + or - from the size. For example, to change the filesystem size to 20 GiB:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
btrfs filesystem resize 20g /mnt&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
btrfsctl -r 20g /mnt&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ZFS does not need file system entries in /etc/vfstab. Is it mandatory in BTRFS to add file system entries in /etc/fstab? ==&lt;br /&gt;
&lt;br /&gt;
Going to need some clarification here since no file system in Linux requires entries in /etc/fstab, you can mount anything manually.  What advantage is there to not having things in /etc/vfstab?&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;Please refer below &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;br /&gt;
&lt;br /&gt;
In fact, zfs &amp;quot;auto&amp;quot; mount pools and filesystems tree hierachies. I think the question was : do we need to use &amp;quot;/etc/fstab&amp;quot; like with ancients FS for auto mount ?&lt;br /&gt;
&lt;br /&gt;
For BTRFS, until we put the mount point entry in &amp;quot;/etc/fstab&amp;quot;, its not going to be stable across reboot. In ZFS,making mount point entry in /etc/vfstab comes as legacy option.&lt;br /&gt;
&lt;br /&gt;
So, if you have got 50 BTRFS file systems mounted on different mount points, you will need 50 mount point entries in /etc/fstab to make sure its persistent across the reboot whereas in ZFS its not mandatory.&lt;br /&gt;
In the scenario, where we have 100+ mounted file system and making 100 entries in /etc/fstab makes fstab file to become big.. &lt;br /&gt;
&lt;br /&gt;
yes right as mentioned above question should have been &amp;quot;do we need to use &amp;quot;/etc/fstab&amp;quot; like with ancients FS for auto mount ?&lt;br /&gt;
&lt;br /&gt;
Please correct me if i am wrong...&lt;br /&gt;
&lt;br /&gt;
== How can I use btrfs for backups/time-machine? ==&lt;br /&gt;
&lt;br /&gt;
You can do snapshots frequently. See the [[SnapBtr]] script.&lt;/div&gt;</summary>
		<author><name>Onnowpurbo</name></author>
	</entry>
</feed>