Message ID | 76e3eff93cb07536292fe39dd5291cb744f94e9c.1719927511.git.jan.kiszka@siemens.com |
---|---|
State | Accepted, archived |
Headers | show |
Series | Reworks, fixes and unattended mode for image installer | expand |
On Tue, 2024-07-02 at 15:38 +0200, 'Jan Kiszka' via isar-users wrote: > From: Jan Kiszka <jan.kiszka@siemens.com> > > Check of the first MB of the target device is only containing zero -------^ typo: if > and > warn otherwise before overwriting potentially valuable data. Looking > at the first MB should cover enough partition table and file system > structures to detect a valid disk. > > Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> > --- > .../deploy-image/files/deploy-image-wic.sh | 6 > ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/meta-isar/recipes-installer/deploy-image/files/deploy- > image-wic.sh b/meta-isar/recipes-installer/deploy-image/files/deploy- > image-wic.sh > index 09d6cc11..81a006ce 100644 > --- a/meta-isar/recipes-installer/deploy-image/files/deploy-image- > wic.sh > +++ b/meta-isar/recipes-installer/deploy-image/files/deploy-image- > wic.sh > @@ -96,6 +96,12 @@ if ! dialog --yes-label Ok --no-label Cancel \ > exit 0 > fi > > +if ! cmp /dev/zero "$TARGET_DEVICE" -n 1M && \ > + ! dialog --defaultno \ > + --yesno "WARNING: Target device is not empty! Continue Ok, but I'm sure this will almost always fire. Even fresh devices are not necessarily zeroed. Felix > anyway?" 5 60; then > + exit 0 > +fi > + > bmap_options="" > if [ -z "$DISK_BMAP" ]; then > bmap_options="--nobmap" > -- > 2.43.0 >
On 03.07.24 17:53, Moessbauer, Felix (T CED OES-DE) wrote: > On Tue, 2024-07-02 at 15:38 +0200, 'Jan Kiszka' via isar-users wrote: >> From: Jan Kiszka <jan.kiszka@siemens.com> >> >> Check of the first MB of the target device is only containing zero > -------^ typo: if > >> and >> warn otherwise before overwriting potentially valuable data. Looking >> at the first MB should cover enough partition table and file system >> structures to detect a valid disk. >> >> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> >> --- >> .../deploy-image/files/deploy-image-wic.sh | 6 >> ++++++ >> 1 file changed, 6 insertions(+) >> >> diff --git a/meta-isar/recipes-installer/deploy-image/files/deploy- >> image-wic.sh b/meta-isar/recipes-installer/deploy-image/files/deploy- >> image-wic.sh >> index 09d6cc11..81a006ce 100644 >> --- a/meta-isar/recipes-installer/deploy-image/files/deploy-image- >> wic.sh >> +++ b/meta-isar/recipes-installer/deploy-image/files/deploy-image- >> wic.sh >> @@ -96,6 +96,12 @@ if ! dialog --yes-label Ok --no-label Cancel \ >> exit 0 >> fi >> >> +if ! cmp /dev/zero "$TARGET_DEVICE" -n 1M && \ >> + ! dialog --defaultno \ >> + --yesno "WARNING: Target device is not empty! Continue > > Ok, but I'm sure this will almost always fire. > Even fresh devices are not necessarily zeroed. Flash drives are generally by design. But if you have a concrete proposal how to improve the heuristics, I'm all ears. Jan
On Wed, 2024-07-03 at 17:55 +0200, 'Jan Kiszka' via isar-users wrote: > On 03.07.24 17:53, Moessbauer, Felix (T CED OES-DE) wrote: > > On Tue, 2024-07-02 at 15:38 +0200, 'Jan Kiszka' via isar-users > > wrote: > > > From: Jan Kiszka <jan.kiszka@siemens.com> > > > > > > Check of the first MB of the target device is only containing > > > zero > > -------^ typo: if > > > > > and > > > warn otherwise before overwriting potentially valuable data. > > > Looking > > > at the first MB should cover enough partition table and file > > > system > > > structures to detect a valid disk. > > > > > > Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> > > > --- > > > .../deploy-image/files/deploy-image-wic.sh | 6 > > > ++++++ > > > 1 file changed, 6 insertions(+) > > > > > > diff --git a/meta-isar/recipes-installer/deploy- > > > image/files/deploy- > > > image-wic.sh b/meta-isar/recipes-installer/deploy- > > > image/files/deploy- > > > image-wic.sh > > > index 09d6cc11..81a006ce 100644 > > > --- a/meta-isar/recipes-installer/deploy-image/files/deploy- > > > image- > > > wic.sh > > > +++ b/meta-isar/recipes-installer/deploy-image/files/deploy- > > > image- > > > wic.sh > > > @@ -96,6 +96,12 @@ if ! dialog --yes-label Ok --no-label Cancel \ > > > exit 0 > > > fi > > > > > > +if ! cmp /dev/zero "$TARGET_DEVICE" -n 1M && \ > > > + ! dialog --defaultno \ > > > + --yesno "WARNING: Target device is not empty! > > > Continue > > > > Ok, but I'm sure this will almost always fire. > > Even fresh devices are not necessarily zeroed. > > Flash drives are generally by design. But if you have a concrete > proposal how to improve the heuristics, I'm all ears. > > Jan > What about simply checking the device for partitions? `lsblk -n "$TARGET_DEVICE" -o TYPE | grep part >/dev/null` This should fit our needs. > -- > Siemens AG, Technology > Linux Expert Center >
On 19.07.24 07:33, Uladzimir Bely wrote: > On Wed, 2024-07-03 at 17:55 +0200, 'Jan Kiszka' via isar-users wrote: >> On 03.07.24 17:53, Moessbauer, Felix (T CED OES-DE) wrote: >>> On Tue, 2024-07-02 at 15:38 +0200, 'Jan Kiszka' via isar-users >>> wrote: >>>> From: Jan Kiszka <jan.kiszka@siemens.com> >>>> >>>> Check of the first MB of the target device is only containing >>>> zero >>> -------^ typo: if >>> >>>> and >>>> warn otherwise before overwriting potentially valuable data. >>>> Looking >>>> at the first MB should cover enough partition table and file >>>> system >>>> structures to detect a valid disk. >>>> >>>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> >>>> --- >>>> .../deploy-image/files/deploy-image-wic.sh | 6 >>>> ++++++ >>>> 1 file changed, 6 insertions(+) >>>> >>>> diff --git a/meta-isar/recipes-installer/deploy- >>>> image/files/deploy- >>>> image-wic.sh b/meta-isar/recipes-installer/deploy- >>>> image/files/deploy- >>>> image-wic.sh >>>> index 09d6cc11..81a006ce 100644 >>>> --- a/meta-isar/recipes-installer/deploy-image/files/deploy- >>>> image- >>>> wic.sh >>>> +++ b/meta-isar/recipes-installer/deploy-image/files/deploy- >>>> image- >>>> wic.sh >>>> @@ -96,6 +96,12 @@ if ! dialog --yes-label Ok --no-label Cancel \ >>>> exit 0 >>>> fi >>>> >>>> +if ! cmp /dev/zero "$TARGET_DEVICE" -n 1M && \ >>>> + ! dialog --defaultno \ >>>> + --yesno "WARNING: Target device is not empty! >>>> Continue >>> >>> Ok, but I'm sure this will almost always fire. >>> Even fresh devices are not necessarily zeroed. >> >> Flash drives are generally by design. But if you have a concrete >> proposal how to improve the heuristics, I'm all ears. >> >> Jan >> > > What about simply checking the device for partitions? > > `lsblk -n "$TARGET_DEVICE" -o TYPE | grep part >/dev/null` > > This should fit our needs. Could still select an unpartitioned device with a valid filesystem. Jan
diff --git a/meta-isar/recipes-installer/deploy-image/files/deploy-image-wic.sh b/meta-isar/recipes-installer/deploy-image/files/deploy-image-wic.sh index 09d6cc11..81a006ce 100644 --- a/meta-isar/recipes-installer/deploy-image/files/deploy-image-wic.sh +++ b/meta-isar/recipes-installer/deploy-image/files/deploy-image-wic.sh @@ -96,6 +96,12 @@ if ! dialog --yes-label Ok --no-label Cancel \ exit 0 fi +if ! cmp /dev/zero "$TARGET_DEVICE" -n 1M && \ + ! dialog --defaultno \ + --yesno "WARNING: Target device is not empty! Continue anyway?" 5 60; then + exit 0 +fi + bmap_options="" if [ -z "$DISK_BMAP" ]; then bmap_options="--nobmap"