179 shaares
2 results
tagged
btrfs
GENERAL
create filesystem
mkfs.btrfs -f -L $LABEL $DEVICE1 $DEVICE2 ...
# mount subvolume with ssd options & lzo compression
UUID=$UUID $PATHTMP btrfs defaults,noatime,ssd,discard,autodefrag,compress=lzo,space_cache,inode_cache,subvol=save 0 2
# mount device with noauto mounting
UUID=$UUID $PATHTMP btrfs defaults,noauto,noatime0 2
BTRFS
btrfs filesystem
command group othat primarily does work on the whole filesystems
btrfs filesystem <subcommand> <args>
show # show global configuration
show $vol # show information
usage $vol # show detailed information
df $vol # list occupied spaces
defragment $vol # defragment
label $vol $label # get or set label to filesystem
btrfs subvolume
manage btrfs subvolumes
btrfs subvolume <subcommand> [<args>]
create $path # create subvolume
delete $path # delete subvolume
list $path # list major properties of subvolume
set-default $ID $path # set a subvolume a default of device
mount a subvolume
mount [-o ...] subvol=$path <device> <path-system>
btrfs property
get/set/list properties for given filesystem object
btrfs property <subcommand> <args>
list $PATH # list properties of $PATH
-ts list $PATH # list only rw properties of $PATH
get $PATH # return rw property of $PATH
set -ts $PATH ro false # set property of $PATH to RWrite
set -ts $PATH ro true # set property of $PATH to ROnly
UUID
btrfstune -u /dev/sdaX # get UUID of device
btrfstune -U $UUID /dev/sdaX # set the UUID for device
INTEGRITY
btrfs device
manage devices of btrfs filesystems
btrfs device <subcommand> <args>
stats $path-device # show history stats
ready <device> # Wait until all devices of a multiple-device filesystem are scanned and registered within the kernel module
scan <device> # Scan devices for a btrfs filesystem and register them with the kernel module
btrfs scrub
scrub btrfs filesystem, verify block checksums
btrfs scrub <subcommand> <args>
start $path-device # start a scrub
status $path-device # return stats on scrub launched
btrfs check
check or repair an unmounted btrfs filesystem
btrfs check [options] <device>
btrfs check $vol # check an unmounted btrfs filesystem
-b|--backup # use the first valid set of backup roots stored in the superblock
--check-data-csum # verify checksums of data blocks
--chunk-root <bytenr> # use the given offset bytenr for the chunk tree root
-E|--subvol-extents <subvolid> # show extent state for the given subvolume
-p|--progress # indicate progress at various checking phases
--repair # enable the repair mode and attempt to fix problems where possible
SNAPSHOT
btrfs subvolume
manage btrfs subvolumes
btrfs subvolume <subcommand> [<args>]
snapshot $vol $snap # create a RWrite snapshot
snapshot -r $vol $snap # create a ROnly snapshot
delete $vol/$snap # delete snapshot
create [-i <qgroupid>] [<dest>/]<name> # Create a subvolume <name> in <dest>
-i <qgroupid>Add the newly created subvolume to a qgroup
delete [options] <subvolume> [<subvolume>...] # Delete the subvolume(s) from the filesystem
-c|--commit-after # wait for transaction commit at the end of the operation
-C|--commit-each # wait for transaction commit after deleting each subvolume
find-new <subvolume> <last_gen> # List the recently modified files in a subvolume, after <last_gen> ID
get-default <path> # Get the default subvolume of the filesystem <path>
list [options] [-G [+|-]<value>] [-C [+|-]<value>] [--sort=rootid,gen,ogen,path] <path> # List the subvolumes present in the filesystem <path>
-p # print parent ID
-a # print all the subvolumes in the filesystem and distinguish between absolute and relative path with respect to the given <path>
-c # print the ogeneration of the subvolume, aliases: ogen or origin generation
-g # print the generation of the subvolume
-o # print only subvolumes below specified <path>
-u # print the UUID of the subvolume
-q # print the parent uuid of subvolumes (and snapshots)
-R # print the UUID of the sent subvolume, where the subvolume is the result of a receive operation
-t # print the result as a table
-s # only snapshot subvolumes in the filesystem will be listed
-r # only readonly subvolumes in the filesystem will be listed
-G [+|-]<value> # list subvolumes in the filesystem that its generation is >= ⟨+), <= (-)
--sort=rootid,gen,ogen,path # list subvolumes in order by specified items
QGROUP
https://linuxfr.org/users/ar7/journaux/btrfs-et-opensuse-episode-5-les-quotas
BACKUP/RESTORE
https://ramsdenj.com/2016/04/05/using-btrfs-for-easy-backup-and-rollback.html
https://wiki.evolix.org/HowtoBTRFS
https://github.com/digint/btrbk
basic backup
btrfs subvolume snapshot -r $vol $snap # create a ro snapshot
btrfs send <snapshot> | gzip -c > $path # backup to compressed file
gzip -dc $path | btrfs receive <pathto/> # restore from compressed file
btrfs property set -ts <pathto> ro false # to mount volume
credential backup
btrfs subvolume snapshot -r / /my/snapshot-date && sync
btrfs send /my/snapshot-YYYY-MM-DD | ssh user@host btrfs receive /my/backups
btrfs subvolume snapshot -r / /my/incremental-snapshot-YYYY-MM-DD && sync
btrfs send -p /my/snapshot-YYYY-MM-DD /my/incremental-snapshot-YYYY-MM-DD | ssh user@host btrfs receive /backup/home
save the streams
btrfs subvolume snapshot -r / /my/snapshot-YYYY-MM-DD && sync
btrfs send /my/snapshot-YYYY-MM-DD | ssh user@host 'cat >/backup/home/snapshot-YYYY-MM-DD.btrfs'
btrfs subvolume snapshot -r / /my/incremental-snapshot-YYYY-MM-DD && sync
btrfs send -p /my/snapshot-YYYY-MM-DD /my/incremental-snapshot-YYYY-MM-DD | ssh user@host 'cat >/backup/home/incremental-snapshot-YYYY-MM-DD.btrfs'
PARTCLONE
# clone, backup & restore partition
https://manpages.ubuntu.com/manpages/disco/man8/partclone.btrfs.8.html
# clone /dev/hda1 to hda1.img and display debug information.
partclone.ext3 -c -d -s /dev/hda1 -o hda1.img
# restore /dev/hda1 from hda1.img and display debug information.
partclone.extfs -r -d -s hda1.img -o /dev/hda1
# restore image from clonezilla(split, gzip,) with stdin source
cat sda1.ext3-ptcl-img.gz.a* | gunzip -c | partclone.ext3 -d -r -s - -o /dev/sda1
recover/rescue
https://ownyourbits.com/2019/03/03/how-to-recover-a-btrfs-partition/
CONFIG
snapper list-configs # show list of configuration
snapper -c $config
create-config $file # create configuration file
delete-config # delete configuration file
get-config # show config value
set-config $key="$valeur" # set a key/value for a config
SNAPSHOT
snapper -c $config
# list snapshot refer to a config
list
# create a snapshot with description & print id
create --d $DESC -p
# create a 'pre' snapshot
create -t pre --d $DESC -p
# create a 'post' snapshot that refer to pre id
create -t post --pre-number $ID
# create a snapshot
create --d $DESC
# create a pre/post snapshot with command inside
create --command $CMD
# delete snapshot id1
delete $ID
# delete snapshot between id1 & idn
delete $ID1-$ID2
# modify values for snapshot id
modify -$OPTION $valeur $ID
# give a list of changed files between $ID1 & $ID2
status $ID1..$ID2
# show diff of files between $ID1 & $ID2
diff $ID1..$ID2 $fileS
# compare extended attributes of files between $ID1 & $ID2
xadiff $ID1..$ID2 $fileS
# Undo changes on files presents in $file between $ID1 & $ID2
undochange $ID1..$ID2 -i $file
# Undo changes on files between $ID1 & $ID2
undochange $ID1..$ID2 $fileS
```bash