Fix wipedisk rootfs partition and bootloader removal

This commit changes:
 o DD wipe is no longer executed on / or we loose access
   to system commands before wipe is complete. Wiping
   root beginning and end is not mandatory as on reinstall
   it is reformatted.
 o Partitions on rootfs, other than platform-backup are
   removed.
 o Bootloader is removed so that boot from secondary devices
   can be done. This is useful at host reinstall. W/o this
   change boot hangs and manual intervention is needed.

Change-Id: I1ab9f70d00a38568fc00063cdaa54ec3be48dc33
Closes-Bug: 1877579
Signed-off-by: Ovidiu Poncea <ovidiu.poncea@windriver.com>
This commit is contained in:
Ovidiu Poncea 2020-05-08 19:21:20 +03:00
parent a56b99c846
commit 24499f8f25
1 changed files with 12 additions and 3 deletions

View File

@ -123,12 +123,21 @@ do
echo "Wiping partition $part..."
wipefs -f -a $part
# Clearing previous GPT tables or LVM data
# Delete the first few bytes at the start and end of the partition. This is required with
# GPT partitions, they save partition info at the start and the end of the block.
dd if=/dev/zero of=$part bs=512 count=34
dd if=/dev/zero of=$part bs=512 count=34 seek=$((`blockdev --getsz $part` - 34))
# Skip / or we will lose access to the tools on the system.
if [[ $part != $rootfs_part ]]
then
dd if=/dev/zero of=$part bs=512 count=34
dd if=/dev/zero of=$part bs=512 count=34 seek=$((`blockdev --getsz $part` - 34))
fi
echo "Removing partition $part..."
sgdisk $dev --delete $part_number
done
# Wipe bootloader signature to allow reboot from secondary boot devices (e.g. PXE)
dd if=/dev/zero of=$dev bs=440 count=1
else
echo "Wiping $dev..."
wipefs -f -a $dev