{
    "mode": "info",
    "parameter": "BTRFS-DEVICE",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/info/BTRFS-DEVICE/json",
    "generated": "2026-07-05T13:19:29Z",
    "synopsis": "btrfs device <subcommand> <args>",
    "sections": {
        "NAME": {
            "content": "btrfs-device - manage devices of btrfs filesystems\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "btrfs device <subcommand> <args>\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The btrfs device command group is used to manage devices of the btrfs\nfilesystems.\n",
            "subsections": []
        },
        "DEVICE MANAGEMENT": {
            "content": "Btrfs filesystem can be created on top of single or multiple block\ndevices. Data and metadata are organized in allocation profiles with\nvarious redundancy policies. There's some similarity with traditional\nRAID levels, but this could be confusing to users familiar with the\ntraditional meaning. Due to the similarity, the RAID terminology is\nwidely used in the documentation. See mkfs.btrfs(8) for more details\nand the exact profile capabilities and constraints.\n\nThe device management works on a mounted filesystem. Devices can be\nadded, removed or replaced, by commands provided by btrfs device and\nbtrfs replace.\n\nThe profiles can be also changed, provided there's enough workspace to\ndo the conversion, using the btrfs balance command and namely the\nfilter convert.\n\nType\nThe block group profile type is the main distinction of the\ninformation stored on the block device. User data are called Data,\nthe internal data structures managed by filesystem are Metadata and\nSystem.\n\nProfile\nA profile describes an allocation policy based on the\nredundancy/replication constraints in connection with the number of\ndevices. The profile applies to data and metadata block groups\nseparately. Eg.  single, RAID1.\n\nRAID level\nWhere applicable, the level refers to a profile that matches\nconstraints of the standard RAID levels. At the moment the\nsupported ones are: RAID0, RAID1, RAID10, RAID5 and RAID6.\n\nSee the section TYPICAL USECASES for some examples.\n",
            "subsections": []
        },
        "SUBCOMMAND": {
            "content": "add [-Kf] <device> [<device>...] <path>\nAdd device(s) to the filesystem identified by <path>.\n\nIf applicable, a whole device discard (TRIM) operation is performed\nprior to adding the device. A device with existing filesystem\ndetected by blkid(8) will prevent device addition and has to be\nforced. Alternatively the filesystem can be wiped from the device\nusing eg. the wipefs(8) tool.\n\nThe operation is instant and does not affect existing data. The\noperation merely adds the device to the filesystem structures and\ncreates some block groups headers.\n\nOptions\n\n-K|--nodiscard\ndo not perform discard (TRIM) by default\n\n-f|--force\nforce overwrite of existing filesystem on the given disk(s)\n\n--enqueue\nwait if there's another exclusive operation running, otherwise\ncontinue\n\nremove [options] <device>|<devid> [<device>|<devid>...] <path>\nRemove device(s) from a filesystem identified by <path>\n\nDevice removal must satisfy the profile constraints, otherwise the\ncommand fails. The filesystem must be converted to profile(s) that\nwould allow the removal. This can typically happen when going down\nfrom 2 devices to 1 and using the RAID1 profile. See the TYPICAL\nUSECASES section below.\n\nThe operation can take long as it needs to move all data from the\ndevice.\n\nIt is possible to delete the device that was used to mount the\nfilesystem. The device entry in the mount table will be replaced by\nanother device name with the lowest device id.\n\nIf the filesystem is mounted in degraded mode (-o degraded),\nspecial term missing can be used for device. In that case, the\nfirst device that is described by the filesystem metadata, but not\npresent at the mount time will be removed.\n\nNote\nIn most cases, there is only one missing device in degraded\nmode, otherwise mount fails. If there are two or more devices\nmissing (e.g. possible in RAID6), you need specify missing as\nmany times as the number of missing devices to remove all of\nthem.\nOptions\n\n--enqueue\nwait if there's another exclusive operation running, otherwise\ncontinue\n\ndelete <device>|<devid> [<device>|<devid>...] <path>\nAlias of remove kept for backward compatibility\n\nready <device>\nWait until all devices of a multiple-device filesystem are scanned\nand registered within the kernel module. This is to provide a way\nfor automatic filesystem mounting tools to wait before the mount\ncan start. The device scan is only one of the preconditions and the\nmount can fail for other reasons. Normal users usually do not need\nthis command and may safely ignore it.\n\nscan [options] [<device> [<device>...]]\nScan devices for a btrfs filesystem and register them with the\nkernel module. This allows mounting multiple-device filesystem by\nspecifying just one from the whole group.\n\nIf no devices are passed, all block devices that blkid reports to\ncontain btrfs are scanned.\n\nThe options --all-devices or -d can be used as a fallback in case\nblkid is not available. If used, behavior is the same as if no\ndevices are passed.\n\nThe command can be run repeatedly. Devices that have been already\nregistered remain as such. Reloading the kernel module will drop\nthis information. There's an alternative way of mounting\nmultiple-device filesystem without the need for prior scanning. See\nthe mount option device.\n\nOptions\n\n-d|--all-devices\nEnumerate and register all devices, use as a fallback in case\nblkid is not available.\n\n-u|--forget\nUnregister a given device or all stale devices if no path is\ngiven, the device must be unmounted otherwise it's an error.\n\nstats [options] <path>|<device>\nRead and print the device IO error statistics for all devices of\nthe given filesystem identified by <path> or for a single <device>.\nThe filesystem must be mounted. See section DEVICE STATS for more\ninformation about the reported statistics and the meaning.\n\nOptions\n\n-z|--reset\nPrint the stats and reset the values to zero afterwards.\n\n-c|--check\nCheck if the stats are all zeros and return 0 if it is so. Set\nbit 6 of the return code if any of the statistics is no-zero.\nThe error values is 65 if reading stats from at least one\ndevice failed, otherwise it's 64.\n\nusage [options] <path> [<path>...]\nShow detailed information about internal allocations on devices.\n\nThe level of detail can differ if the command is run under a\nregular or the root user (due to use of restricted ioctls). The\nfirst example below is for normal user (warning included) and the\nnext one with root on the same filesystem:\n\nWARNING: cannot read detailed chunk info, per-device usage will not be shown, run as root\n/dev/sdc1, ID: 1\nDevice size:           931.51GiB\nDevice slack:              0.00B\nUnallocated:           931.51GiB\n\n/dev/sdc1, ID: 1\nDevice size:           931.51GiB\nDevice slack:              0.00B\nData,single:           641.00GiB\nData,RAID0/3:            1.00GiB\nMetadata,single:        19.00GiB\nSystem,single:          32.00MiB\nUnallocated:           271.48GiB\n\no   Device size -- size of the device as seen by the filesystem\n(may be different than actual device size)\n\no   Device slack -- portion of device not used by the filesystem\nbut still available in the physical space provided by the\ndevice, eg. after a device shrink\n\no   Data,single, Metadata,single, System,single -- in general, list\nof block group type (Data, Metadata, System) and profile\n(single, RAID1, ...) allocated on the device\n\no   Data,RAID0/3 -- in particular, striped profiles\nRAID0/RAID10/RAID5/RAID6 with the number of devices on which\nthe stripes are allocated, multiple occurrences of the same\nprofile can appear in case a new device has been added and all\nnew available stripes have been used for writes\n\no   Unallocated -- remaining space that the filesystem can still\nuse for new block groups\n\nOptions\n\n-b|--raw\nraw numbers in bytes, without the B suffix\n\n-h|--human-readable\nprint human friendly numbers, base 1024, this is the default\n\n-H\nprint human friendly numbers, base 1000\n\n--iec\nselect the 1024 base for the following options, according to\nthe IEC standard\n\n--si\nselect the 1000 base for the following options, according to\nthe SI standard\n\n-k|--kbytes\nshow sizes in KiB, or kB with --si\n\n-m|--mbytes\nshow sizes in MiB, or MB with --si\n\n-g|--gbytes\nshow sizes in GiB, or GB with --si\n\n-t|--tbytes\nshow sizes in TiB, or TB with --si\n\nIf conflicting options are passed, the last one takes precedence.\n",
            "subsections": []
        },
        "TYPICAL USECASES": {
            "content": "STARTING WITH A SINGLE-DEVICE FILESYSTEM\nAssume we've created a filesystem on a block device /dev/sda with\nprofile single/single (data/metadata), the device size is 50GiB and\nwe've used the whole device for the filesystem. The mount point is\n/mnt.\n\nThe amount of data stored is 16GiB, metadata have allocated 2GiB.\n\nADD NEW DEVICE\nWe want to increase the total size of the filesystem and keep the\nprofiles. The size of the new device /dev/sdb is 100GiB.\n\n$ btrfs device add /dev/sdb /mnt\n\nThe amount of free data space increases by less than 100GiB, some\nspace is allocated for metadata.\n\nCONVERT TO RAID1\nNow we want to increase the redundancy level of both data and\nmetadata, but we'll do that in steps. Note, that the device sizes\nare not equal and we'll use that to show the capabilities of split\ndata/metadata and independent profiles.\n\nThe constraint for RAID1 gives us at most 50GiB of usable space and\nexactly 2 copies will be stored on the devices.\n\nFirst we'll convert the metadata. As the metadata occupy less than\n50GiB and there's enough workspace for the conversion process, we\ncan do:\n\n$ btrfs balance start -mconvert=raid1 /mnt\n\nThis operation can take a while, because all metadata have to be\nmoved and all block pointers updated. Depending on the physical\nlocations of the old and new blocks, the disk seeking is the key\nfactor affecting performance.\n\nYou'll note that the system block group has been also converted to\nRAID1, this normally happens as the system block group also holds\nmetadata (the physical to logical mappings).\n\nWhat changed:\n\no   available data space decreased by 3GiB, usable roughly (50 - 3)\n+ (100 - 3) = 144 GiB\n\no   metadata redundancy increased\n\nIOW, the unequal device sizes allow for combined space for data yet\nimproved redundancy for metadata. If we decide to increase\nredundancy of data as well, we're going to lose 50GiB of the second\ndevice for obvious reasons.\n\n$ btrfs balance start -dconvert=raid1 /mnt\n\nThe balance process needs some workspace (ie. a free device space\nwithout any data or metadata block groups) so the command could\nfail if there's too much data or the block groups occupy the whole\nfirst device.\n\nThe device size of /dev/sdb as seen by the filesystem remains\nunchanged, but the logical space from 50-100GiB will be unused.\n\nREMOVE DEVICE\nDevice removal must satisfy the profile constraints, otherwise the\ncommand fails. For example:\n\n$ btrfs device remove /dev/sda /mnt\nERROR: error removing device '/dev/sda': unable to go below two devices on raid1\n\nIn order to remove a device, you need to convert the profile in\nthis case:\n\n$ btrfs balance start -mconvert=dup -dconvert=single /mnt\n$ btrfs device remove /dev/sda /mnt\n",
            "subsections": []
        },
        "DEVICE STATS": {
            "content": "The device stats keep persistent record of several error classes\nrelated to doing IO. The current values are printed at mount time and\nupdated during filesystem lifetime or from a scrub run.\n\n$ btrfs device stats /dev/sda3\n[/dev/sda3].writeioerrs   0\n[/dev/sda3].readioerrs    0\n[/dev/sda3].flushioerrs   0\n[/dev/sda3].corruptionerrs 0\n[/dev/sda3].generationerrs 0\n\nwriteioerrs\nFailed writes to the block devices, means that the layers beneath\nthe filesystem were not able to satisfy the write request.\n\nreadioerrors\nRead request analogy to writeioerrs.\n\nflushioerrs\nNumber of failed writes with the FLUSH flag set. The flushing is a\nmethod of forcing a particular order between write requests and is\ncrucial for implementing crash consistency. In case of btrfs, all\nthe metadata blocks must be permanently stored on the block device\nbefore the superblock is written.\n\ncorruptionerrs\nA block checksum mismatched or a corrupted metadata header was\nfound.\n\ngenerationerrs\nThe block generation does not match the expected value (eg. stored\nin the parent node).\n\nSince kernel 5.14 the device stats are also available in textual form\nin /sys/fs/btrfs/FSID/devinfo/DEVID/errorstats.\n",
            "subsections": []
        },
        "EXIT STATUS": {
            "content": "btrfs device returns a zero exit status if it succeeds. Non zero is\nreturned in case of failure.\n\nIf the -s option is used, btrfs device stats will add 64 to the exit\nstatus if any of the error counters is non-zero.\n",
            "subsections": []
        },
        "AVAILABILITY": {
            "content": "btrfs is part of btrfs-progs. Please refer to the btrfs wiki\nhttp://btrfs.wiki.kernel.org for further details.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "mkfs.btrfs(8), btrfs-replace(8), btrfs-balance(8)\n\nBtrfs v5.16.2                     02/16/2022                   BTRFS-DEVICE(8)",
            "subsections": []
        }
    },
    "summary": "btrfs-device - manage devices of btrfs filesystems",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "mkfs.btrfs",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/mkfs.btrfs/8/json"
        },
        {
            "name": "btrfs-replace",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/btrfs-replace/8/json"
        },
        {
            "name": "btrfs-balance",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/btrfs-balance/8/json"
        }
    ]
}