I can't mount my filesystem, and I get a kernel oops!
If the kernel oops in your logs has something like this in the middle of it, then it's probably fixable easily:
? replay_one_dir_item+0xb5/0xb5 [btrfs] ? walk_log_tree+0x9c/0x19d [btrfs] ? btrfs_read_fs_root_no_radix+0x169/0x1a1 [btrfs] ? btrfs_recover_log_trees+0x195/0x29c [btrfs] ? replay_one_dir_item+0xb5/0xb5 [btrfs] ? btree_read_extent_buffer_pages+0x76/0xbc [btrfs] ? open_ctree+0xff6/0x132c [btrfs]
If you have errors like this, then your log tree is probably corrupt, and removing it will allow you to mount the filesystem again. You will lose the last few seconds of activity on the filesystem from before your original corruption (up to 30 seconds), but you will at least have a mountable FS. If you are not sure whether you have a situation that these instructions apply to, please ask on the mailing list or on IRC.
You will need to build and run the
btrfs-zero-log tool: get a recent copy of the user-space tools, and build them:
$ make $ make btrfs-zero-log $ sudo btrfs-zero-log /dev/sda1
(replacing /dev/sda1 with whatever device your FS resides on)
Filesystem can't be mounted by label
See the next section.
Only one disk of a multi-volume filesystem will mount
If you have labelled your filesystem and put it in /etc/fstab, but you get:
# mount LABEL=foo mount: wrong fs type, bad option, bad superblock on /dev/sdd2, missing codepage or helper program, or other error In some cases useful info is found in syslog - try dmesg | tail or so
or if one volume of a multi-volume filesystem fails when mounting, but the other succeeds:
# mount /dev/sda1 /mnt/fs mount: wrong fs type, bad option, bad superblock on /dev/sdd2, missing codepage or helper program, or other error In some cases useful info is found in syslog - try dmesg | tail or so # mount /dev/sdb1 /mnt/fs #
Then you need to ensure that you run a btrfs device scan first:
# btrfs device scan
This should be in many distributions' startup scripts (and initrd images, if your root filesystem is btrfs), but you may have to add it yourself.
Defragmenting a directory doesn't work
# btrfs filesystem defragment ~/stuff
doesn't defragment the contents of the directory.
This is by design. btrfs fi defrag operates on the single filesystem object passed to it. This means that the command defragments just the metadata held by the directory object, and not the contents of the directory. If you want to defragment the contents of the directory, something like this would be more useful:
# find -type f -xdev -print0 | xargs -0 btrfs fi defrag
Caveat: Defragmenting a file which has a COW copy (either a snapshot copy or one made with cp --reflink or bcp) will produce two unrelated files. If you defragment a subvolume that has a snapshot, you will roughly double the disk usage, as the snapshot files are no longer COW images of the originals.
Compression doesn't work / poor compression ratios
First of all make sure you have passed "compress" mount option in fstab or mount command.
If yes, and ratios are unsatisfactory, then you might try "compress-force" option.
This way you make the btrfs to compress everything.
The reason why "compress" ratios are so low is because btrfs very easily backs out of compress decision. (Probably not to waste too much CPU time on bad compressing data).
Copy-on-write doesn't work
You've just copied a large file, but still it consumed free space. Try:
# cp --reflink=always file1 file2