support installing NOS to where ONIE image resides while block device is not specified

this fixes the issue when an external USB disk is inserted before powering on the switch that
may change the device name of the expected installation destination (e.g. /dev/sdb becomes /dev/sdc)
This commit is contained in:
Lewis Kang
2016-05-12 18:20:31 +08:00
parent 194ef35b66
commit 3d8a473b65
3 changed files with 11 additions and 2 deletions

View File

@@ -275,6 +275,15 @@ partition_gpt()
installer_standard_gpt_install()
{
DEV=$1; shift
if [ -z $DEV ]; then
# Install on the same block device as ONIE
DEV=$(blkid | grep ONIE-BOOT | awk '{print $1}' | sed -e 's/[1-9][0-9]*:.*$//' | sed -e 's/\([0-9]\)\(p\)/\1/' | head -n 1)
[ -b "$DEV" ] || {
echo "Error: Unable to determine block device of ONIE install"
return 1
}
fi
visit_parted $DEV do_handle_disk do_handle_partitions || return 1
partition_gpt $(get_free_space) || return 1

View File

@@ -11,5 +11,5 @@
platform_installer() {
# Standard isntallation to an available GPT partition
installer_standard_gpt_install /dev/sdb
installer_standard_gpt_install
}

View File

@@ -11,5 +11,5 @@
platform_installer() {
# Standard isntallation to an available GPT partition
installer_standard_gpt_install /dev/sdb
installer_standard_gpt_install
}