[installer]: Umount before delete partition (#1575)

Signed-off-by: Qi Luo <qiluo-msft@users.noreply.github.com>
This commit is contained in:
Qi Luo 2018-04-09 23:51:43 -07:00 committed by lguohan
parent af0013e939
commit c29def6379

View File

@ -163,11 +163,21 @@ create_demo_gpt_partition()
while read -r part_index; do while read -r part_index; do
if [ "$blk_dev$part_index" = "$cur_part" ]; then continue; fi if [ "$blk_dev$part_index" = "$cur_part" ]; then continue; fi
echo "deleting partition $part_index ..." echo "deleting partition $part_index ..."
# if the partition is already mounted, umount first
df $blk_dev$part_index 2>/dev/null && {
umount $blk_dev$part_index || {
echo "Error: Unable to umount $blk_dev$part_index"
exit 1
}
}
sgdisk -d $part_index $blk_dev || { sgdisk -d $part_index $blk_dev || {
echo "Error: Unable to delete partition $part_index on $blk_dev" echo "Error: Unable to delete partition $part_index on $blk_dev"
exit 1 exit 1
} }
partprobe partprobe || {
echo "Error: Unable to partprobe"
exit 1
}
done < $tmpfifo done < $tmpfifo
fi fi