Skip to content

Commit c29def6

Browse files
qiluo-msftlguohan
authored andcommitted
[installer]: Umount before delete partition (#1575)
Signed-off-by: Qi Luo <[email protected]>
1 parent af0013e commit c29def6

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

installer/x86_64/install.sh

+11-1
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,21 @@ create_demo_gpt_partition()
163163
while read -r part_index; do
164164
if [ "$blk_dev$part_index" = "$cur_part" ]; then continue; fi
165165
echo "deleting partition $part_index ..."
166+
# if the partition is already mounted, umount first
167+
df $blk_dev$part_index 2>/dev/null && {
168+
umount $blk_dev$part_index || {
169+
echo "Error: Unable to umount $blk_dev$part_index"
170+
exit 1
171+
}
172+
}
166173
sgdisk -d $part_index $blk_dev || {
167174
echo "Error: Unable to delete partition $part_index on $blk_dev"
168175
exit 1
169176
}
170-
partprobe
177+
partprobe || {
178+
echo "Error: Unable to partprobe"
179+
exit 1
180+
}
171181
done < $tmpfifo
172182
fi
173183

0 commit comments

Comments
 (0)