Skip to content

Commit 3a96976

Browse files
authored
Merge pull request ostroproject#20 from rojkov/iotos-1724
installer: fix booting from MicroSD
2 parents b8d1435 + 9a9d5a4 commit 3a96976

File tree

1 file changed

+22
-13
lines changed
  • meta-ostro-xt/recipes-xt/initrdscripts/initramfs-framework-installer

1 file changed

+22
-13
lines changed

meta-ostro-xt/recipes-xt/initrdscripts/initramfs-framework-installer/installer

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ SETTINGS_COPY_SSH_KEYS="no"
88

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

1214
installer_enabled() {
1315
if [ -n "$bootparam_installer" ]; then
@@ -104,13 +106,7 @@ install_onto_emmc() {
104106
set -x
105107
local pnum=0
106108
local gdisk_pnum=1
107-
local rootuuid=`echo $bootparam_root | cut -d'=' -f2`
108-
109-
while [ ! -b /dev/disk/by-partuuid/$rootuuid ]; do
110-
echo "Waiting for USB storage is fully initialized..."
111-
sleep 1
112-
done
113-
mount -t $bootparam_rootfstype -o ro /dev/disk/by-partuuid/$rootuuid /rootfs
109+
mount -t $bootparam_rootfstype -o ro $SRC_PARTITION /rootfs
114110

115111
if [ -s /rootfs/etc/machine-id ]; then
116112
set +x
@@ -167,16 +163,29 @@ install_onto_emmc() {
167163
}
168164

169165
read_settings() {
170-
while [ ! -b /dev/sda ]; do
171-
echo "Waiting for USB storage is initialized..."
166+
local fat_part=
167+
local disk=
168+
169+
while [ ! -b $SRC_PARTITION ]; do
170+
echo "Waiting for installation media is fully initialized..."
172171
sleep 1
173172
done
174173

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

178-
if [ -n $usbstick_fat_part ]; then
179-
mount /dev/sda${usbstick_fat_part} $boot_mnt
188+
mount $fat_part $boot_mnt
180189

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

0 commit comments

Comments
 (0)