Skip to content

Commit

Permalink
Merge pull request ostroproject#20 from rojkov/iotos-1724
Browse files Browse the repository at this point in the history
installer: fix booting from MicroSD
  • Loading branch information
pohly authored Jul 27, 2016
2 parents b8d1435 + 9a9d5a4 commit 3a96976
Showing 1 changed file with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ SETTINGS_COPY_SSH_KEYS="no"

# DST_DISK is evaluated in find_emmc_disk() and contains the device to install OS onto
DST_DISK=
# rootfs partition of the installation media
SRC_PARTITION="/dev/disk/by-partuuid/`echo $bootparam_root | cut -d'=' -f2`"

installer_enabled() {
if [ -n "$bootparam_installer" ]; then
Expand Down Expand Up @@ -104,13 +106,7 @@ install_onto_emmc() {
set -x
local pnum=0
local gdisk_pnum=1
local rootuuid=`echo $bootparam_root | cut -d'=' -f2`

while [ ! -b /dev/disk/by-partuuid/$rootuuid ]; do
echo "Waiting for USB storage is fully initialized..."
sleep 1
done
mount -t $bootparam_rootfstype -o ro /dev/disk/by-partuuid/$rootuuid /rootfs
mount -t $bootparam_rootfstype -o ro $SRC_PARTITION /rootfs

if [ -s /rootfs/etc/machine-id ]; then
set +x
Expand Down Expand Up @@ -167,16 +163,29 @@ install_onto_emmc() {
}

read_settings() {
while [ ! -b /dev/sda ]; do
echo "Waiting for USB storage is initialized..."
local fat_part=
local disk=

while [ ! -b $SRC_PARTITION ]; do
echo "Waiting for installation media is fully initialized..."
sleep 1
done

local boot_mnt=`mktemp -d -p / tmp_efiboot_part.XXXXXX`
local usbstick_fat_part=`sgdisk -p /dev/sda | grep EF00 | awk '{print $1}'`
# USB and SD disks use different naming schemes for their partitions,
# therefore we have to check both schemes.
local canonical_part=`readlink -f $SRC_PARTITION`
if [ `echo $canonical_part | grep mmcblk | wc -l` -eq "0" ]; then
disk=`echo $canonical_part | cut -b -8`
fat_part="${disk}`sgdisk -p ${disk} | grep EF00 | awk '{print $1}'`"
else
disk=`echo $canonical_part | cut -b -12`
fat_part="${disk}p`sgdisk -p ${disk} | grep EF00 | awk '{print $1}'`"
fi

if [ -n $fat_part ]; then
local boot_mnt=`mktemp -d -p / tmp_efiboot_part.XXXXXX`

if [ -n $usbstick_fat_part ]; then
mount /dev/sda${usbstick_fat_part} $boot_mnt
mount $fat_part $boot_mnt

if [ -f $boot_mnt/non-interactive-install.txt -o -f $boot_mnt/non-interactive-install ]; then
SETTINGS_INTERACTIVE="no"
Expand Down

0 comments on commit 3a96976

Please sign in to comment.