-
Notifications
You must be signed in to change notification settings - Fork 27
btrfs
on Ubuntu 16.04, btrfs-progs version is 4.4.
The following table lists valid btrfs profiles.
┌────────┬────────────────────────────────────┬─────────────────┐
│Profile │ Redundancy │ Min/max devices │
│ ├──────────────┬────────┬────────────┤ │
│ │ Copies │ Parity │ Striping │ │
├────────┼──────────────┼────────┼────────────┼─────────────────┤
│single │ 1 │ │ │ 1/any │
├────────┼──────────────┼────────┼────────────┼─────────────────┤
│ DUP │ 2 / 1 device │ │ │ 1/1 (see note) │
├────────┼──────────────┼────────┼────────────┼─────────────────┤
│ RAID0 │ │ │ 1 to N │ 2/any │
├────────┼──────────────┼────────┼────────────┼─────────────────┤
│ RAID1 │ 2 │ │ │ 2/any │
├────────┼──────────────┼────────┼────────────┼─────────────────┤
│RAID10 │ 2 │ │ 1 to N │ 4/any │
├────────┼──────────────┼────────┼────────────┼─────────────────┤
│ RAID5 │ 1 │ 1 │ 2 to N - 1 │ 2/any │
├────────┼──────────────┼────────┼────────────┼─────────────────┤
│ RAID6 │ 1 │ 2 │ 3 to N - 2 │ 3/any │
└────────┴──────────────┴────────┴────────────┴─────────────────┘
By default, for 1 drive, mkfs.btrfs
use DUP and single mode for metadata and data respectively.
xenial@xenial:~$ sudo mkfs.btrfs /dev/sdb -f
btrfs-progs v4.4
See http://btrfs.wiki.kernel.org for more information.
Label: (null)
UUID: 93fd18e3-ba66-43d1-8940-81c32f81a81c
Node size: 16384
Sector size: 4096
Filesystem size: 40.00GiB
Block group profiles:
Data: single 8.00MiB
Metadata: DUP 1.01GiB
System: DUP 12.00MiB
SSD detected: no
Incompat features: extref, skinny-metadata
Number of devices: 1
Devices:
ID SIZE PATH
1 40.00GiB /dev/sdb
And for 2 drivers, raid0 for data and raid1 for metadata/system.
sudo mkfs.btrfs /dev/sdb /dev/sdc -f
btrfs-progs v4.4
See http://btrfs.wiki.kernel.org for more information.
Label: (null)
UUID: f8ac9f67-efe2-4a50-9cac-14f34c8f883d
Node size: 16384
Sector size: 4096
Filesystem size: 80.00GiB
Block group profiles:
Data: RAID0 2.01GiB
Metadata: RAID1 1.01GiB
System: RAID1 12.00MiB
SSD detected: no
Incompat features: extref, skinny-metadata
Number of devices: 2
Devices:
ID SIZE PATH
1 40.00GiB /dev/sdb
2 40.00GiB /dev/sdc
The profile can be changed by btrfs balance
command with convert filter
, but multiple steps are required. See following example:
xenial@xenial:~$ sudo mkfs.btrfs -f /dev/sdb /dev/sdc
xenial@xenial:~$ sudo mount /dev/sdb mnt
xenial@xenial:~$ sudo btrfs fi usage mnt
Overall:
Device size: 80.00GiB
Device allocated: 4.02GiB
Device unallocated: 75.98GiB
Device missing: 0.00B
Used: 1.00MiB
Free (estimated): 77.98GiB (min: 39.99GiB)
Data ratio: 1.00
Metadata ratio: 2.00
Global reserve: 16.00MiB (used: 0.00B)
Data,RAID0: Size:2.00GiB, Used:768.00KiB
/dev/sdb 1.00GiB
/dev/sdc 1.00GiB
Metadata,RAID1: Size:1.00GiB, Used:112.00KiB
/dev/sdb 1.00GiB
/dev/sdc 1.00GiB
System,RAID1: Size:8.00MiB, Used:16.00KiB
/dev/sdb 8.00MiB
/dev/sdc 8.00MiB
Unallocated:
/dev/sdb 37.99GiB
/dev/sdc 37.99GiB
xenial@xenial:~$ sudo btrfs balance start -dconvert=raid1 mnt
Done, had to relocate 1 out of 3 chunks
xenial@xenial:~$ sudo btrfs fi usage mnt
Overall:
Device size: 80.00GiB
Device allocated: 6.02GiB
Device unallocated: 73.98GiB
Device missing: 0.00B
Used: 2.25MiB
Free (estimated): 58.49GiB (min: 39.99GiB)
Data ratio: 1.33
Metadata ratio: 2.00
Global reserve: 16.00MiB (used: 0.00B)
Data,RAID0: Size:2.00GiB, Used:0.00B
/dev/sdb 1.00GiB
/dev/sdc 1.00GiB
Data,RAID1: Size:1.00GiB, Used:1.00MiB
/dev/sdb 1.00GiB
/dev/sdc 1.00GiB
Metadata,RAID1: Size:1.00GiB, Used:112.00KiB
/dev/sdb 1.00GiB
/dev/sdc 1.00GiB
System,RAID1: Size:8.00MiB, Used:16.00KiB
/dev/sdb 8.00MiB
/dev/sdc 8.00MiB
Unallocated:
/dev/sdb 36.99GiB
/dev/sdc 36.99GiB
xenial@xenial:~$ sudo btrfs balance start mnt
Done, had to relocate 4 out of 4 chunks
xenial@xenial:~$ sudo btrfs fi usage mnt
Overall:
Device size: 80.00GiB
Device allocated: 4.06GiB
Device unallocated: 75.94GiB
Device missing: 0.00B
Used: 1.25MiB
Free (estimated): 38.97GiB (min: 38.97GiB)
Data ratio: 2.00
Metadata ratio: 2.00
Global reserve: 16.00MiB (used: 0.00B)
Data,RAID1: Size:1.00GiB, Used:512.00KiB
/dev/sdb 1.00GiB
/dev/sdc 1.00GiB
Metadata,RAID1: Size:1.00GiB, Used:112.00KiB
/dev/sdb 1.00GiB
/dev/sdc 1.00GiB
System,RAID1: Size:32.00MiB, Used:16.00KiB
/dev/sdb 32.00MiB
/dev/sdc 32.00MiB
Unallocated:
/dev/sdb 37.97GiB
/dev/sdc 37.97GiB
So, the convert procedure should take two steps:
sudo btrfs balance start -dconvert=<profile> <mountpoint>
sudo btrfs balance start <mountpoint>
This is a workaround definition:
S1 : One disk, d:single, m:dup, s:dup, this is the default setting for 1 disk S20: Tow disks, d:raid0, m:raid1, s:raid1, this is the default setting for 2 disks S21: Two disks, d:raid1, m:raid1, s:raid1
Create volume with no option, results in S1
mkfs.btrfs <devname>
No operation. Remind: umount before creating volume