feat: Check filesystem (#477)

* feat: Check filesystem
This commit is contained in:
Kroese 2023-12-22 15:00:22 +01:00 committed by GitHub
parent 9a97dfdc70
commit 682e0a9952
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 8 deletions

View File

@ -8,7 +8,7 @@ set -Eeuo pipefail
: ${DISK_CACHE:='none'} # Caching mode, can be set to 'writeback' for better performance : ${DISK_CACHE:='none'} # Caching mode, can be set to 'writeback' for better performance
: ${DISK_DISCARD:='on'} # Controls whether unmap (TRIM) commands are passed to the host. : ${DISK_DISCARD:='on'} # Controls whether unmap (TRIM) commands are passed to the host.
: ${DISK_ROTATION:='1'} # Rotation rate, set to 1 for SSD storage and increase for HDD : ${DISK_ROTATION:='1'} # Rotation rate, set to 1 for SSD storage and increase for HDD
: ${DISK_FLAGS:='nocow=on'} # Specifies the options for use with the qcow2 disk format : ${DISK_FLAGS:=''} # Specifies the options for use with the qcow2 disk format
BOOT="$STORAGE/$BASE.boot.img" BOOT="$STORAGE/$BASE.boot.img"
SYSTEM="$STORAGE/$BASE.system.img" SYSTEM="$STORAGE/$BASE.system.img"
@ -272,8 +272,16 @@ checkFS () {
info "Warning: the filesystem of $DIR is OverlayFS, this usually means it was binded to an invalid path!" info "Warning: the filesystem of $DIR is OverlayFS, this usually means it was binded to an invalid path!"
fi fi
if [[ "$FS" == "btrfs"* ]]; then if [[ "$FS" == "xfs" || "$FS" == "zfs" || "$FS" == "btrfs" || "$FS" == "bcachefs" ]]; then
local FLAG="nocow"
if [[ "$DISK_FLAGS" != *"$FLAG="* ]]; then
if [ -z "$DISK_FLAGS" ]; then
DISK_FLAGS="$FLAG=on"
else
DISK_FLAGS="$DISK_FLAGS,$FLAG=on"
fi
fi
if [ -f "$DISK_FILE" ] ; then if [ -f "$DISK_FILE" ] ; then
FA=$(lsattr "$DISK_FILE") FA=$(lsattr "$DISK_FILE")
[[ "$FA" == *"C"* ]] && FA=$(lsattr -d "$DIR") [[ "$FA" == *"C"* ]] && FA=$(lsattr -d "$DIR")
@ -282,8 +290,8 @@ checkFS () {
fi fi
if [[ "$FA" != *"C"* ]]; then if [[ "$FA" != *"C"* ]]; then
info "Warning: the filesystem of $DIR is BTRFS, and COW (copy on write) is not disabled for that folder!" info "Warning: the filesystem of $DIR is ${FS^^}, and COW (copy on write) is not disabled for that folder!"
info "This will negatively affect write performance, please empty the folder and disable COW (chattr +C <path>)." info "This will negatively affect performance, please empty the folder and disable COW (chattr +C <path>)."
fi fi
fi fi

View File

@ -55,11 +55,11 @@ FS=$(stat -f -c %T "$STORAGE")
if [[ "$FS" == "overlay"* ]]; then if [[ "$FS" == "overlay"* ]]; then
info "Warning: the filesystem of $STORAGE is OverlayFS, this usually means it was binded to an invalid path!" info "Warning: the filesystem of $STORAGE is OverlayFS, this usually means it was binded to an invalid path!"
fi fi
if [[ "$FS" == "btrfs"* ]]; then if [[ "$FS" == "xfs" || "$FS" == "zfs" || "$FS" == "btrfs" || "$FS" == "bcachefs" ]]; then
FA=$(lsattr -d "$STORAGE") FA=$(lsattr -d "$STORAGE")
if [[ "$FA" != *"C"* ]]; then if [[ "$FA" != *"C"* ]]; then
info "Warning: the filesystem of $STORAGE is BTRFS, and COW (copy on write) is not disabled for that folder!" info "Warning: the filesystem of $STORAGE is ${FS^^}, and COW (copy on write) is not disabled for that folder!"
info "This will negatively affect write performance, please empty the folder and disable COW (chattr +C <path>)." info "This will negatively affect performance, please empty the folder and disable COW (chattr +C <path>)."
fi fi
fi fi