I'm bringing up a new device and I've gotten everything to work as it should, with the exception of saving the sysupgrade.tgz
file.
In package/base-files/lib/upgrade/common.sh
, it defines export BACKUP_FILE=sysupgrade.tgz # file extracted by preinit
, which means it'll be generated and needs to be copied.
From what I've been able to learn, preinit/80_mount_root
looks and applies this sysupgrade.tgz on the first boot after the upgrade (and looks for the file in /sysupgrade.tgz
).
My data partition is a f2fs
partition that squashfs/overlayfs use. Once sysupgrade switches to the initramfs, I can't seem to ACCESS the partition. mount /dev/mmcblk1p2 /mnt
mounts it as read-only, and adding a -o rw,noatime
doesn't seem to help. I cannot seem to get the sysupgrade.tgz
file onto the /dev/mmcblk1p2
data partition.
This is my /lib/upgrade/platform.sh
- I commented out the actual flashing commands to do the testing of the backups in do_flash()
#
# Copyright (C) 2014 OpenWrt.org
#
platform_get_rootfs() {
local rootfsdev
if read cmdline < /proc/cmdline; then
case "$cmdline" in
*block2mtd=*)
rootfsdev="${cmdline##*block2mtd=}"
rootfsdev="${rootfsdev%%,*}"
;;
*root=*)
rootfsdev="${cmdline##*root=}"
rootfsdev="${rootfsdev%% *}"
;;
esac
echo "${rootfsdev}"
fi
}
platform_copy_config() {
case "$(board_name)" in
erlite)
mount -t vfat /dev/sda1 /mnt
cp -af "$UPGRADE_BACKUP" "/mnt/$BACKUP_FILE"
umount /mnt
;;
itusrouter)
mkdir -p /boot
mount -o rw,noatime "/dev/mmcblk1p2" /mnt
cp -af "$UPGRADE_BACKUP" "/mnt/$BACKUP_FILE"
umount /mnt
;;
itusbridge)
mount -t f2fs -o rw,noatime /dev/mmcblk1p4 /mnt
cp -af "$UPGRADE_BACKUP" "/mnt/$BACKUP_FILE"
umount /mnt
;;
itusgateway)
mount -t f2fs -o rw,noatime /dev/mmcblk1p3 /mnt
cp -af "$UPGRADE_BACKUP" "/mnt/$BACKUP_FILE"
umount /mnt
;;
esac
}
platform_do_flash() {
local tar_file=$1
local board=$2
local kernel=$3
local rootfs=$4
mkdir -p /boot
if [[ $board == "itusrouter" || $board == "itusbridge" || $board == "itusgateway" ]]; then
# mmcblk1p1 (fat) contains all ELF-bin images for the Shield
mount /dev/mmcblk1p1 /boot
echo "flashing Itus Kernel to /boot/$kernel (/dev/mmblk1p1)"
tar -C /tmp -xvf $tar_file
#cp /tmp/sysupgrade-$board/kernel /boot/$kernel
umount /boot
echo "flashing rootfs to ${rootfs}"
#dd if=/tmp/sysupgrade-$board/root of="${rootfs}"
else
echo "flashing kernel to /dev/$kernel"
mount -t vfat /dev/$kernel /boot
[ -f /boot/vmlinux.64 -a ! -L /boot/vmlinux.64 ] && {
mv /boot/vmlinux.64 /boot/vmlinux.64.previous
mv /boot/vmlinux.64.md5 /boot/vmlinux.64.md5.previous
}
echo "flashing kernel to /dev/$kernel"
tar xf $tar_file sysupgrade-$board/kernel -O > /boot/vmlinux.64
md5sum /boot/vmlinux.64 | cut -f1 -d " " > /boot/vmlinux.64.md5
umount /boot
echo "flashing rootfs to ${rootfs}"
tar xvf $tar_file sysupgrade-$board/root -O | dd of="${rootfs}" bs=4096
fi
sync
}
platform_do_upgrade() {
local tar_file="$1"
local board=$(board_name)
local rootfs="$(platform_get_rootfs)"
local kernel=
[ -b "${rootfs}" ] || return 1
case "$board" in
er)
kernel=mmcblk0p1
;;
erlite)
kernel=sda1
;;
itusrouter)
kernel=ItusrouterImage
;;
itusbridge)
kernel=ItusbridgeImage
;;
itusgateway)
kernel=ItusgatewayImage
;;
*)
return 1
esac
platform_do_flash $tar_file $board $kernel $rootfs
return 0
}
platform_check_image() {
local board=$(board_name)
case "$board" in
er | \
erlite | \
itus*)
local tar_file="$1"
local kernel_length=$(tar xf $tar_file sysupgrade-$board/kernel -O | wc -c 2> /dev/null)
local rootfs_length=$(tar xf $tar_file sysupgrade-$board/root -O | wc -c 2> /dev/null)
[ "$kernel_length" = 0 -o "$rootfs_length" = 0 ] && {
echo "The upgrade image is corrupt."
return 1
}
return 0
;;
esac
echo "Sysupgrade is not yet supported on $board."
return 1
}
As you can see from the log below, I cannot get the /dev/mmcblk1p2 to mount rw..
root@OpenWrt:/tmp# sysupgrade -v openwrt-octeon-itusrouter-squashfs-sysupgrade.t
ar
Image metadata not found
Saving config files...
etc/config/dhcp
etc/config/dropbear
etc/config/firewall
etc/config/luci
etc/config/network
etc/config/rpcd
etc/config/system
etc/config/ucitrack
etc/config/uhttpd
etc/dropbear/dropbear_rsa_host_key
etc/group
etc/hosts
etc/inittab
etc/luci-uploads/.placeholder
etc/opkg/keys/0b26f36ae0f4106d
etc/opkg/keys/1035ac73cc4e59e3
etc/opkg/keys/5151f69420c3f508
etc/opkg/keys/72a57f2191b211e0
etc/opkg/keys/792d9d9b39f180dc
etc/opkg/keys/9ef4694208102c43
etc/opkg/keys/b2d571e0880ff617
etc/opkg/keys/b5043e70f9a75cde
etc/opkg/keys/c10b9afab19ee428
etc/opkg/keys/caafb567d784e639
etc/opkg/keys/dace9d4df16896bf
etc/opkg/keys/dd6de0d06bbd3d85
etc/opkg/keys/f94b9dd6febac963
etc/passwd
etc/profile
etc/rc.local
etc/shadow
etc/shells
etc/shinit
etc/sysctl.conf
etc/uhttpd.crt
etc/uhttpd.key
etc/uhttpd.key
etc/uhttpd.crt
Commencing upgrade. Closing all shell sessions.
Watchdog handover: fd=3
- watchdog -
killall: telnetd: no process killed
Sending TERM to remaining processes ... netifd odhcpd uhttpd ntpd dnsmasq ubusd urngd logd rpcd
Sending KILL to remaining processes ...
Switching to ramdisk...
Performing system upgrade...
flashing Itus Kernel to /boot/ItusrouterImage (/dev/mmblk1p1)
sysupgrade-itusrouter/
sysupgrade-itusrouter/CONTROL
sysupgrade-itusrouter/kernel
sysupgrade-itusrouter/root
flashing rootfs to /dev/mmcblk1p2
cp: can't create '/mnt/sysupgrade.tgz': Read-only file system
Upgrade completed
Rebooting system...
umount: can't unmount /dev: Resource busy
umount: can't unmount /tmp: Resource busy
[12277.594916] reboot: Restarting system