Fix reinstall of controller nodes
At shutdown, systemd will try to remount everything read-only before attempting to unmount it. In the wipedisk script we are deleting the partitions without unmounting their corresponding filesystems. This leads to errors because systemd will try to remount filesystems whose partitions were deleted. To fix this we have to unmount the filesystems that are linked to the removed partitions. Closes-Bug: 1919153 Signed-off-by: Mihnea Saracin <Mihnea.Saracin@windriver.com> Change-Id: I49a3c06ae6bce1324dd06f4fc63fb3e5cd4d28c1
This commit is contained in:
parent
6cf5e84825
commit
497a6f93f4
|
@ -18,6 +18,28 @@ usage ()
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Systemd automatically remounts all the mounted filesystems at shutdown
|
||||||
|
# When we are deleting a partition, we have to unmount its corresponding filesystem
|
||||||
|
# because remounting deleted filesystems at shutdown will throw errors
|
||||||
|
unmount_fs()
|
||||||
|
{
|
||||||
|
local fs=$1
|
||||||
|
local ret_code=0
|
||||||
|
echo "Trying to unmount $fs"
|
||||||
|
if findmnt $fs > /dev/null 2>&1 ; then
|
||||||
|
if umount -f $fs ; then
|
||||||
|
echo "$fs has been successfully unmounted"
|
||||||
|
else
|
||||||
|
echo "Error! Failed to unmount $fs"
|
||||||
|
ret_code=1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Warning! $fs is not mounted"
|
||||||
|
ret_code=2
|
||||||
|
fi
|
||||||
|
return $ret_code
|
||||||
|
}
|
||||||
|
|
||||||
OPTS=`getopt -o h -l force -- "$@"`
|
OPTS=`getopt -o h -l force -- "$@"`
|
||||||
if [ $? != 0 ]
|
if [ $? != 0 ]
|
||||||
then
|
then
|
||||||
|
@ -131,6 +153,7 @@ do
|
||||||
# Skip / or we will lose access to the tools on the system.
|
# Skip / or we will lose access to the tools on the system.
|
||||||
if [[ $part != $rootfs_part ]]
|
if [[ $part != $rootfs_part ]]
|
||||||
then
|
then
|
||||||
|
unmount_fs $part
|
||||||
dd if=/dev/zero of=$part bs=512 count=34
|
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))
|
dd if=/dev/zero of=$part bs=512 count=34 seek=$((`blockdev --getsz $part` - 34))
|
||||||
fi
|
fi
|
||||||
|
@ -144,6 +167,7 @@ do
|
||||||
else
|
else
|
||||||
echo "Wiping $dev..."
|
echo "Wiping $dev..."
|
||||||
wipefs -f -a $dev
|
wipefs -f -a $dev
|
||||||
|
unmount_fs $dev
|
||||||
|
|
||||||
# Clearing previous GPT tables or LVM data
|
# Clearing previous GPT tables or LVM data
|
||||||
# Delete the first few bytes at the start and end of the partition. This is required with
|
# Delete the first few bytes at the start and end of the partition. This is required with
|
||||||
|
|
Loading…
Reference in New Issue