saltstack/salt — pull request #17282 by isbm (2014-11-07 21:50:49+00:00)
Title: BTRFS module

Hi!
Since BTRFS is a flagship filesystem in **SUSE Linux Enterprise 12** and is offered by default (along with XFS for ``/home``, module of which already merged), I would like to introduce BTRFS management module.

*NOTE: The module has some obvious duplication with XFS module, but this is intentionally: once current version of BTRFS module is merged, they will be brought to the common procedures, since they differ and need an additional polishing.*

This module allows you to make filesystems, manage RAID arrays, scan, resize, get all required information and even reliably migrate from Ext2/Ext3/Ext4. Some additional features are still coming, but it already does initial not so very bad job and therefore I would like to just "release it early". :-)

Some examples:
```
e212:~ # salt '*' btrfs.info /foo
d122.suse.de:
----------
/dev/sdb1:
----------
device_id:
1
size:
5.00GiB
used:
0.00B
/dev/sdb2:
----------
device_id:
2
size:
4.99GiB
used:
1.28GiB
label:
None
uuid:
2bf3713d-603e-4fc3-a671-ce6b55517642
e212:~ # salt '*' btrfs.delete /foo /dev/sdb2 force=True
d122.suse.de:
----------
/dev/sdb1:
----------
device_id:
1
size:
5.00GiB
used:
800.00MiB
label:
None
uuid:
2bf3713d-603e-4fc3-a671-ce6b55517642
e212:~ # salt '*' btrfs.mkfs /dev/sdb2 label='My Great Storage'
d122.suse.de:
----------
/dev/sdb2:
----------
device_id:
1
size:
4.99GiB
used:
546.62MiB
label:
'My Great Storage'
log:
Btrfs v3.16+20140829
See http://btrfs.wiki.kernel.org for more information.

Turning ON incompat feature 'extref': increased hardlink limit per file to 65536
Turning ON incompat feature 'skinny-metadata': reduced-size metadata extent refs
fs created label bubamara on /dev/sdb2
nodesize 16384 leafsize 16384 sectorsize 4096 size 4.99GiB
uuid:
067275df-7265-46a6-aed1-2aee720d979f

e212:~ # salt '*' btrfs.add /foo /dev/sdb2 force=True
d122.suse.de:
----------
/dev/sdb1:
----------
device_id:
1
size:
5.00GiB
used:
0.00B
/dev/sdb2:
----------
device_id:
2
size:
4.99GiB
used:
1.28GiB
label:
None
log:
Done, had to relocate 3 out of 3 chunks
uuid:
2bf3713d-603e-4fc3-a671-ce6b55517642

e212:~ # salt '*' btrfs.properties /foo set="label='My great storage'"
d122.suse.de:
None
e212:~ # salt '*' btrfs.properties /foo
d122.suse.de:
----------
compression:
----------
description:
Set/get compression for a file or directory
value:
N/A
label:
----------
description:
Set/get label of device.
value:
My great storage
ro:
----------
description:
Set/get read-only flag of subvolume.
value:
false
```