Once again, please have a look at Flash Layout. A sysupgrade will replace the Linux Kernel and the SquashFS contents and it will erase the entire JFFS2 partition. You can save a couple or all of your your configuration files, but be aware that on rare occasions old configuration files don't work with new program versions. You cannot save installed binaries, you will have to install them again after sysupgrade. That way, everything will match, e.g. the flashed Linux Kernel and installed Kernel modules.
It is important to download the firmware image file to
/tmp-directory, a tmpfs drive is mounted to it. That way the data will be downloaded into memory and not onto the flash storage because most likely there is not enough flash storage available! → user.beginner.fhs. That means you should free up enough memory beforehand.
- You should check how much RAM you have currently available:
freeIn case you do not have enough left, consult Free up RAM.
- Populate your
- Obtain suitable OpenWrt firmware image (trunk or stable):
cd /tmp wget http://downloads.openwrt.org/snapshots/trunk/PLATFORM/xxx-sysupgrade.bin wget http://downloads.openwrt.org/snapshots/trunk/PLATFORM/md5sums
Some brief things to consider: If you are attempting this on a system with an extroot configured, you will need to reinstall your packages after the sysupgrade. So before you upgrade, take some consideration and follow a few extra steps. I recommend to make a quick list of the packages you had installed:
opkg list-installed > /etc/installed-pkgs
- check the integrity of the image file:
md5sum -c md5sums 2> /dev/null | grep OK or alternatively cat md5sums | grep mr3420 | md5sum -cWhen it says something like
md5sum: WARNING: 195 of 196 computed checksums did NOT matchit means the only one you downloaded did match
- use the following command to upgrade:
sysupgrade -v /tmp/openwrt-ar71xx-generic-wzr-hp-ag300h-squashfs-sysupgrade.bin
- The verbose-option should give some output similar to this:
root@openwrt:/tmp$ sysupgrade -v openwrt-ar71xx-generic-tl-wr1043nd-v1-squashfs-sysupgrade.bin Saving config files... root/zeit root/statistics root/quelen root/auswurfeln etc/sysupgrade.conf etc/sysctl.conf etc/shells etc/rc.local etc/TC_hfsc.sh etc/profile etc/passwd etc/inittab etc/init.d/trafficc etc/hotplug.d/iface/30-trafficc etc/hosts etc/group etc/firewall.user etc/dropbear/dropbear_rsa_host_key etc/dropbear/dropbear_dss_host_key etc/crontabs/root etc/config/wireless etc/config/timeserver etc/config/system etc/config/network etc/config/firewall etc/config/dropbear etc/config/dhcp etc/collectd.conf Switching to ramdisk... Performing system upgrade... Unlocking firmware ... Writing from <stdin> to firmware ... Appending jffs2 data from /tmp/sysupgrade.tgz to firmware...TRX header not found Error fixing up TRX header Writing from <stdin> to firmware ... Upgrade completed Rebooting system...
- After the automatic reboot, the system should come up with the same network IP addresses, same dropbear password, etc. It is however possible that it does not. In that case, try a cold reset (= interrupt the electrical current to the device, wait a couple of seconds and then connect it again).
- After the cold reboot, you should gain access and here you could check things out:
dmesg uname -a iptables -V ...
- You do need to reinstall opkg-packages:
opkg update opkg install tc iptables-mod-ipopt wol
optional EXTROOT notes continued… I use a USB flash drive for my extroot. Modify as needed if you are using a different medium. Of course you'll want to setup your extroot before reinstalling all of your packages. fdisk is optional, but can be useful if you do not remember your partitioning schema.
opkg install blockmount opkg install kmod-usb-storage opkg install kmod-fs-ext4 opkg install e2fsprogs opkg install kmod-scsi-generic opkg install fdisk opkg install nano
You'll need to modify /etc/config/fstab again per instructions in http://wiki.openwrt.org/doc/howto/extroot
I am using this for example:
config mount option target /overlay option device /dev/sda1 option fstype ext4 option options rw,sync option enabled 1 option enabled_fsck 0
Which is working well on my current trunk r36141. Do not use on revisions earlier than r25787
Now mount your device and copy the overlay to it, enable fstab so it mounts on startup and reboot
mkdir /mnt/sda1 mount /dev/sda1 /mnt/sda1 tar -C /overlay -cvf - . | tar -C /mnt/sda1 -xf - /etc/init.d/fstab enable reboot
Once the device is running again, check to see that your extroot is mounted. My storage medium again is USB flash drive 8GB.
root@OpenWrt:~# df -h Filesystem Size Used Available Use% Mounted on rootfs 7.2G 58.0M 6.8G 1% / /dev/root 1.8M 1.8M 0 100% /rom tmpfs 30.0M 472.0K 29.6M 2% /tmp tmpfs 512.0K 0 512.0K 0% /dev /dev/sda1 7.2G 58.0M 6.8G 1% /overlay overlayfs:/overlay 7.2G 58.0M 6.8G 1% / root@OpenWrt:~# mount rootfs on / type rootfs (rw) /dev/root on /rom type squashfs (ro,relatime) proc on /proc type proc (rw,noatime) sysfs on /sys type sysfs (rw,noatime) tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime) tmpfs on /dev type tmpfs (rw,noatime,size=512k,mode=755) devpts on /dev/pts type devpts (rw,noatime,mode=600) /dev/sda1 on /overlay type ext4 (rw,sync,relatime,data=ordered) overlayfs:/overlay on / type overlayfs (rw,noatime,lowerdir=/,upperdir=/overlay) debugfs on /sys/kernel/debug type debugfs (rw,noatime)
Now update package cache and reinstall your packages based on the list you made before. The cut command cleans the version numbers from the list. Pay careful attention to any errors at the end of the operation. The only ones I encountered were due to saved configuration files.
opkg update opkg install $(cat /etc/installed-pkgs | cut -d' ' -f 1 )
Note that you can preserve scripts, settings, and documents across sysupgrade by putting them in a directory in /etc/config. Otherwise, most will be lost.
|For unknown reasons such a cold reset has often been reported to be necessary after a sysupgrade. This is very very bad in case you performed this remotely!|
- Download a suitable OpenWrt firmware image file
- Login to the WebInterface of the router (default: http://192.168.1.1)
- Upload the OpenWrt image file you downloaded to your PC at step 1 to your router via LuCI
- LuCI will calculate the MD5 checksum of the file, if it's correct, you are green to go
- wait until the router comes back online
- In case
sysupgradeis not supported for your embedded device, you cannot use it. Use
mtd -r write /tmp/openwrt-ar71xx-generic-wzr-hp-ag300h-squashfs-sysupgrade.bin firmware
Netcat could be employed if you cannot free enough RAM. See netcat. Netcat needs to be installed first.
|This method is NOT recommended!|
- On your Linux PC run:
nc -q0 192.168.1.1 1234 < openwrt-ar71xx-tl-wr1043nd-v1-squashfs-sysupgrade.bin
- On the router run:
nc -l -p 1234 | mtd write - firmware
|This method is much SAFER if you have enough RAM.|
This method is fine for self built firmwares.
You should check how much RAM you have currently available.(In case you do not have enough left, consult Free up RAM.)
- On your Linux PC run:
cat [specified firmware].bin | pv -b | nc -l 3333
- On the router run:
nc 192.168.1.111 3333 > /tmp/[specified firmware].bin
The port 3333 an IP address 192.168.1.111 are just examples. The command 'pv -b' is optional for tracking progress but maybe you have to install pv to your system previously.
sysupgrade -v /tmp/[specified firmware].bin
mtd -r write /tmp/[specified firmware].bin firmware
I have tested under Ubuntu 11.10.
http://www.g-loaded.eu/2006/11/06/netcat-a-couple-of-useful-examples/ http://www.screenage.de/blog/2007/12/30/using-netcat-and-tar-for-network-file-transfer/ https://help.ubuntu.com/community/BackupYourSystem/TAR http://www.aboutdebian.com/tar-backup.htm
First check memory usage with the
cat /proc/meminfo commands; proceed if you have as much free RAM as the image is in size plus an some additional MiB of free memory.
In this example there are precisely 11416 KiB of RAM unused. All the rest 32768 - 11416 = 21352 KiB are used somehow and a portion of it can and will be made available by the kernel, if it be needed, the problem is, we do not know how much exactly that is. Make sure enough is available. Free space in /tmp also counts towards free memory. Therefore with:
One has actually 752+6636 KiB of free memory available.
- quickest and safest way to free up, some RAM is to delete the
rm -r /tmp/opkg-lists/
- drop caches:
echo 3 > /proc/sys/vm/drop_caches
- prevent wireless drivers to be loaded at next boot and then reboot:
rm /etc/modules.d$/*80211* rm /etc/modules.d$/*ath9k* reboot
The wireless drivers, usually take up quite some amount of RAM and are not required (unless you are connected via wireless of course ), so an easy way to free up some RAM is to delete the symlinks in
etc/modules.d so these are not loaded into memory at the next reboot:
Add installed-pkgs to preserved files
echo /etc/installed-pkgs >> /etc/sysupgrade.conf
Verify backup configuration
sysupgrade -b - | tar -tzv
doc/howto/generic.sysupgrade.txt · Last modified: 2013/05/16 21:09 by tmomas