diff --git a/modules/filesystem/btrfs/btrfs.mod b/modules/filesystem/btrfs/btrfs.mod index ae0f67d..1967679 100644 --- a/modules/filesystem/btrfs/btrfs.mod +++ b/modules/filesystem/btrfs/btrfs.mod @@ -250,7 +250,31 @@ alias btsub="sudo $BTRFS_BIN subvolume" +dir2subvol () { + # Directory to convert into BTRFS subvolume +dirPath="$1" + +getfacl -R "$dirPath" > /tmp/_perms + +# Rename original dierctory +sudo mv "${dirPath}" "${dirPath}_original" + +# Create btrfs subvolume +sudo $BTRFS_BIN subvolume create "${dirPath}" + +# Copy as "reflink" for speed and save space +sudo cp --archive --one-file-system --reflink=always \ + "${dirPath}_original/." "${dirPath}" + +# Remove old directory +sudo rm -rf --one-file-system "${dirPath}_original" + +setfacl --restore=/tmp/_perms + +rm -f /tmp/_perms + +} diff --git a/modules/utility/copy.lib b/modules/utility/copy.lib index 8f91a26..df25678 100644 --- a/modules/utility/copy.lib +++ b/modules/utility/copy.lib @@ -21,7 +21,7 @@ copy () { cat < source destination --- +rsync