Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Check filesystem #252

Merged
merged 1 commit into from
Dec 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/disk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set -Eeuo pipefail
: ${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_ROTATION:='1'} # Rotation rate, set to 1 for SSD storage and increase for HDD
: ${DISK_FLAGS:='nocow=on'} # Specify the options for use with the qcow2 format
: ${DISK_FLAGS:=''} # Specifies the options for use with the qcow2 disk format

BOOT="$STORAGE/boot.img"
DISK_OPTS="-object iothread,id=io2"
Expand Down Expand Up @@ -267,8 +267,16 @@ checkFS () {
info "Warning: the filesystem of $DIR is OverlayFS, this usually means it was binded to an invalid path!"
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
FA=$(lsattr "$DISK_FILE")
[[ "$FA" == *"C"* ]] && FA=$(lsattr -d "$DIR")
Expand All @@ -277,8 +285,8 @@ checkFS () {
fi

if [[ "$FA" != *"C"* ]]; then
info "Warning: the filesystem of $DIR is BTRFS, 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 "Warning: the filesystem of $DIR is ${FS^^}, and COW (copy on write) is not disabled for that folder!"
info "This will negatively affect performance, please empty the folder and disable COW (chattr +C <path>)."
fi
fi

Expand Down