salt.modules.btrfs

Module for managing BTRFS file systems.

salt.modules.btrfs.add(mountpoint, *devices, **kwargs)

Add a devices to a BTRFS filesystem.

General options:

  • nodiscard: Do not perform whole device TRIM
  • force: Force overwrite existing filesystem on the disk

CLI Example:

salt '*' btrfs.add /mountpoint /dev/sda1 /dev/sda2
salt.modules.btrfs.convert(device, permanent=False, keeplf=False)

Convert ext2/3/4 to BTRFS. Device should be mounted.

Filesystem can be converted temporarily so the further processing and rollback is possible, or permanently, where previous extended filesystem image gets deleted. Please note, permanent conversion takes a while as BTRFS filesystem needs to be properly rebalanced afterwards.

General options:

  • permanent: Specify if the migration should be permanent (false by default)

  • keeplf: Keep lost+found of the partition (removed by default,

    but still in the image, if not permanent migration)

CLI Example:

salt '*' btrfs.convert /dev/sda1
salt '*' btrfs.convert /dev/sda1 permanent=True
salt.modules.btrfs.defragment(path)

Defragment mounted BTRFS filesystem. In order to defragment a filesystem, device should be properly mounted and writable.

If passed a device name, then defragmented whole filesystem, mounted on in. If passed a moun tpoint of the filesystem, then only this mount point is defragmented.

CLI Example:

salt '*' btrfs.defragment /dev/sda1
salt '*' btrfs.defragment /path/on/filesystem
salt.modules.btrfs.delete(mountpoint, *devices, **kwargs)

Remove devices from a BTRFS filesystem.

CLI Example:

salt '*' btrfs.delete /mountpoint /dev/sda1 /dev/sda2
salt.modules.btrfs.devices()

Get known BTRFS formatted devices on the system.

CLI Example:

salt '*' btrfs.devices
salt.modules.btrfs.features()

List currently available BTRFS features.

CLI Example:

salt '*' btrfs.mkfs_features
salt.modules.btrfs.info(device)

Get BTRFS filesystem information.

CLI Example:

salt '*' btrfs.info /dev/sda1
salt.modules.btrfs.mkfs(*devices, **kwargs)

Create a file system on the specified device. By default wipes out with force.

General options:

  • allocsize: Specify the BTRFS offset from the start of the device.
  • bytecount: Specify the size of the resultant filesystem.
  • nodesize: Node size.
  • leafsize: Specify the nodesize, the tree block size in which btrfs stores data.
  • noforce: Prevent force overwrite when an existing filesystem is detected on the device.
  • sectorsize: Specify the sectorsize, the minimum data block allocation unit.
  • nodiscard: Do not perform whole device TRIM operation by default.
  • uuid: Pass UUID or pass True to generate one.

Options:

  • dto: (raid0|raid1|raid5|raid6|raid10|single|dup)

    Specify how the data must be spanned across the devices specified.

  • mto: (raid0|raid1|raid5|raid6|raid10|single|dup)

    Specify how metadata must be spanned across the devices specified.

  • fts: Features (call salt <host> btrfs.features for full list of available features)

See the mkfs.btrfs(8) manpage for a more complete description of corresponding options description.

CLI Example:

salt '*' btrfs.mkfs /dev/sda1
salt '*' btrfs.mkfs /dev/sda1 noforce=True
salt.modules.btrfs.properties(obj, type=None, set=None)

List properties for given btrfs object. The object can be path of BTRFS device, mount point, or any directories/files inside the BTRFS filesystem.

General options:

  • type: Possible types are s[ubvol], f[ilesystem], i[node] and d[evice].
  • force: Force overwrite existing filesystem on the disk
  • set: <key=value,key1=value1...> Options for a filesystem properties.

CLI Example:

salt '*' btrfs.properties /mountpoint
salt '*' btrfs.properties /dev/sda1 type=subvol set='ro=false,label="My Storage"'
salt.modules.btrfs.resize(mountpoint, size)

Resize filesystem.

General options:

  • mountpoint: Specify the BTRFS mountpoint to resize.
  • size: ([+/-]<newsize>[kKmMgGtTpPeE]|max) Specify the new size of the target.

CLI Example:

salt '*' btrfs.resize /mountpoint size=+1g
salt '*' btrfs.resize /dev/sda1 size=max
salt.modules.btrfs.usage(path)

Show in which disk the chunks are allocated.

CLI Example:

salt '*' btrfs.usage /your/mountpoint
salt.modules.btrfs.version()

Return BTRFS version.

CLI Example:

salt '*' btrfs.version