Message ID | 20240626134141.74487-2-clara.kowalsky@siemens.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [isar-cip-core,v2,1/2] initramfs-overlay-hook: Add INITRAMFS_OVERLAY_MOUNT_OPTION | expand |
On 26.06.24 15:41, Clara Kowalsky wrote: > In case of ext*, this detects and fixes file system errors in the > partition device before doing the partition mount. > > Signed-off-by: Clara Kowalsky <clara.kowalsky@siemens.com> > --- > .../initramfs-overlay-hook/files/overlay.hook | 10 ++++++++-- > .../initramfs-overlay-hook/files/overlay.script.tmpl | 8 +++++++- > 2 files changed, 15 insertions(+), 3 deletions(-) > > diff --git a/recipes-initramfs/initramfs-overlay-hook/files/overlay.hook b/recipes-initramfs/initramfs-overlay-hook/files/overlay.hook > index 8b00ecf..1a54853 100644 > --- a/recipes-initramfs/initramfs-overlay-hook/files/overlay.hook > +++ b/recipes-initramfs/initramfs-overlay-hook/files/overlay.hook > @@ -22,6 +22,12 @@ esac > > . /usr/share/initramfs-tools/hook-functions > > +hook_error() { > + echo "(ERROR): $1" >&2 > + exit 1 > +} > + > manual_add_modules overlay > -copy_exec /usr/bin/mountpoint > -copy_exec /usr/bin/awk > +copy_exec /usr/bin/mountpoint || hook_error "/usr/bin/mountpoint not found" > +copy_exec /usr/bin/awk || hook_error "/usr/bin/awk not found" > +copy_exec /usr/sbin/e2fsck || hook_error "/usr/sbin/e2fsck not found" > diff --git a/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl b/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl > index 42eb59c..6b404c6 100644 > --- a/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl > +++ b/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl > @@ -34,9 +34,15 @@ ovl_mount_option="${INITRAMFS_OVERLAY_MOUNT_OPTION}" > > root_mount_storage=${rootmnt}${ovl_storage_path} > storage_mount_point="$(echo "${ovl_storage_path}" | awk -F/ '{print FS$2}' )" > +partition_fstype=$(get_fstype "${ovl_partition_device}") > > if ! mountpoint -q "${rootmnt}${storage_mount_point}"; then > - if ! mount -t $(get_fstype ${ovl_partition_device}) \ > + if [ $partition_fstype = "ext*" ]; then > + if ! e2fsck -p -f "$partition_fstype"; then > + panic "E2fsck on ${ovl_partition_device} not successful!" Err, this will break the boot without even a chance to go back to factory state, no? Jan > + fi > + fi > + if ! mount -t ${partition_fstype} \ > -o ${ovl_mount_option} \ > ${ovl_partition_device} \ > ${rootmnt}${storage_mount_point}; then
On 6/26/24 3:56 PM, Jan Kiszka wrote: > On 26.06.24 15:41, Clara Kowalsky wrote: >> In case of ext*, this detects and fixes file system errors in the >> partition device before doing the partition mount. >> >> Signed-off-by: Clara Kowalsky <clara.kowalsky@siemens.com> >> --- >> .../initramfs-overlay-hook/files/overlay.hook | 10 ++++++++-- >> .../initramfs-overlay-hook/files/overlay.script.tmpl | 8 +++++++- >> 2 files changed, 15 insertions(+), 3 deletions(-) >> >> diff --git a/recipes-initramfs/initramfs-overlay-hook/files/overlay.hook b/recipes-initramfs/initramfs-overlay-hook/files/overlay.hook >> index 8b00ecf..1a54853 100644 >> --- a/recipes-initramfs/initramfs-overlay-hook/files/overlay.hook >> +++ b/recipes-initramfs/initramfs-overlay-hook/files/overlay.hook >> @@ -22,6 +22,12 @@ esac >> >> . /usr/share/initramfs-tools/hook-functions >> >> +hook_error() { >> + echo "(ERROR): $1" >&2 >> + exit 1 >> +} >> + >> manual_add_modules overlay >> -copy_exec /usr/bin/mountpoint >> -copy_exec /usr/bin/awk >> +copy_exec /usr/bin/mountpoint || hook_error "/usr/bin/mountpoint not found" >> +copy_exec /usr/bin/awk || hook_error "/usr/bin/awk not found" >> +copy_exec /usr/sbin/e2fsck || hook_error "/usr/sbin/e2fsck not found" >> diff --git a/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl b/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl >> index 42eb59c..6b404c6 100644 >> --- a/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl >> +++ b/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl >> @@ -34,9 +34,15 @@ ovl_mount_option="${INITRAMFS_OVERLAY_MOUNT_OPTION}" >> >> root_mount_storage=${rootmnt}${ovl_storage_path} >> storage_mount_point="$(echo "${ovl_storage_path}" | awk -F/ '{print FS$2}' )" >> +partition_fstype=$(get_fstype "${ovl_partition_device}") >> >> if ! mountpoint -q "${rootmnt}${storage_mount_point}"; then >> - if ! mount -t $(get_fstype ${ovl_partition_device}) \ >> + if [ $partition_fstype = "ext*" ]; then >> + if ! e2fsck -p -f "$partition_fstype"; then >> + panic "E2fsck on ${ovl_partition_device} not successful!" > > Err, this will break the boot without even a chance to go back to > factory state, no? I would add a hook to a script which defines the action in case we cannot recover. Quirin > > Jan > >> + fi >> + fi >> + if ! mount -t ${partition_fstype} \ >> -o ${ovl_mount_option} \ >> ${ovl_partition_device} \ >> ${rootmnt}${storage_mount_point}; then >
On 28.06.24 13:58, Gylstorff Quirin wrote: > > > On 6/26/24 3:56 PM, Jan Kiszka wrote: >> On 26.06.24 15:41, Clara Kowalsky wrote: >>> In case of ext*, this detects and fixes file system errors in the >>> partition device before doing the partition mount. >>> >>> Signed-off-by: Clara Kowalsky <clara.kowalsky@siemens.com> >>> --- >>> .../initramfs-overlay-hook/files/overlay.hook | 10 ++++++++-- >>> .../initramfs-overlay-hook/files/overlay.script.tmpl | 8 +++++++- >>> 2 files changed, 15 insertions(+), 3 deletions(-) >>> >>> diff --git >>> a/recipes-initramfs/initramfs-overlay-hook/files/overlay.hook >>> b/recipes-initramfs/initramfs-overlay-hook/files/overlay.hook >>> index 8b00ecf..1a54853 100644 >>> --- a/recipes-initramfs/initramfs-overlay-hook/files/overlay.hook >>> +++ b/recipes-initramfs/initramfs-overlay-hook/files/overlay.hook >>> @@ -22,6 +22,12 @@ esac >>> . /usr/share/initramfs-tools/hook-functions >>> +hook_error() { >>> + echo "(ERROR): $1" >&2 >>> + exit 1 >>> +} >>> + >>> manual_add_modules overlay >>> -copy_exec /usr/bin/mountpoint >>> -copy_exec /usr/bin/awk >>> +copy_exec /usr/bin/mountpoint || hook_error "/usr/bin/mountpoint not >>> found" >>> +copy_exec /usr/bin/awk || hook_error "/usr/bin/awk not found" >>> +copy_exec /usr/sbin/e2fsck || hook_error "/usr/sbin/e2fsck not found" >>> diff --git >>> a/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl >>> b/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl >>> index 42eb59c..6b404c6 100644 >>> --- a/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl >>> +++ b/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl >>> @@ -34,9 +34,15 @@ ovl_mount_option="${INITRAMFS_OVERLAY_MOUNT_OPTION}" >>> root_mount_storage=${rootmnt}${ovl_storage_path} >>> storage_mount_point="$(echo "${ovl_storage_path}" | awk -F/ '{print >>> FS$2}' )" >>> +partition_fstype=$(get_fstype "${ovl_partition_device}") >>> if ! mountpoint -q "${rootmnt}${storage_mount_point}"; then >>> - if ! mount -t $(get_fstype ${ovl_partition_device}) \ >>> + if [ $partition_fstype = "ext*" ]; then >>> + if ! e2fsck -p -f "$partition_fstype"; then >>> + panic "E2fsck on ${ovl_partition_device} not successful!" >> >> Err, this will break the boot without even a chance to go back to >> factory state, no? > I would add a hook to a script which defines the action in case we > cannot recover. > ...and maybe already provide a default action that reformats (thus wipes) the state. Jan
diff --git a/recipes-initramfs/initramfs-overlay-hook/files/overlay.hook b/recipes-initramfs/initramfs-overlay-hook/files/overlay.hook index 8b00ecf..1a54853 100644 --- a/recipes-initramfs/initramfs-overlay-hook/files/overlay.hook +++ b/recipes-initramfs/initramfs-overlay-hook/files/overlay.hook @@ -22,6 +22,12 @@ esac . /usr/share/initramfs-tools/hook-functions +hook_error() { + echo "(ERROR): $1" >&2 + exit 1 +} + manual_add_modules overlay -copy_exec /usr/bin/mountpoint -copy_exec /usr/bin/awk +copy_exec /usr/bin/mountpoint || hook_error "/usr/bin/mountpoint not found" +copy_exec /usr/bin/awk || hook_error "/usr/bin/awk not found" +copy_exec /usr/sbin/e2fsck || hook_error "/usr/sbin/e2fsck not found" diff --git a/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl b/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl index 42eb59c..6b404c6 100644 --- a/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl +++ b/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl @@ -34,9 +34,15 @@ ovl_mount_option="${INITRAMFS_OVERLAY_MOUNT_OPTION}" root_mount_storage=${rootmnt}${ovl_storage_path} storage_mount_point="$(echo "${ovl_storage_path}" | awk -F/ '{print FS$2}' )" +partition_fstype=$(get_fstype "${ovl_partition_device}") if ! mountpoint -q "${rootmnt}${storage_mount_point}"; then - if ! mount -t $(get_fstype ${ovl_partition_device}) \ + if [ $partition_fstype = "ext*" ]; then + if ! e2fsck -p -f "$partition_fstype"; then + panic "E2fsck on ${ovl_partition_device} not successful!" + fi + fi + if ! mount -t ${partition_fstype} \ -o ${ovl_mount_option} \ ${ovl_partition_device} \ ${rootmnt}${storage_mount_point}; then
In case of ext*, this detects and fixes file system errors in the partition device before doing the partition mount. Signed-off-by: Clara Kowalsky <clara.kowalsky@siemens.com> --- .../initramfs-overlay-hook/files/overlay.hook | 10 ++++++++-- .../initramfs-overlay-hook/files/overlay.script.tmpl | 8 +++++++- 2 files changed, 15 insertions(+), 3 deletions(-)