1

Since I run today in a problem with a full disk, which turns out is not unbalanced. Which you can fix with btrfs balance.

So my question is:

Is there any risk by ruining this by a cron job? (in cases where my laptop go to sleep)

4
  • Balance is for when you add a new disk to the fs; it is not something you do on a regular basis.
    – psusi
    Nov 16, 2014 at 21:47
  • @psusi that was what I thought first, but btrfs balance also free up unused blocks. A detailed description is here marc.merlins.org/perso/btrfs/… Nov 17, 2014 at 7:30
  • That article is misleading. While it is true that btrfs df reports only chunk usage, which can be higher than actual usage if chunks are only partly used, df reports a proper amount of free space. Partially filled chunks don't matter so there is no reason to bother with a balance simply to make the output of btrfs df look nicer. In other words, free blocks are free blocks, whether they are part of a chunk or not; either way they are available for use by files on demand.
    – psusi
    Nov 17, 2014 at 14:09
  • Well but if you have Mis-balanced data chunks and the disk is 100% full programs start to crash because they can't write Nov 17, 2014 at 16:05

1 Answer 1

1

Sir I33tname gave you the answer.

However you should be running separate cron job that checks for nearly full disks. This is an idea how to do that, NOT necessarily a perfect solution for your situation

Use cronjob -e to add this (example change names of directories and files): 0,10,20,30,40,50 * * * * /path/to/my/script.sh 2>>/path/to/logfile

script.sh has something like this (check the output of df -h -- I am assuming col #5 is the %full, and this assumes 90% is the start of problems and you have email setup):

 #!/bin/bash
 df -h  | awk 'INT($5)>80 { print }{next}' > /path/to/diskfull.txt
 [  -s /path/to/diskfull.txt ] && /usr/bin/mailx -s 'disk full error ' [your email name here ] < /path/to/diskfull.txt
2
  • I think this is the best solution if I can't automate the balance, I consider it and mark it eventually as answer if nobody find a better solution. Nov 17, 2014 at 7:37
  • In my case this wouldn't work because btrfs said the disk is full. Almost any task ended up in no space left on device, but when I checked df -h it told me /dev/mapper/cryptroot 93G 59G 35G 64% /. But there was another command that showed me the full filesystem: btrfs fi show: devid 1 size 92.68GiB used 92.68GiB path /dev/mapper/cryptroot. Jan 16, 2017 at 11:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .