Difference between revisions of "Btrfs"

reordered
(Resorted)
(reordered)
Line 85: Line 85:
{{BoxDanger|Snapshots together with quotas|There are reports about massive problems when using '''quotas''' together with snapshots (snapper, timeshift)}}
{{BoxDanger|Snapshots together with quotas|There are reports about massive problems when using '''quotas''' together with snapshots (snapper, timeshift)}}


== RAID ==
 
== move a volume to another disk ==
There are a lot of ways you can move a "normal" filesystem from one disk to another. But there are dangers with moving btrfs volumes that do not exist with other filesystems! '''Don´t ever move a btrfs volume with a tool that does not say it is 100% btrfs-proof.'''
When at any time there are 2 partitions in one computer that have the same filesystem UUID, one ore both filesystems '''may be destroyed'''. Under the topic '''tips''' you will find an easy way to do this without danger
{{BoxDanger|Do NOT|
* make a block-level copy of a Btrfs filesystem to another block device
* use LVM snapshots, or any other kind of block level snapshots
* turn a copy of a filesystem that is stored in a file into a block device with the loopback driver
* try to mount either the original or the copy while both are visible to the same kernel
See why at [https://btrfs.wiki.kernel.org/index.php/Gotchas Block-level copies of devices@btrfs.wiki.kernel.org]}}
 
= Btrfs RAID =
Btrfs can add and remove devices while running, and can freely switch between RAID levels after the volume has been created.
Btrfs can add and remove devices while running, and can freely switch between RAID levels after the volume has been created.


==== RAID 0 (Bunch of Disks)====
== RAID 0 (Bunch of Disks)==
Using one ore more devices to build a volume. This volume has the '''capacity of all the used devices together(1+2+3+4...)'''. This is an very easy way to expand your volume when you need more space.  You even can add 2 or 3 devices at a time. When you want to replace a device, you can add the new device, then remove the old device. Btrfs will move all data as necessary. ''To distribute all data to all devices you may want to '''balance''' the volume.''
Using one ore more devices to build a volume. This volume has the '''capacity of all the used devices together(1+2+3+4...)'''. This is an very easy way to expand your volume when you need more space.  You even can add 2 or 3 devices at a time. When you want to replace a device, you can add the new device, then remove the old device. Btrfs will move all data as necessary. ''To distribute all data to all devices you may want to '''balance''' the volume.''
{{BoxWarning|If one device fails, everything is lost|Be aware that when one of the devices fails your complete volume will be lost}}
{{BoxWarning|If one device fails, everything is lost|Be aware that when one of the devices fails your complete volume will be lost}}


===== 1 device =====
=== 1 device ===
In most setups you will start a volume with 1 device. If only one device is present, '''metadata will be duplicated''' on that device. Even with this simple setup you benefit from most features of Btrfs.
In most setups you will start a volume with 1 device. If only one device is present, '''metadata will be duplicated''' on that device. Even with this simple setup you benefit from most features of Btrfs.


===== 2 or more devices =====
=== 2 or more devices ===
By default, '''metadata will be mirrored''' across two devices and '''data will be striped''' across all of the devices present. But if you have 2 or more devices in your volume you should consider using RAID 1.  
By default, '''metadata will be mirrored''' across two devices and '''data will be striped''' across all of the devices present. But if you have 2 or more devices in your volume you should consider using RAID 1.  


===== move a volume to another disk =====
There are a lot of ways you can move a "normal" filesystem from one disk to another. But there are dangers with moving btrfs volumes that do not exist with other filesystems! '''Don´t ever move a btrfs volume with a tool that does not say it is 100% btrfs-proof.'''
When at any time there are 2 partitions in one computer that have the same filesystemUUID, one ore both filesystems '''may be destroyed'''.
{{BoxDanger|Do NOT|
* make a block-level copy of a Btrfs filesystem to another block device
* use LVM snapshots, or any other kind of block level snapshots
* turn a copy of a filesystem that is stored in a file into a block device with the loopback driver
* try to mount either the original or the copy while both are visible to the same kernel
See why at [https://btrfs.wiki.kernel.org/index.php/Gotchas Block-level copies of devices@btrfs.wiki.kernel.org]}}
But there is an '''easy and secure way''' to move a volume to another disk/device. If you use Btrfs itself to move a volume, there will be no danger. You even can do this '''while the volume is in use'''.
* Create the partition you want to use in the future '''without formatting''' it. Or remove the filesystem when one is present
* Add this device to your volume by '''btrfs device add ...'''
* Remove the previously used device from your volume by '''btrfs device remove ...'''
Btrfs will notice, that it is necessary for this setup to move all data from the old device to the new device. And it will start immediately to move it in the background. Meanwhile you can use your PC as you want. Empty Blocks will not be moved. Compressed data will remain compressed. Snapshots will remain. '''The UUID of the filesystem will remain the same''', but btrfs will be aware of this. So this is also easy with '''/boot/grub/grub.cfg''' and '''/etc/fstab'''.
* Only, '''don't shutdown while the move of the volume is not complete'''.
If you want to watch the volume move, inside a terminal:
{{UserCmd|command=pamac install procps-ng}}
{{RootCmd|command=watch -n 60 btrfs filesystem show /}}


==== RAID 1, 1C3, 1C4 ====
=== RAID 1, 1C3, 1C4 ===


===== automatic repair =====
=== automatic repair ===


==== RAID 10 ====
== RAID 10 ==


==== RAID 5 ====
== RAID 5 ==
{{BoxDanger|Not save yet|This is not recommended [https://btrfs.wiki.kernel.org/index.php/Gotchas see Parity RAID@btrfs.wiki.kernel.org]}}
{{BoxDanger|Not save yet|This is not recommended [https://btrfs.wiki.kernel.org/index.php/Gotchas see Parity RAID@btrfs.wiki.kernel.org]}}


==== RAID 6 ====
== RAID 6 ==
{{BoxDanger|Not save yet|This is not recommended [https://btrfs.wiki.kernel.org/index.php/Gotchas see Parity RAID@btrfs.wiki.kernel.org]}}
{{BoxDanger|Not save yet|This is not recommended [https://btrfs.wiki.kernel.org/index.php/Gotchas see Parity RAID@btrfs.wiki.kernel.org]}}


=== balance ===
= Btrfs maintenance =


=== scrub ===
== balance ==


=== compression ===
== scrub ==
 
= Btrfs options =
 
== compression ==


{{BoxWarning|Grub needs to load the kernel and initrd|When you use compression on kernel, initrd, or grub config files, grub needs to decompress these files. Otherwise you will '''not be able to boot'''. GRUB introduced '''zstd''' support in '''2.04.'''}}
{{BoxWarning|Grub needs to load the kernel and initrd|When you use compression on kernel, initrd, or grub config files, grub needs to decompress these files. Otherwise you will '''not be able to boot'''. GRUB introduced '''zstd''' support in '''2.04.'''}}


=== encryption ===
== encryption ==


=== send / receive ===
== send⇒receive = backup ==


=== quotas ===
== quotas ==
Quota support in Btrfs is implemented at the subvolume level.
Quota support in Btrfs is implemented at the subvolume level.


Line 152: Line 148:
* [https://forum.manjaro.org/t/files-disappearing-in-btrfs-and-ssd/28991 files-disappearing-in-btrfs-and-ssd 2020]
* [https://forum.manjaro.org/t/files-disappearing-in-btrfs-and-ssd/28991 files-disappearing-in-btrfs-and-ssd 2020]


= tips =


== move a volume ==
But there is an '''easy and secure way''' to move a volume to another disk/device. If you use Btrfs itself to move a volume, there will be no danger. You even can do this '''while the volume is in use'''.
* Create the partition you want to use in the future '''without formatting''' it. Or remove the filesystem when one is present
* Add this device to your volume by '''btrfs device add ...'''
* Remove the previously used device from your volume by '''btrfs device remove ...'''
Btrfs will notice, that it is necessary for this setup to move all data from the old device to the new device. And it will start immediately to move it in the background. Meanwhile you can use your PC as you want. Empty Blocks will not be moved. Compressed data will remain compressed. Snapshots will remain. '''The UUID of the filesystem will remain the same''', but btrfs will be aware of this. So this is also easy with '''/boot/grub/grub.cfg''' and '''/etc/fstab'''.
* Only, '''don't shutdown while the move of the volume is not complete'''.
If you want to watch the volume move, inside a terminal:
{{UserCmd|command=pamac install procps-ng}}
{{RootCmd|command=watch -n 60 btrfs filesystem show /}}


= Btrfs Tools =
= Btrfs Tools =
translator
987

edits