mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-08 21:34:25 +00:00
chore: maintenance of btrfs in kb articles
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
# Sync directories from a Linux source to a Linux destination.
|
# Sync directories from a Linux source to a Linux destination.
|
||||||
# Expand symlink at the source to their referred files.
|
# Expand symlink at the source to their referred files.
|
||||||
# Assumes the same owner and group at both hosts.
|
# Assumes the same owner and group at both hosts.
|
||||||
|
# GNU's `rsync` 3.2.7 does not support ctimes (-N).
|
||||||
rsync 'data/' 'nas.lan:data/' \
|
rsync 'data/' 'nas.lan:data/' \
|
||||||
--secluded-args --no-inc-recursive \
|
--secluded-args --no-inc-recursive \
|
||||||
--archive --copy-links --acls --xattrs --times --atimes --crtimes \
|
--archive --copy-links --acls --xattrs --times --atimes --crtimes \
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ sudo mkfs.btrfs --label "data" /dev/sd{a,c,d,f,g} --force \
|
|||||||
sudo btrfs filesystem show
|
sudo btrfs filesystem show
|
||||||
|
|
||||||
# Show detailed `df` analogue for filesystems.
|
# Show detailed `df` analogue for filesystems.
|
||||||
|
# Also show the filesystem specifications, like metadata replication.
|
||||||
sudo btrfs filesystem df "path/to/filesystem"
|
sudo btrfs filesystem df "path/to/filesystem"
|
||||||
sudo btrfs filesystem df -h "path/to/filesystem"
|
sudo btrfs filesystem df -h "path/to/filesystem"
|
||||||
|
|
||||||
@@ -60,10 +61,18 @@ sudo btrfs subvolume create "path/to/subvolume"
|
|||||||
btrfs subvolume snapshot "${HOME}/path/to/subvolume" "${HOME}/path/to/snapshot"
|
btrfs subvolume snapshot "${HOME}/path/to/subvolume" "${HOME}/path/to/snapshot"
|
||||||
sudo btrfs subvolume snapshot -r "path/to/subvolume" "path/to/snapshot"
|
sudo btrfs subvolume snapshot -r "path/to/subvolume" "path/to/snapshot"
|
||||||
|
|
||||||
# Mount subvolumes without mounting their main filesystem.
|
# Display the ID of the default subvolume.
|
||||||
|
# The default subvolume is the one mounted when no other is specified.
|
||||||
|
btrfs subvolume get-default "path/to/subvolume"
|
||||||
|
|
||||||
|
# Set the default subvolume for a filesystem.
|
||||||
|
btrfs subvolume set-default "subvolume_id" "path/to/root/subvolume"
|
||||||
|
|
||||||
|
# Mount specific subvolumes without mounting the default one.
|
||||||
sudo mount -o 'subvol=sv1' "/dev/sdb" "/mnt"
|
sudo mount -o 'subvol=sv1' "/dev/sdb" "/mnt"
|
||||||
|
|
||||||
# Delete subvolumes.
|
# Delete subvolumes.
|
||||||
|
sudo btrfs subvolume delete -C "path/to/subvolume/1" "path/to/subvolume/n"
|
||||||
sudo btrfs subvolume delete --commit-each "path/to/subvolume"
|
sudo btrfs subvolume delete --commit-each "path/to/subvolume"
|
||||||
|
|
||||||
# Automatically compress new files and folders in directories in BTRFS mounts.
|
# Automatically compress new files and folders in directories in BTRFS mounts.
|
||||||
@@ -87,8 +96,12 @@ btrfs … -ti "path/to/inode"
|
|||||||
btrfs … -td "path/to/device"
|
btrfs … -td "path/to/device"
|
||||||
btrfs … "path/to/autoselected/type/of/resource"
|
btrfs … "path/to/autoselected/type/of/resource"
|
||||||
|
|
||||||
# Change RW subvolumes to RO ones on the fly.
|
# Change RW subvolumes to RO ones on the fly and viceversa.
|
||||||
btrfs property set -ts "path/to/subvolume" 'ro' 'true'
|
btrfs property set -ts "path/to/subvolume" 'ro' 'true'
|
||||||
|
btrfs property set "path/to/subvolume" 'ro' 'false'
|
||||||
|
|
||||||
|
# Enable compression on subvolumes.
|
||||||
|
btrfs property set "path/to/subvolume" 'compression' 'zstd'
|
||||||
|
|
||||||
# Show subvolumes' information.
|
# Show subvolumes' information.
|
||||||
sudo btrfs subvolume show "path/to/subvolume"
|
sudo btrfs subvolume show "path/to/subvolume"
|
||||||
@@ -151,6 +164,13 @@ swapon 'path/to/swapfile'
|
|||||||
# `btrfs` utility >= 6.1 only.
|
# `btrfs` utility >= 6.1 only.
|
||||||
btrfs filesystem mkswapfile --size '2G' 'path/to/swapfile'
|
btrfs filesystem mkswapfile --size '2G' 'path/to/swapfile'
|
||||||
swapon 'path/to/swapfile'
|
swapon 'path/to/swapfile'
|
||||||
|
|
||||||
|
# Create multiple snapshots at once.
|
||||||
|
DATETIME="$(date '+%F_%H-%M-%S')"
|
||||||
|
parallel -qt \
|
||||||
|
btrfs subvolume snapshot -r \
|
||||||
|
"${BTRFS_ROOT}/{}" "${BTRFS_ROOT}/.snapshots/${DATETIME}/{}" \
|
||||||
|
::: $(ls "${BTRFS_ROOT}")
|
||||||
```
|
```
|
||||||
|
|
||||||
## Check differences between 2 snapshots
|
## Check differences between 2 snapshots
|
||||||
@@ -171,6 +191,7 @@ sudo snapper -c 'config' diff '445..446'
|
|||||||
- [Swapfile]
|
- [Swapfile]
|
||||||
- [Gentoo wiki]
|
- [Gentoo wiki]
|
||||||
- [Snapper]
|
- [Snapper]
|
||||||
|
- [Managing the Btrfs File System]
|
||||||
|
|
||||||
## Sources
|
## Sources
|
||||||
|
|
||||||
@@ -187,6 +208,7 @@ All the references in the [further readings] section, plus the following:
|
|||||||
<!-- Upstream -->
|
<!-- Upstream -->
|
||||||
[documentation]: https://btrfs.readthedocs.io/en/latest/
|
[documentation]: https://btrfs.readthedocs.io/en/latest/
|
||||||
[introduction]: https://btrfs.readthedocs.io/en/latest/Introduction.html
|
[introduction]: https://btrfs.readthedocs.io/en/latest/Introduction.html
|
||||||
|
[managing the btrfs file system]: https://docs.oracle.com/en/operating-systems/oracle-linux/9/fsadmin/fsadmin-ManagingtheBtrfsFileSystem.html#btrfs-main
|
||||||
[mkfs.btrfs]: https://btrfs.readthedocs.io/en/latest/mkfs.btrfs.html
|
[mkfs.btrfs]: https://btrfs.readthedocs.io/en/latest/mkfs.btrfs.html
|
||||||
[swapfile]: https://btrfs.readthedocs.io/en/latest/Swapfile.html
|
[swapfile]: https://btrfs.readthedocs.io/en/latest/Swapfile.html
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user