Difference between revisions of "Btrfs"

3,172 bytes added ,  3 years ago
first approach
(added link)
(first approach)
Line 99: Line 99:
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 ====
==== 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.''
{{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 =====
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 =====
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 ====
translator
1,001

edits