8,673
edits
(Updating to match new version of source page) |
(Updating to match new version of source page) |
||
Line 9: | Line 9: | ||
Because Btrfs is different, some things seem unfamiliar and strange. If you want to learn the details and the newest stuff, then [https://btrfs.wiki.kernel.org/index.php/Main_Page btrfs.wiki.kernel.org] is the place to go or [https://btrfs.readthedocs.io/en/latest/index.html btrfs.readthedocs.io]. | Because Btrfs is different, some things seem unfamiliar and strange. If you want to learn the details and the newest stuff, then [https://btrfs.wiki.kernel.org/index.php/Main_Page btrfs.wiki.kernel.org] is the place to go or [https://btrfs.readthedocs.io/en/latest/index.html btrfs.readthedocs.io]. | ||
Development of Btrfs started in 2007. Since that time, Btrfs is a part of the Linux kernel and is under active development. The Btrfs code base and filesystem-layout is '''[https://btrfs.wiki.kernel.org/index.php/Status stable] .''' However, new features are still under development. Its main features and benefits are: | Development of Btrfs started in 2007. Since that time, Btrfs is a part of the Linux kernel and is under active development. The Btrfs code base and filesystem-layout is '''[https://btrfs.wiki.kernel.org/index.php/Status stable] .''' However, new features are still under development. Its main features and benefits are: | ||
*'''Snapshots''' which do not make | *'''Snapshots''' which do not make a full copy of files | ||
*'''Volume Manager''' join partitions, split into subvolumes | *'''Volume Manager''' join partitions, split into subvolumes | ||
*'''RAID''' - support for software-based RAID 0, RAID 1, RAID 10 | *'''RAID''' - support for software-based RAID 0, RAID 1, RAID 10 | ||
Line 30: | Line 30: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
<div class="mw-collapsible mw-collapsed"><div class="mw-collapsible-toggle" style="float:none;">▶ Btrfs '''volume'''</div><div class="mw-collapsible-content">A '''[[Btrfs#Btrfs_Volume|volume]]''' is a pool of raw storage and consists of one or more '''device'''s. The size of the volume will be the addition of all devices that are part of this volume. In most cases you will only use one volume. You are able to add/remove devices at any time. ''Usually you do '''not''' mount a Btrfs volume.'' | <div class="mw-collapsible mw-collapsed"><div class="mw-collapsible-toggle" style="float:none;">▶ Btrfs '''volume'''</div><div class="mw-collapsible-content">A '''[[Btrfs#Btrfs_Volume|volume]]''' is a pool of raw storage and consists of one or more '''device'''s. The size of the volume will be the addition of all devices that are part of this volume. In most cases you will only use '''one''' volume. You are able to add/remove devices at any time. ''Usually you do '''not''' mount a Btrfs volume.'' | ||
</div></div> | </div></div> | ||
</div> | </div> | ||
Line 61: | Line 61: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
<div class="mw-collapsible mw-collapsed"><div class="mw-collapsible-toggle" style="float:none;">▶ '''snapshot'''</div><div class="mw-collapsible-content">A '''[[Btrfs#snapshot|snapshot]]''' looks nearly the same as a '''[[Btrfs#subvolume|subvolumes]]'''. But don´t get confused. When we talk about snapshots we usually mean a "'''Read-Only (ro) photograph''' of a subvolume". While the subvolume changes with time. A snapshot stays in the state of the subvolume at the time we made it. You can mount snapshots into your linux system, but you only can read the content. And the content will never change while this snapshot exists. When creating '''snapshots''' you have to watch out for the Btrfs-'''layout''' in use. | <div class="mw-collapsible mw-collapsed"><div class="mw-collapsible-toggle" style="float:none;">▶ '''snapshot'''</div><div class="mw-collapsible-content">A '''[[Btrfs#snapshot|snapshot]]''' looks nearly the same as a '''[[Btrfs#subvolume|subvolumes]]'''. But don´t get confused. When we talk about snapshots we usually mean a "'''Read-Only (ro) photograph''' of a subvolume". While the subvolume changes with time. A snapshot stays in the state of the subvolume at the time we made it. You can mount snapshots into your linux system, but you only can read the content. And the content will never change while this snapshot exists. When creating '''snapshots''' you have to watch out for the Btrfs-'''layout''' in use. | ||
It is possible to make a writeable(rw) subvolume out of a ro-snapshot. This is the way '''[[Btrfs#Rollback_to_a_snapshot|roll back]]''' does work. | It is possible to make a writeable(rw) subvolume out of a ro-snapshot. This is the way '''[[Btrfs#Rollback_to_a_snapshot|roll back]]''' does work. It is also possible to send a ro-snapshot to another btrfs volume as '''[[Btrfs#Send_.2B_receive_.3D_backup_.E2.87.92|backup]]''' | ||
</div></div> | </div></div> | ||
</div> | </div> | ||
Line 147: | Line 147: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
=== Subvolume '''@''' === | === Subvolume '''@''' === | ||
This is the subvolume where your '''complete manjaro system''' will reside. It is mounted at "/" in your filesystem. You may take snapshots of this subvolume | This is the subvolume where your '''complete manjaro system''' will reside. It is mounted at "/" in your filesystem. You may take snapshots of this subvolume to secure a running manjaro system. When something bad happens, you are able to rollback to one of the snapshots, (or to restore one of the external backups of a snapshot) '''without changing your data''' at /home. | ||
</div> | </div> | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
In order to make a rollback possible | {{BoxInfo|In order to make a rollback possible|The snapshot has to contain all and every data that is needed for your manjaro to work properly! This includes: | ||
* '''config''' of your bootloader (/boot/brub/grub.cfg) | * '''config''' of your bootloader (/boot/brub/grub.cfg) | ||
* '''initramdisk''' (/boot/initramfs- | * '''initramdisk''' (/boot/initramfs-6.xx-x86_64.img) | ||
* '''kernel''' (/boot/vmlinuz- | * '''kernel''' (/boot/vmlinuz-6.xx-x86_64) | ||
* '''kernel-modules''' (/usr/lib/modules/ | * '''kernel-modules''' (/usr/lib/modules/6.xx.xx-x-MANJARO/*) | ||
* programs (/usr/bin/*) | * programs (/usr/bin/*) | ||
* configs (/etc/*) | * configs (/etc/*) | ||
Line 161: | Line 161: | ||
* your root account (/root/*) | * your root account (/root/*) | ||
* rest of system files (/usr/*) | * rest of system files (/usr/*) | ||
}} | |||
</div> | </div> | ||
Line 184: | Line 185: | ||
{{RootCmd|command=btrfs subvolume create [/mnt/@tests]}} | {{RootCmd|command=btrfs subvolume create [/mnt/@tests]}} | ||
This will be shown by | This will be shown by | ||
{{RootCmd|command=ls - | {{RootCmd|command=ls -lA /mnt}} | ||
{{RootCmd|command=btrfs subvolume list /mnt}} | {{RootCmd|command=btrfs subvolume list /mnt}} | ||
This subvolume '''tests''' is empty. And it is not mounted by default. So if you want to use it, you have to mount it by ''fstab'' or other means. '''Now lets delete it again.''' | This subvolume '''tests''' is empty. And it is not mounted by default. So if you want to use it, you have to mount it by ''fstab'' or other means. '''Now lets delete it again.''' | ||
Line 222: | Line 223: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
Taking a snapshot is '''very fast''', and '''nearly priceless'''. After the snapshot is taken, all future writes will go as in CoW usual. But none of the space occupied by files in the snapshot will be reusable. As you write more and more new files, the filesystem will grow because it can not reuse the files in the snapshot. A new snapshot will freeze additionally all created or modified files since the last snapshot and so on. '''If you don´t release'''(delete) any snapshot '''you will''' eventually '''run out of space''' soon | Taking a snapshot is '''very fast''', and '''nearly priceless'''. After the snapshot is taken, all future writes will go as in CoW usual. But none of the space occupied by files in the snapshot will be reusable. As you write more and more new files, the filesystem will grow because it can not reuse the files in the snapshot. A new snapshot will freeze additionally all created or modified files since the last snapshot and so on. '''If you don´t release'''(delete) any snapshot '''you will''' eventually '''run [[Btrfs#Out_of_space|out of space]]''' soon. | ||
</div> | </div> | ||
Line 234: | Line 235: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
Don´t forget to remove snapshots, or you will get in ''' | It's best to delete snapshots using the tool that created them. | ||
* ++++ '''Add''' some partition/device to the volume | * If you used Snapper to create them, delete them using Snapper. | ||
* If you used Timeshift to create them, delete them using Timeshift. | |||
* If you created them manually, delete them manually. | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
Don´t forget to remove snapshots, or you will get in '''[[Btrfs#Out_of_space|out of space]]-trouble soon'''. Btrfs needs some free space to manage its work. If your volume is more then 85% full you have to think(fast) what to do. | |||
* ++++ '''[[Btrfs#Extend_a_volume|Add]]''' some partition/device to the volume | |||
* +++ '''Remove''' some snapshots you don't need | * +++ '''Remove''' some snapshots you don't need | ||
* ++ [[Btrfs#Compression_.E2.87.92|Compress]] your volume | * ++ [[Btrfs#Compression_.E2.87.92|Compress]] your volume | ||
* + '''Delete''' some files ( | * + '''Delete''' some files (This does only help if they are not part of '''any''' snapshot) | ||
</div> | </div> | ||
Line 246: | Line 254: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
If you need to roll back into a snapshot you have to replace the actual subvolume by the chosen snapshot. | If you need to roll back into a snapshot you have to '''replace''' the actual subvolume by the chosen snapshot. | ||
# '''Make a snapshot(ro)''' of the actual subvolume (for later reference) | # '''Make a snapshot(ro)''' of the actual subvolume (for later reference) | ||
# '''Delete the subvolume''' out of its actual place | # '''Delete the subvolume''' out of its actual place | ||
Line 257: | Line 265: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
Please also have a look at [https://github.com/jrabinow/snapper-rollback snapper-rollback@github] and at [https://wiki.archlinux.org/title/Snapper#Suggested_filesystem_layout snapshot-layout@wiki.archlinux] for the suggested flat layout and the reasoning. ([https://forum.manjaro.org/t/how-to-manual-rollback-with-btrfs/80230 Rollback example ]) | Please also have a look at [https://github.com/jrabinow/snapper-rollback snapper-rollback@github] and at [https://wiki.archlinux.org/title/Snapper#Suggested_filesystem_layout snapshot-layout@wiki.archlinux] for the suggested flat layout and the reasoning. ([https://forum.manjaro.org/t/how-to-manual-rollback-with-btrfs/80230 Rollback example ]) | ||
{{BoxWarning|Don't forget to remove snapshots before you run out of space|Every time you take a snapshot you only use the "rest of the volume" for storing everything you change from this time on. At some point in time you have to release the snapshot. Don´t use your space up. Btrfs needs '''space to breath.''' Don't use more then '''90%''' or you will get into trouble."}} | {{BoxWarning|Don't forget to remove snapshots before you run out of space|Every time you take a snapshot you only use the "rest of the volume" for storing everything you change from this time on. At some point in time you have to release the snapshot. Don´t use your space up. Btrfs needs '''space to breath.''' Don't use more then '''90%''' or you will get deep into trouble."}} | ||
{{BoxDanger|NO Snapshots together with quotas|There are reports about massive problems when using '''quotas''' together with snapshots (snapper, timeshift). Please have a look at: [https://btrfs.wiki.kernel.org/index.php/Quota_support#Known_issues Known_issues@btrfs.kernel.org]}} | {{BoxDanger|NO Snapshots together with quotas|There are reports about massive problems when using '''quotas''' together with snapshots (snapper, timeshift). Please have a look at: [https://btrfs.wiki.kernel.org/index.php/Quota_support#Known_issues Known_issues@btrfs.kernel.org]}} | ||
</div> | </div> | ||
Line 295: | Line 303: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
When using | When using RAID 1 btrfs mirrors '''data and metadata'''. This way it is possible to repair data when one copy gets damaged. This could happen when one device fails, when power was lost while writing, ... '''After enabling RAID1''' all new data and metadata is automatically mirrored. To mirror your existing data and metadata, '''you have to balance your complete volume'''. | ||
</div> | </div> | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
=== Automatic repair === | === Automatic repair === | ||
In order to preserve the integrity of the volume, Btrfs does separate CRC-checksums of metadata blocks and of data blocks. Every time a data block is read, the checksum is verified. When the checksum shows that the data is not good, Btrfs tries to get a good copy from the mirrored block. Then the bad block is written again with the good data from the mirrored block. This happens in background. The filesystem has been repaired, and this is logged into syslog. This can be forced by using btrfs scrub. | In order to preserve the integrity of the volume, Btrfs does separate CRC-checksums of metadata blocks and of data blocks. Every time a data block is read, the checksum is verified. When the checksum shows that the data is not good, Btrfs tries to get a good copy from the mirrored block. Then the bad block is written again with the good data from the mirrored block. This happens in background. The filesystem has been repaired, and this is logged into syslog. This repair can be forced by using btrfs scrub. | ||
</div> | </div> | ||
<div class="mw-translate-fuzzy"> | |||
=== [https://btrfs.readthedocs.io/en/stable/mkfs.btrfs.html#man-mkfs-profiles RAID 10] (otomatik) === | === [https://btrfs.readthedocs.io/en/stable/mkfs.btrfs.html#man-mkfs-profiles RAID 10] (otomatik) === | ||
RAID 1 ile yeterli sayıda aygıt (4...) kullanıldığında, Btrfs tüm verileri yalnızca yansıtılacak değil aynı zamanda şeritlenecek şekilde dağıtacaktır. | RAID 1 ile yeterli sayıda aygıt (4...) kullanıldığında, Btrfs tüm verileri yalnızca yansıtılacak değil aynı zamanda şeritlenecek şekilde dağıtacaktır. | ||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
Line 429: | Line 439: | ||
=== Get out of jail === | === Get out of jail === | ||
This said, there is an '''easy way out''': Give btrfs more space ;-) | This said, there is an '''easy way out''': Give btrfs more space ;-) | ||
* '''add a partition''' (for example a extern USB-Stick with 8GB) to the btrfs-volume with{{RootCmd|command=btrfs device add /dev/[sdz4] /}} | * '''add a (unformatted) partition''' (for example a fast extern USB-Stick with 8GB) to the btrfs-volume with{{RootCmd|command=btrfs device add /dev/[sdz4] /}} | ||
{{BoxDanger|Do NOT remove this USB-Stick|From now on this partition belongs to your volume! '''Do not boot without it'''. If possible do not reboot at all in this stage! This USB-stick has to stay until '''btrfs device remove''' has '''completed'''.}} | |||
* look for old snapshots you don´t need, remove them '''now''' | * look for old snapshots you don´t need, remove them '''now''' | ||
* '''or delete some files''' you do not need | * '''or delete some files''' you do not need | ||
Line 441: | Line 451: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
* '''balance''' your volume with a filter(50%) This '''will''' take some time ! | * '''balance''' your volume with a filter(50%) This '''will''' take some time !{{RootCmd|command=btrfs balance start -dusage=50 /}} | ||
{{RootCmd|command=btrfs balance start -dusage=50 /}} | {{BoxSuccess|Tip: Want to watch the volume clean up ?|{{UserCmd|command=pamac install procps-ng}}}} | ||
{{BoxSuccess|Tip: Want to watch the volume clean up ?| | {{BoxSuccess||After that inside a terminal: {{RootCmd|command=watch -n 60 btrfs filesystem usage -h / }}}} | ||
{{UserCmd|command=pamac install procps-ng}}}} | * If neccesary '''balance''' your volume with a filter(90%) This '''will''' take some more time !{{RootCmd|command=btrfs balance start -dusage=95 /}} | ||
{{BoxSuccess|After that inside a terminal: | |||
{{RootCmd|command=watch -n 60 btrfs filesystem usage -h / }}}} | |||
* '''balance''' your volume with a filter( | |||
{{RootCmd|command=btrfs balance start -dusage=95 /}} | |||
</div> | </div> | ||
Line 454: | Line 460: | ||
* '''remove the added partition''' from the volume with {{RootCmd|command=btrfs device remove /dev/[sdz4] /}} | * '''remove the added partition''' from the volume with {{RootCmd|command=btrfs device remove /dev/[sdz4] /}} | ||
* This '''will''' take some time ! '''Do not reboot until this step is complete'''. | * This '''will''' take some time ! '''Do not reboot until this step is complete'''. | ||
* | * After "btrfs remove" has finished successfully, you can remove the USB stick. | ||
</div> | </div> | ||