Skip to content

Commit

Permalink
add trim filesystem
Browse files Browse the repository at this point in the history
  • Loading branch information
BassT23 committed Dec 14, 2024
1 parent 48f235b commit f36718a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions change.log
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Changelog:
- fix ioBroker Upgrade
- fix arch upgrade
- add autoclean for debian based systems
- add filesystem trim for ext4 systems

**v4.2** (01.12.2024)
- fix VM Template error
Expand Down
32 changes: 16 additions & 16 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,22 @@ EXTRAS () {
fi
}

# Trim Filesystem
TRIM_FILESYSTEM () {
if [[ "INCLUDE_FSTRIM" == true ]]; then
ROOT_FS=$(df -Th "/" | awk 'NR==2 {print $2}')
if [ "$ROOT_FS" = "ext4" ]; then
echo -e "${OR}--- Trimming filesystem ---${CL}"
local BEFORE_TRIM=$(lvs | awk -F '[[:space:]]+' 'NR>1 && (/Data%|'"vm-$CONTAINER"'/) {gsub(/%/, "", $7); print $7}')
echo -e "${RD}Data before trim $BEFORE_TRIM%${CL}"
pct fstrim $CONTAINER
local AFTER_TRIM=$(lvs | awk -F '[[:space:]]+' 'NR>1 && (/Data%|'"vm-$CONTAINER"'/) {gsub(/%/, "", $7); print $7}')
echo -e "${GN}Data after trim $AFTER_TRIM%${CL}\n"
sleep 1.5
fi
fi
}

# Check Updates for Welcome-Screen
UPDATE_CHECK () {
if [[ "$WELCOME_SCREEN" == true ]]; then
Expand All @@ -454,22 +470,6 @@ UPDATE_CHECK () {
fi
}

# Trim Filesystem
TRIM_FILESYSTEM () {
if [[ "INCLUDE_FSTRIM" == true ]]; then
ROOT_FS=$(df -Th "/" | awk 'NR==2 {print $2}')
if [ "$ROOT_FS" = "ext4" ]; then
echo -e "${OR}--- Trimming filesystem ---${CL}"
local BEFORE_TRIM=$(lvs | awk -F '[[:space:]]+' 'NR>1 && (/Data%|'"vm-$CONTAINER"'/) {gsub(/%/, "", $7); print $7}')
echo -e "${RD}Data before trim $BEFORE_TRIM%${CL}"
pct fstrim $CONTAINER
local AFTER_TRIM=$(lvs | awk -F '[[:space:]]+' 'NR>1 && (/Data%|'"vm-$CONTAINER"'/) {gsub(/%/, "", $7); print $7}')
echo -e "${GN}Data after trim $AFTER_TRIM%${CL}\n"
sleep 1.5
fi
fi
}

## HOST ##
# Host Update Start
HOST_UPDATE_START () {
Expand Down

0 comments on commit f36718a

Please sign in to comment.