2019-02-16 22:53:18 +03:00
|
|
|
|
[38;5;246m# Create a btrfs file system on /dev/sdb, /dev/sdc, and /dev/sdd[39m
|
|
|
|
|
[38;5;252mmkfs.btrfs[39m[38;5;252m [39m[38;5;252m/dev/sdb[39m[38;5;252m [39m[38;5;252m/dev/sdc[39m[38;5;252m [39m[38;5;252m/dev/sdd[39m
|
|
|
|
|
|
|
|
|
|
[38;5;246m# btrfs with just one hard drive, metadata not redundant [39m
|
|
|
|
|
[38;5;246m# (this is danegerous: if your metadata is lost, your data is lost as well)[39m
|
|
|
|
|
[38;5;252mmkfs.btrfs[39m[38;5;252m [39m[38;5;252m-m[39m[38;5;252m [39m[38;5;252msingle[39m[38;5;252m [39m[38;5;252m/dev/sdb[39m
|
|
|
|
|
|
|
|
|
|
[38;5;246m# data to be redundant and metadata to be non-redundant:[39m
|
|
|
|
|
[38;5;252mmkfs.btrfs[39m[38;5;252m [39m[38;5;252m-m[39m[38;5;252m [39m[38;5;252mraid0[39m[38;5;252m [39m[38;5;252m-d[39m[38;5;252m [39m[38;5;252mraid1[39m[38;5;252m [39m[38;5;252m/dev/sdb[39m[38;5;252m [39m[38;5;252m/dev/sdc[39m[38;5;252m [39m[38;5;252m/dev/sdd[39m
|
|
|
|
|
|
|
|
|
|
[38;5;246m# both data and metadata to be redundan[39m
|
|
|
|
|
[38;5;252mmkfs.btrfs[39m[38;5;252m [39m[38;5;252m-d[39m[38;5;252m [39m[38;5;252mraid1[39m[38;5;252m [39m[38;5;252m/dev/sdb[39m[38;5;252m [39m[38;5;252m/dev/sdc[39m[38;5;252m [39m[38;5;252m/dev/sdd[39m
|
|
|
|
|
|
|
|
|
|
[38;5;246m# To get a list of all btrfs file systems[39m
|
|
|
|
|
[38;5;252mbtrfs[39m[38;5;252m [39m[38;5;252mfilesystem[39m[38;5;252m [39m[38;5;252mshow[39m
|
|
|
|
|
|
|
|
|
|
[38;5;246m# detailed df for a fileesystem (mounted in /mnt)[39m
|
|
|
|
|
[38;5;252mbtrfs[39m[38;5;252m [39m[38;5;252mfilesystem[39m[38;5;252m [39m[38;5;252mdf[39m[38;5;252m [39m[38;5;252m/mnt[39m
|
|
|
|
|
|
|
|
|
|
[38;5;246m# resize btrfs online (-2g decreases, +2g increases)[39m
|
|
|
|
|
[38;5;252mbtrfs[39m[38;5;252m [39m[38;5;252mfilesystem[39m[38;5;252m [39m[38;5;252mresize[39m[38;5;252m [39m[38;5;252m-2g[39m[38;5;252m [39m[38;5;252m/mnt[39m
|
|
|
|
|
|
|
|
|
|
[38;5;246m# use maximum space[39m
|
|
|
|
|
[38;5;252mbtrfs[39m[38;5;252m [39m[38;5;252mfilesystem[39m[38;5;252m [39m[38;5;252mresize[39m[38;5;252m [39m[38;5;252mmax[39m[38;5;252m [39m[38;5;252m/mnt[39m
|
|
|
|
|
|
|
|
|
|
[38;5;246m# add new device to a filesystem[39m
|
|
|
|
|
[38;5;252mbtrfs[39m[38;5;252m [39m[38;5;252mdevice[39m[38;5;252m [39m[38;5;252madd[39m[38;5;252m [39m[38;5;252m/dev/sdf[39m[38;5;252m [39m[38;5;252m/mnt[39m
|
|
|
|
|
|
|
|
|
|
[38;5;246m# remove devices from a filesystem[39m
|
|
|
|
|
[38;5;252mbtrfs[39m[38;5;252m [39m[38;5;252mdevice[39m[38;5;252m [39m[38;5;252mdelete[39m[38;5;252m [39m[38;5;252mmissing[39m[38;5;252m [39m[38;5;252m/mnt[39m
|
|
|
|
|
|
2018-08-03 10:37:18 +03:00
|
|
|
|
[38;5;246m# create the subvolume /mnt/sv1 in the /mnt volume[39m
|
|
|
|
|
[38;5;252mbtrfs[39m[38;5;252m [39m[38;5;252msubvolume[39m[38;5;252m [39m[38;5;252mcreate[39m[38;5;252m [39m[38;5;252m/mnt/sv1[39m
|
2019-02-16 22:53:18 +03:00
|
|
|
|
|
|
|
|
|
[38;5;246m# list subvolumes[39m
|
|
|
|
|
[38;5;252mbtrfs[39m[38;5;252m [39m[38;5;252msubvolume[39m[38;5;252m [39m[38;5;252mlist[39m[38;5;252m [39m[38;5;252m/mnt[39m
|
|
|
|
|
|
|
|
|
|
[38;5;246m# mount subvolume without mounting the main filesystem[39m
|
|
|
|
|
[38;5;252mmount[39m[38;5;252m [39m[38;5;252m-o[39m[38;5;252m [39m[38;5;87msubvol[39m[38;5;252m=[39m[38;5;252msv1[39m[38;5;252m [39m[38;5;252m/dev/sdb[39m[38;5;252m [39m[38;5;252m/mnt[39m
|
|
|
|
|
|
|
|
|
|
[38;5;246m# delete subvolume[39m
|
|
|
|
|
[38;5;252mbtrfs[39m[38;5;252m [39m[38;5;252msubvolume[39m[38;5;252m [39m[38;5;252mdelete[39m[38;5;252m [39m[38;5;252m/mnt/sv1[39m
|
|
|
|
|
|
|
|
|
|
[38;5;246m# taking snapshot of a subvolume[39m
|
|
|
|
|
[38;5;252mbtrfs[39m[38;5;252m [39m[38;5;252msubvolume[39m[38;5;252m [39m[38;5;252msnapshot[39m[38;5;252m [39m[38;5;252m/mnt/sv1[39m[38;5;252m [39m[38;5;252m/mnt/sv1_snapshot[39m
|
|
|
|
|
|
|
|
|
|
[38;5;246m# taking snapshot of a file (copy file by reference)[39m
|
|
|
|
|
[38;5;252mcp[39m[38;5;252m [39m[38;5;252m--reflink[39m[38;5;252m [39m[38;5;252m/mnt/sv1/test1[39m[38;5;252m [39m[38;5;252m/mnt/sv1/test3[39m
|
|
|
|
|
|
|
|
|
|
[38;5;246m# convert ext3/ext4 to btrfs[39m
|
|
|
|
|
[38;5;252mbtrfs-convert[39m[38;5;252m [39m[38;5;252m/dev/sdb1[39m
|
|
|
|
|
|
|
|
|
|
[38;5;246m# convert btrfs to ext3/ext4[39m
|
|
|
|
|
[38;5;252mbtrfs-convert[39m[38;5;252m [39m[38;5;252m-r[39m[38;5;252m [39m[38;5;252m/dev/sdb1[39m
|