Welcome! Log In Create A New Profile

Advanced

Cheaty SATA boot on GoFlex Net

Posted by Julian Calaby 
Julian Calaby
Cheaty SATA boot on GoFlex Net
February 05, 2011 06:40AM
Hi all,

So, after reading through the docs, going back and forth and generally stuffing around, I finally figured out a way to get my GoFlex net to boot from SATA without compiling anything.

The principle is blatantly pinched from the SPARC community where their bootloader is traditionally not smart enough to deal with large partitions, hence the standard procedure for booting is to place the files necessary to boot in a small partition at the start of the disk, then point the bootloader at them, at which point the kernel and initrd will then boot us to a point where we can read the entire disk and continue to boot normally.

So my idea was to use a small partition on the flash drive in place of this small partition and use uBoot's awesomeness to boot files from in there.

My procedure is as follows:
1. Use Jeff's script to set up a linux partition on a USB attached disk that will plug in the top.
2. Install the linux-image-2.6.37-rc7-kirkwood package from Debian Experimental.
3. Change the arcNumber to 2678 (sheevaplug eSATA reference) to convince this kernel to set up the SATA ports.
Note that despite information I've read elsewhere, bootloader interaction doesn't seem to be required to get them to work - this kernel sets them up fine on it's own.
4. Alter fstab to mount the original pogoplug root image somewhere sensible by adding the line:
/dev/mtdblock2 /boot/uImages jffs2 noatime,errors=remount-ro 0 1
5. Mount the directory
mount /boot/uImages
6. Back up the device (optional =) )
cd /boot/uImages
tar -cvpzf /root/pogo_bkp.tar.gz *
7. Wipe the device
cd /boot/uIimages
rm -rf *
8. Add the following two lines to the end of /usr/sbin/flash-kernel
cp -f /boot/uImage /boot/uImages
cp -f /boot/uInitrd /boot/uImages
Note: This is an UGLY HACK
9. Run update-initramfs -u
10. Add a bootcmd to uBoot to boot from these files

I use the prefix "piggy" for this, and set the bootcmd as follows:
fw_setenv piggy_bootcmd 'run usb_set_bootargs; mw 0x800000 0 1; if fsload 0x800000 /uImage; then if fsload 0x1100000 /uInitrd; then bootm 0x800000 0x1100000; else bootm 0x800000; fi; fi'
Then I insert this just before the usb bootcmd is called from bootcmd
fw_setenv bootcmd 'usb start; run force_rescue_bootcmd; run ubifs_bootcmd; run piggy_bootcmd; run usb_bootcmd; usb stop; run rescue_bootcmd; run pogo_bootcmd; reset'

At this point, I can power off the device, slot the disk into the top and boot normally.

Notes:
- This is writing to flash memory *every* time you update your initrd, and *every* time you install a kernel, so this will wear out relatively fast if you update often. I've made it only copy the needed files into flash, so hopefully it'll cycle through this chunk of flash so you won't wear it out *too* quickly, but you can never really be sure.
- I *strongly* recommend that you update /etc/initramfs-tools/initramfs.conf to *only* include the modules you need. This will mean less stuff gets put in the initramfs and less cycling of the flash will occur.
- The script I've hacked up there only updates the booted image if it's installed through the Debian Kernel packaging system and has an initrd. This will work for all stock Debian kernels, but you're on your own if you're compiling your own. (that said, it will boot it properly, but then I did crib the code from usb_bootcmd)
- If I take the disk and plug it back in through USB, then it will still boot from the files we created as piggy_bootcmd is still getting to the bootm statements - that said, everything is smart enough to figure out which disk to boot from and it should still boot properly. To revert back to a pristine usb booting system, either delete or rename the files in /boot/uImages from under Linux or put bootcmd back how it was.
- If flash-kernel is ever updated, then the hack at step 8 will have to be repeated.

I take no responsibility for your device breaking, but that said, this is probably safer and more permanent than building a new uboot.

Thanks,

Julian Calaby
Re: Cheaty SATA boot on GoFlex Net
February 28, 2011 01:22PM
Finally instruction for GoFlex Net :) Thought, I need to figure out commands for step-1,2,3.
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: