Hi Chris,
1) thank you very much for the amazing explanation.
Il giorno gio 30 giu 2016 alle ore 18:20 Chris Murphy
On Thu, Jun 30, 2016 at 8:24 AM, Francesco Montesano
wrote: Hi,
2016-06-30 0:44 GMT+02:00 Chris Murphy
: On Wed, Jun 29, 2016 at 1:52 PM, Francesco Montesano [...]
You could try 'btrfs balance start -dusage=25 /' which should free up one or more data block groups into unallocated space so that Btrfs can reallocate it as a metadata block group if needed.
~> sudo btrfs balance start -dusage=25 / Done, had to relocate 0 out of 54 chunks ~> sudo btrfs balance status / No balance found on '/'
OK there are no empyt or nearly empty chunks.
The problem with a full balance is that it is CoW. That's good and bad. Good because it should be safe. Bad because Btrfs must have unallocated space to create a new chunk to copy extents into before it can deallocate the origin chunk. But there is no unallocated space on this file system.
There are two options:
1. You delete a bunch of snapshots and hopefully an entire data chunk becomes empty and therefore reverts to unallocated, and now Btrfs can make it into a metadata chunk, which seems not quite chrystal clear is what it wants to do. There's no guarantee this frees up an entire chunk, as snapshots can reference extents across chunks.
I've tried removing some of the oldest snapshots. I cleared some space: Data,single: Size:38.23GiB, Used:27.35GiB /dev/sdb2 38.23GiB Metadata,single: Size:1.75GiB, Used:1.09GiB /dev/sdb2 1.75GiB System,single: Size:32.00MiB, Used:16.00KiB /dev/sdb2 32.00MiB Then I've tried to run the balance command with -dusage 25 with no success. Then I tried: sudo btrfs balance start -dusage=50 / ERROR: error during balancing '/': No space left on device There may be more info in syslog - try dmesg | tail Given your explanation it makes sense, as I guess the balance needs disk space (metadata?) that apparently is not that abundant. In one of your messaged you talked about fragmentation; should I try to run "btrfs fi defragment"?
2. You need to make more unallocated space available by temporarily adding another device to the volume. Now you can do a balance, and then remove the extra device so that you're back to a single device volume. This device doesn't need to be big, in fact the smaller the better (up to a point). I'd say even a 2GiB USB stick is adequate. A 4GiB or 8GiB is better. If it's bigger than 8GiB I'd partition it, with an 8GiB partition and then point btrfs to that partition. Why? Btrfs will try to make the free space on each device the same, so the more free space on the USB stick, the more it'll use it. And the USB stick is slow. Slower than a hard drive, unless this is a fast USB 3.0 stick.
So it looks like this:
btrfs dev add /dev/sdXY / ###where XY is the block device and partition you intend to use. btrfs fi show ## will show this is now a two device Btrfs volume btrfs balance start --dusage=100 ### this will completely rewrite all data chunks, some of which will end up on the USB stick so you cannot physical disconnect it until it's removed from the volume
The balance might take a while depending on the speed of the devices. Not much will be written to the USB stick. But for 38GiB it could take maybe 10 minutes if it's a hard drive. And maybe a couple minutes on SSD. If you want to watch this, you can use & after the balance command, and then use top or iotop to keep track of Btrfs activity.
btrfs fi show ##will give you an idea of how much is used on the stick so you can estimate how long device removal should take Once the balance completes, the metadata and data on the USB stick is returned back to the first device like this:
btrfs dev rem /dev/sdXY / ###where XY is the same as before, for the USB stick you're removing, could be slow and take a minute or 10 minutes depending on how much is used.
Once that command returns to prompt, you can confirm:
btrfs fi show
And see that the volume is now a single device volume again. Only then is it safe to physically disconnect the USB stick.
I'll wait a day or two to see how btrfs behaves after removing the snapshot. If nothing happens, I'll try this. Ciao, Fra
-- Chris Murphy
-- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-factory+owner@opensuse.org