Re: Upgrading an ALIX board w/o serial and from remote ssh

Home Page Forums Network Management ZeroShell Development vmware image Re: Upgrading an ALIX board w/o serial and from remote ssh

#48417

schoopy
Member

Dear all,

As an ALIX board user, I was always bothered with opening the ALIX case, unscrewing everything to get access to the CF card, replacing the image and rebuilding it all.
I have finally figured out a way to get rid of that trouble!

Problem is in the second partition being a Z iso image mounted under /cdrom. You cannot access it from dd if not previously unmounted. The latter cannot be done from remote since ssh lies within the mounted image. So unless you want to do it manually from a serial connection, this is not possible for several reasons!
1. you would have to copy all the SSH required files within RAM under /(bin,sbin,etc).
2. You would have to stop all services without killing SSH and since this is done with the use of killall5, SSH gets killed since the script calling killall5 is not having the SSH pid! Trying without killall5 is fastidious if we want it to work for all cases, all services would have to be checked!

But by having either another partition of your CF card mounted under /mnt (for example) or a USB key holding the new CDROM.iso file you can trick the system reboot.

This is how it works:

I added a new script file in /etc/init.d, /etc/init.d/upgrade, and linked it in /etc/rc.d/rc6.d which holds what should be done during reboot.
Therefore right before unmounting the file system K60mountfs you add a link to upgrade (k55upgrade -> ../init.d/upgrade).
The system will thus have completely destroy all services allowing you to correctly unmount /cdrom, do your task of upgrading, and then terminate the reboot.

This is the upgrade script file I used (it is not checking anything and expects CDROM.iso to be in /mnt/):


#!/bin/bash

IMAGE_DEV=/mnt
IMAGE_NAME=CDROM.iso

echo "Upgrading /dev/hda2 to image in $IMAGE_NAME"

umount /cdrom
dd if=$IMAGE_DEV/$IMAGE_NAME of=/dev/hda2
mount -a

I did try several times using image created from the dev kit from my work directly to my home through the internet and it worked great.

DISCLAIMER : THE NEW IMAGE SIZE HAS TO BE SMALLER THAN THE PARTITION DEDICATED TO IT OTHERWISE YOUR DATA PLACED IN THE THIRD PARTITION WILL BE SMASHED!!!
LESS THAN 145 MB IS OK, IN FACT A BIT MORE BUT WE KEEP SOME MARGIN HERE

Upon reboot, the upgrade file will have disappear since it is placed in the RAM root /.

Note that the idea could also be used for ALIX board to get completely upgraded provided a USB key holds the full disk image!

Regards,

Schoopy