/dev/mmcblk0 disk dev is no longer hardcoded everywhere

This commit is contained in:
Calin Crisan 2017-03-12 13:09:35 +02:00
parent c4f4127a69
commit e85f7645d8
3 changed files with 37 additions and 12 deletions

View File

@ -2,9 +2,27 @@
PATH=/bin:/sbin:/usr/bin:/usr/sbin
BOOT_DEV=/dev/mmcblk0p1
ROOT_DEV=/dev/mmcblk0p2
DATA_DEV=/dev/mmcblk0p3
msg() {
echo "* $1"
}
ROOT_DEV=$(cat /proc/cmdline | grep -oE 'root=[/a-z0-9]+' | cut -d '=' -f 2)
if [[ "$ROOT_DEV" =~ ^([/a-z0-9]+)(p[0-9])$ ]]; then # e.g. /dev/mmcblk0p2
DISK_DEV=${BASH_REMATCH[1]}
BOOT_DEV=${DISK_DEV}p1
DATA_DEV=${DISK_DEV}p3
else # e.g. /dev/sdc2
[[ "$ROOT_DEV" =~ ^([/a-z0-9]+)([0-9])$ ]]
DISK_DEV=${BASH_REMATCH[1]}
BOOT_DEV=${DISK_DEV}1
DATA_DEV=${DISK_DEV}3
fi
msg "Disk device is $DISK_DEV"
msg "Boot device is $BOOT_DEV"
msg "Root device is $ROOT_DEV"
msg "Data device is $DATA_DEV"
FW_DIR=/data/.fwupdate
FW_FILE=firmware.img.gz
@ -15,10 +33,6 @@ LEGACY_FW_FILE_EXTR=firmware
ROOT_INFO_FILE=root_info
msg() {
echo "* $1"
}
on_exit() {
msg "Switching to normal boot"
/remove_initramfs

View File

@ -1,12 +1,23 @@
#!/bin/bash
disk_dev="/dev/mmcblk0"
data_dev="${disk_dev}p3"
test -n "$os_version" || source /etc/init.d/base
msg_begin "Detecting disk device"
root_part=$(cat /proc/cmdline | grep -oE 'root=[/a-z0-9]+' | cut -d '=' -f 2)
if [[ "$root_part" =~ ^([/a-z0-9]+)(p[0-9])$ ]]; then # e.g. /dev/mmcblk0p2
disk_dev=${BASH_REMATCH[1]}
data_dev=${disk_dev}p3
elif [[ "$root_part" =~ ^([/a-z0-9]+)([0-9])$ ]]; then # e.g. /dev/sdc2
disk_dev=${BASH_REMATCH[1]}
data_dev=${disk_dev}3
else
msg_fail "unknown ($root_part)"
exit 1
fi
msg_done "$disk_dev"
test -b $data_dev && exit 0
test -n "$os_version" || source /etc/init.d/base
case "$1" in
start)
msg_begin "Creating data partition"

View File

@ -36,7 +36,7 @@ SYS_VERSION_FILE=/etc/version
SYS_BOARD_FILE=/etc/board
OS_CONF=/data/etc/os.conf
BOOT_DEV=/dev/mmcblk0p1
BOOT_DEV=$(mount | grep /boot | cut -d ' ' -f 1)
MIN_FREE_DISK=$((500*1024)) # 500 MB
VER_FILE=version
ROOT_INFO_FILE=root_info