-
Notifications
You must be signed in to change notification settings - Fork 53
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
Add fsck to dracut modules #1352
Changes from all commits
949af5d
c0dbdc3
9284c9d
5697990
f0632ba
877c82d
7d838a4
8b0e5e3
d7e8df3
aaa808a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: "base-dracut-modules" | ||
category: "system" | ||
version: 0.1.1-29 | ||
version: "0.1.2" | ||
description: "Base modules for creating an initrd with dracut for cOS derivatives" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,16 +9,38 @@ function doLoopMount { | |
label=$(basename "${dev}") | ||
[ -e "/tmp/cosloop-${label}" ] && continue | ||
> "/tmp/cosloop-${label}" | ||
|
||
mount -t auto -o "${cos_root_perm}" "/dev/disk/by-label/${label}" "${cos_state}" || continue | ||
if [ -f "${cos_state}/${cos_img}" ]; then | ||
losetup -f "${cos_state}/${cos_img}" | ||
|
||
# FSCHECK if cos_root_perm == "ro" on both | ||
if [ "$cos_root_perm" == "ro" ]; then | ||
systemd-fsck "/dev/disk/by-label/${label}" | ||
fi | ||
|
||
dev=$(losetup --show -f "${cos_state}/${cos_img}") | ||
|
||
# FSCHECK if cos_root_perm == "ro" | ||
if [ "$cos_root_perm" == "ro" ]; then | ||
systemd-fsck "$dev" | ||
fi | ||
|
||
exit 0 | ||
else | ||
umount "${cos_state}" | ||
fi | ||
done | ||
} | ||
|
||
function dofsCheck { | ||
# Iterate over current partitions | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @davidcassany here while testing I corrupted COS_PERSISTENT in a way that no labels were properly detected anymore, but by running efsck on the disk id manually I could restore them just fine. When no labels are identified, it just skips all our loops, as we loop over labels Since this could happen, I'm back at scanning all the partitions found. I'm not sure if this is maybe too invasive on some front and maybe better to make it opt-in - but on the other hand I don't see why someone would disable a fscheck integrity utility running on boot. I guess, in that case |
||
# As fs corruption could lead to partitions with no label, we scan here for all partitions found and we run systemd-fsck | ||
for dev in /dev/disk/by-partuuid/*; do | ||
partuuid=$(basename "${dev}") | ||
systemd-fsck "/dev/disk/by-partuuid/${partuuid}" | ||
done | ||
} | ||
|
||
type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh | ||
|
||
PATH=/usr/sbin:/usr/bin:/sbin:/bin | ||
|
@@ -37,6 +59,7 @@ ismounted "${cos_state}" && exit 0 | |
|
||
mkdir -p "${cos_state}" | ||
|
||
dofsCheck | ||
doLoopMount | ||
|
||
rm -r "${cos_state}" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,13 @@ steps: | |
{{ if .Values.distribution }} | ||
{{if eq .Values.distribution "opensuse" }} | ||
# Mount /tmp as tmpfs by default as set by systemd itself | ||
- cp /usr/share/systemd/tmp.mount /etc/systemd/system | ||
- | | ||
/bin/bash -c " \ | ||
if [ -e /usr/share/systemd/tmp.mount ]; then \ | ||
cp /usr/share/systemd/tmp.mount /etc/systemd/system; \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this something to do with the underlying distro change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could be, note that TW alreay has this mountpoint by default, probably SLE for rancher too. The old logic was valid when opensuse meant leap, if we include TW, this logic is safer. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yup exactly, this happens to be in two different places - tw and leap have it differently |
||
else \ | ||
cp /usr/lib/systemd/system/tmp.mount /etc/systemd/system; \ | ||
fi " | ||
{{end}} | ||
{{end}} | ||
- cp -r 30cos-immutable-rootfs /usr/lib/dracut/modules.d | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: "dracut-initrd" | ||
category: "system" | ||
version: 0.2-8 | ||
version: "0.3" | ||
description: "Dracut-based generated initrd" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any
fsck.repair
definition, hence I guess this is something thatsystemd-fsck
parses, right? If this something custom from our side I'd suggest defining it with therd.cos...
prefix, I think it is not the case though, just to double check.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, those are read by systemd-fsck directly, so we don't need to do any special handling ourselves 🥳