Welcome! Log In Create A New Profile

Advanced

"Dual Boot" between rescue and usb?

Posted by edinger 
"Dual Boot" between rescue and usb?
March 03, 2011 02:01AM
Hi,
I want to switch between the installed debian system on usb an the rescue-system (V2) from script/remote.
So the normal way (shutting down, unplugging usb, boot into rescue and re-plug usb) is not possible.
How can I hande this? I'm a little bit scary changing anything in the boot environment, but I think the correct use of fw_setenv is the right way.
Finally I want to use it for planned regular backups of the usb-system.
Has anybody implemented something similar?

Dieter

Here is the current output of fw_printenv:
ethact=egiga0
bootdelay=3
baudrate=115200
mainlineLinux=yes
console=ttyS0,115200
led_init=green blinking
led_exit=green off
led_error=orange blinking
mtdparts=mtdparts=orion_nand:1M(u-boot),4M(uImage),32M(rootfs),-(data)
mtdids=nand0=orion_nand
partition=nand0,2
stdin=serial
stdout=serial
stderr=serial
rescue_set_bootargs=setenv bootargs console=$console ubi.mtd=2 root=ubi0:rootfs ro rootfstype=ubifs $mtdparts $rescue_custom_params
rescue_bootcmd=if test $rescue_installed -eq 1; then run rescue_set_bootargs; nand read.e 0x800000 0x100000 0x400000; bootm 0x800000; else run pogo_bootcmd; fi
pogo_bootcmd=if fsload uboot-original-mtd0.kwb; then go 0x800200; fi
force_rescue=0
force_rescue_bootcmd=if test $force_rescue -eq 1 || ext2load usb 0:1 0x1700000 /rescueme 1 || fatload usb 0:1 0x1700000 /rescueme.txt 1; then run rescue_bootcmd; fi
ubifs_mtd=3
ubifs_set_bootargs=setenv bootargs console=$console ubi.mtd=$ubifs_mtd root=ubi0:rootfs rootfstype=ubifs $mtdparts $ubifs_custom_params
ubifs_bootcmd=run ubifs_set_bootargs; if ubi part data && ubifsmount rootfs && ubifsload 0x800000 /boot/uImage && ubifsload 0x1100000 /boot/uInitrd; then bootm 0x800000 0x1100000; fi
usb_scan=usb_scan_done=0;for scan in $usb_scan_list; do run usb_scan_$scan; if test $usb_scan_done -eq 0 && ext2load usb $usb 0x800000 /boot/uImage 1; then usb_scan_done=1; echo "Found bootable drive on usb $usb"; setenv usb_device $usb; setenv usb_root /dev/$dev; fi; done
usb_scan_list=1 2 3 4
usb_scan_1=usb=0:1 dev=sda1
usb_scan_2=usb=1:1 dev=sdb1
usb_scan_3=usb=2:1 dev=sdc1
usb_scan_4=usb=3:1 dev=sdd1
usb_init=run usb_scan
usb_device=0:1
usb_root=/dev/sda1
usb_rootfstype=ext2
usb_rootdelay=10
usb_set_bootargs=setenv bootargs console=$console root=$usb_root rootdelay=$usb_rootdelay rootfstype=$usb_rootfstype $mtdparts $usb_custom_params
usb_bootcmd=run usb_init; run usb_set_bootargs; run usb_boot
usb_boot=mw 0x800000 0 1; ext2load usb $usb_device 0x800000 /boot/uImage; if ext2load usb $usb_device 0x1100000 /boot/uInitrd; then bootm 0x800000 0x1100000; else bootm 0x800000; fi
bootcmd=usb start; run force_rescue_bootcmd; run ubifs_bootcmd; run usb_bootcmd; usb stop; run rescue_bootcmd; run pogo_bootcmd; reset
ethaddr=00:10:75:1A:D9:23
arcNumber=2097
rescue_installed=1
John Doe
Re: "Dual Boot" between rescue and usb?
March 03, 2011 05:08AM
You should avoid frequent changes of the boot loader environment. It is stored in flash memory without wear leveling, so it is written to the same erase unit every time. Depending on the flash technology, a flash cell can only be written to a few thousand times. The flash memory in the Dockstar appears to be of "just good enough" quality for being used without wear leveling. The boot loader environment is critical for booting, so if these memory cells are worn out, reviving the Dockstar will be very complicated.

The answer to your problem is in this line:
Quote

force_rescue_bootcmd=if test $force_rescue -eq 1 || ext2load usb 0:1 0x1700000 /rescueme 1 || fatload usb 0:1 0x1700000 /rescueme.txt 1; then run rescue_bootcmd; fi

When you are in the USB system, create a file /rescueme on the USB stick. This puts the rescue system before the USB system in the boot sequence. When you want to boot the USB system again, remove the /rescueme file.
Re: "Dual Boot" between rescue and usb?
March 03, 2011 06:27AM
Thanks, I didn't know that this feature is builtin already.
Re: "Dual Boot" between rescue and usb?
March 17, 2011 10:42AM
How can i add this line to the ubit on mtd0?

Quote
Quote
force_rescue_bootcmd=if test $force_rescue -eq 1 || ext2load usb 0:1 0x1700000 /rescueme 1 || fatload usb 0:1 0x1700000 /rescueme.txt 1; then run rescue_bootcmd; fi


The rescue system is installed to mtd1 & mtd2, but without that bootcmd it's not working on my GoFlex Home!
John Doe
Re: "Dual Boot" between rescue and usb?
March 17, 2011 01:22PM
That line by itself does nothing. It's part of the boot scripts that Jeff wrote for the boot loader. When called, that particular line tests if the force_rescue environment variable is set to 1 or if there exists a file /rescueme on an ext2 formatted USB stick in the first USB port or if there exists a file /rescueme.txt on a FAT formatted USB stick in the first USB port. If any of these conditions hold, then the script in the variable rescue_bootcmd is executed. If not, control returns to the calling function.

This part of the boot scripts is in the force_rescue_bootcmd environment variable, because it tests for flags by which the user can force booting of the rescue system when usually the USB system would be started.

Be very careful when you modify the boot scripts. You can lock yourself out if you make a mistake. I don't have a GoFlex Home, so I will not advise you on what to do to boot the rescue system on your device.
Re: "Dual Boot" between rescue and usb?
March 17, 2011 02:12PM
Thanx for your answer!

I think that i'm not on the level to change anything of the uboot without a good description.

The reason for change the uboot to the ubit one, is the support for the sata-drive.

Exist another uboot, which support both, the sata drive and also the boot from the internal flash?
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: