Skip to content

Commit

Permalink
os-helpers-fs: regenerate_uuid: skip remounting
Browse files Browse the repository at this point in the history
Remounting filesystems is done on systems with a broken clock in order
to prevent tune2fs from bailing out when the last mounted time is in the
future. This resets the last mounted time to now.

However, the filesystem is immediately unmounted again without being
utilized, and the mount and unmount process is time consuming. Instead,
use `-e continue` to tell tune2fs to continue after an error, which
achieves the same result with less time and complexity.

Change-type: patch
Signed-off-by: Joseph Kogut <joseph@balena.io>
  • Loading branch information
jakogut authored and alexgg committed May 3, 2024
1 parent 53e995b commit 7674716
Showing 1 changed file with 1 addition and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,22 +145,11 @@ regenerate_uuid() {
fi
;;
ext*)
# tune2fs refuses to work when the filesystem was not
# freshly checked.
# Remount to update lastmount time to current time
# Otherwise in systems with no RTC lastmount could be in the future
# and e2fsck does not update the last filesystem check time
if [ -e /etc/e2fsck.conf ] && grep broken_system_clock /etc/e2fsck.conf > /dev/null; then
broken_system_clock=$(grep broken_system_clock /etc/e2fsck.conf | cut -d "=" -f2)
if [ "${broken_system_clock}" = "1" ]; then
update_mounttime "$dev"
fi
fi
if ! e2fsck -fp "$dev"; then
return 1
fi
new_uuid=$(sed 's/^[^-]*/ba1eadef/' < /proc/sys/kernel/random/uuid)
cmd="echo y | EXT2FS_NO_MTAB_OK=1 tune2fs -U ${new_uuid}"
cmd="echo y | EXT2FS_NO_MTAB_OK=1 tune2fs -e continue -U ${new_uuid}"
if ! eval "${cmd}" "${dev}"; then
return 1
fi
Expand Down

0 comments on commit 7674716

Please sign in to comment.