Difference between revisions of "Btrfs Maintenance"

retranslated some text2
(rrd)
(retranslated some text2)
Line 37: Line 37:
btrfs will mount the subvolume read-write.
btrfs will mount the subvolume read-write.


== Manual Maintenace ==
== Manual Maintenance ==
From time to time it may be advisable to check the health of the volume.
From time to time it may be advisable to check the health of a btrfs volume.
{{BoxInfo|Notice| Be aware,  that with btrfs all maintenance is performed on a normally running system. The volume can be fully used. Even a shutdown during such an action is not problematic. Btrfs will continue to execute the action after the next boot until it completes.}}
{{BoxInfo|Note| Btrfs is used to perform all maintenance on '''a normally running system'''. The volume can be fully used. Shutting down during such an action is also unproblematic. Btrfs will keep running the action after the next launch until it completes.}}


=== usage ===
 
Look if everything is OK with the unallocated space on your volume.
=== Usage ===
Check if the '''unallocated''' space on your volume is ok.


==== check unallocated space ====
==== check unallocated space ====


{{RootCmd|command=btrfs filesystem usage -h /}}
{{RootCmd|command=btrfs filesystem usage -h /}}
Pay special attention to the unallocated space !


The commonly used term "free" is meaningless to btrfs users. Even if you have 50% of your volume "free", you may run out of storage space. **You must pay attention to the term unallocated**.
{{BoxWarning|Pay special attention to '''unallocated''' !|The commonly used term "free" is meaningless to btrfs users. Even if you have 50% of your volume "free", you can run out of storage space. }}


Try to keep at least 10% of your volume unallocated. If this is below 10%:
Try to leave '''at least 10%''' of your volume unallocated. If this got below 10%:
* expand your volume to double size (see: [[Btrfs]])
* Expand the volume to double size (see: [[Btrfs]])
* delete some unused data
* Delete some unused data
* delete some old snapshots
* Delete some old snapshots
* balance ([[Btrfs]])
* Balance ([[Btrfs]])


==== clean up unused snapshots ====
==== Clean up unused snapshots ====
From time to time it is necessary to check if you have snapshots that you do not need any more, but that hold valuable space on your volume.
From time to time it is necessary to check if you have snapshots that you no longer need but that are taking up valuable space on your volume.


=== balance your free space ===
=== Balance your free disk space ===
If you have some space "free" on your volume, but the unallocated space is below 10% (or close to 10%), you can help btrfs to rebalance some chunks.
If you have some "free" space on your volume, but the unallocated space is below 10% (or close to 10%), you can help btrfs to rebalance some parts.


{{RootCmd|command=btrfs balance start -musage=50 -dusage=50 /}}
{{RootCmd|command=btrfs balance start -musage=50 -dusage=50 /}}
Btrfs looks for chunks that contain more than 50% free space. It will take 2 of them and then move everything into a new chunk. After that, one chunk is released. This continues until each chunk is at least 50% full.
Btrfs looks for chunks that contain more than 50% free space. It will take 2 of them and then move everything into a new chunk. After that, a chunk is released. This continues until each chunk is at least 50% full.


This will give you some unallocated(free) chunks that help btrfs **not** to get out of space.
This will give you some unallocated (free) chunks that help btrfs **not** to get out of space.


If you have less than 20% unallocated space, please do the following:
If you have less than 20% unallocated space, please do the following:
{{RootCmd|command=btrfs balance start -musage=75 -dusage=75 /}}  
{{RootCmd|command=btrfs balance start -musage=75 -dusage=75 /}}
Btrfs looks for chunks that are less than 75% full.
Btrfs looks for chunks that are less than 75% full.
It will take 4 of them and then move everything into 3 new chunks. After that, one chunk can be released. This continues until each chunk is at least 75% full.
It will take 4 of them and then move everything into 3 new chunks. After that, a chunk can be released. This continues until each chunk is at least 75% full.


If you still have less than 20% unallocated space, please do the following:
If you still have less than 20% unallocated space, please do the following:
{{RootCmd|command=btrfs balance start -musage=90 -dusage=90 /}}  
{{RootCmd|command=btrfs balance start -musage=90 -dusage=90 /}}
 


=== scrub ===
=== scrub ===
Check if everything is ok with the checksums and the readability of your data. **Only do this when in doubt**. This may take a long time as btrfs has to read ALL the data. Btrfs only scans the portion of your volume that actually contains data.
Check if everything is ok with the checksums and the readability of your data. '''Only do this when in doubt'''. This may take a long time as btrfs has to read ALL the data. Btrfs only scans the portion of your volume that actually contains data.


{{RootCmd|command=btrfs scrub start -Bd /}}
{{RootCmd|command=btrfs scrub start -Bd /}}


Tip:watch -d btrfs scrub status /
 
{{BoxSuccess|Want to watch how btrfs works ?|
{{UserCmd|command=pamac install procps-ng}}}}
{{BoxSuccess|After that inside a separate terminal:|
{{RootCmd|command=watch -n 60 btrfs filesystem usage -h / }}}}


== special cases ==
== special cases ==
translator
987

edits