Btrfs is an open-source, general-purpose file system for Linux. The name derives from the use of B-trees to store internal file system structures. Different names are used for the file system, including “Butter F S” and “B-tree F S.” Development of Btrfs began at Oracle in 2007, and now a number of companies (including Red Hat, Fujitsu, Intel, SUSE, and many others) are contributing to the development effort. Btrfs is included in the mainline Linux kernel.

 

btrfs device Utilities

 

Use the btrfs device command to manage devices on Btrfs file systems. A list of the available commands is as follows:

# btrfs device
usage: btrfs device [command] [args]

    btrfs device add [options] [device] [device...] [path]
        Add a device to a filesystem
    btrfs device delete [device]|[devid] [device|devid...] [path]
    btrfs device remove [device]|[devid] [device|devid...] [path]
        Remove a device from a filesystem
    btrfs device scan [(-d|--all-devices)|[device] [device...]]
        Scan devices for a btrfs filesystem
    btrfs device ready [device]
        Check device to see if it has all of its devices in cache for mounting
    btrfs device stats [options] [path]|[device]
        Show device IO error statistics
    btrfs device usage [options] [path] [path..]
        Show detailed information about internal allocations in devices.

manage and query devices in the filesystem

 

The btrfs device scan command scans physical devices looking for members of a Btrfs volume. This command allows a multiple-disk Btrfs file system to be mounted without specifying all the disks on the mount command.

 

You do not need to run “btrfs device scan” from the command line, because udev automatically runs btrfs device scan on boot. Use the btrfs device add command to add a device to a file system. In this example, the current file system structure is as follows:

Use the btrfs device command to manage devices on Btrfs file systems. A list of the available commands is as follows:

# btrfs filesystem show
Label: none  uuid: ba60ac96-1628-4656-b68b-c7327ff49179
	Total devices 1 FS bytes used 325.29MiB
	devid    1 size 10.00GiB used 867.66MiB path /dev/sda

 

The btrfs filesystem df command shows:

# btrfs filesystem df /btrfs
Data, single: total=547.66MiB, used=324.75MiB
System, single: total=32.00MiB, used=16.00KiB
Metadata, single: total=288.00MiB, used=528.00KiB
GlobalReserve, single: total=16.00MiB, used=0.00B

 

The output of the df command shows:

# df -h /btrfs
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda         10G  342M  9.4G   4% /btrfs

 

Add a 10 GB disk, /dev/sdb, to the file system mounted on /btrfs by using the btrfs device add command:

# btrfs device add /dev/sdb /btrfs

 

The output of the btrfs filesystem show command shows the newly added device:

# btrfs filesystem show
Label: none  uuid: ba60ac96-1628-4656-b68b-c7327ff49179
	Total devices 2 FS bytes used 325.29MiB
	devid    1 size 10.00GiB used 867.66MiB path /dev/sda
	devid    2 size 10.00GiB used 0.00B path /dev/sdb

 

The output of the btrfs filesystem df command shows no difference after adding the new device:

# btrfs filesystem df /btrfs
Data, single: total=547.66MiB, used=324.75MiB
System, single: total=32.00MiB, used=16.00KiB
Metadata, single: total=288.00MiB, used=528.00KiB
GlobalReserve, single: total=16.00MiB, used=0.00B

 

There is no difference in the output because the newly added device has not yet been allocated for either data or metadata. The additional size is reflected in the output of df:

# df -h /btrfs
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda         20G  342M   20G   2% /btrfs

 

After adding a device, it is recommended that you run the following balance command on the file system:

# btrfs filesystem balance /btrfs
WARNING:

	Full balance without filters requested. This operation is very
	intense and takes potentially very long. It is recommended to
	use the balance filters to narrow down the balanced data.
	Use 'btrfs balance start --full-balance' option to skip this
	warning. The operation will start in 10 seconds.
	Use Ctrl-C to stop it.
10 9 8 7 6 5 4 3 2 1
Starting balance without any filters.
Done, had to relocate 17 out of 17 chunks

 

Running this command redistributes space by balancing the chunks of the file system across all the devices. This command also reclaims any wasted space. Use the btrfs device delete command to remove a device from a file system. Example:

# btrfs device delete /dev/sdb /btrfs

 

¿Fue útil la respuesta? 0 Los Usuarios han Encontrado Esto Útil (0 Votos)