blob: 7419dceef50f1e23e3701463d9366a8a97e9e480 [file] [log] [blame]
# Copyright 2023 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
description "Trim the thinly provisioned user filesystem"
author ""
stop on stopping ui
# The job can be later restarted.
oom score -100
# Note that this should be very fast on thinly-provisioned filesystems.
get_volume_group() {
local physical_volume="$1"
pvs -qq --readonly --noheadings --separator '|' \
-o vg_name "${physical_volume}" | tr -d '[:space:]'
# Example root dev types we need to handle: /dev/sda2 -> /dev/sda,
# /dev/mmcblk0p0 -> /dev/mmcblk0p, /dev/ubi2_1 -> /dev/ubi
STATE_DEV="$(rootdev -s | sed 's/[0-9_]*$//')1"
VG_NAME="$(get_volume_group "${STATE_DEV}")"
if [ -n "${VG_NAME}" ]; then
fstrim -v /home/chronos/user
end script