Welcome! Log In Create A New Profile

Advanced

installed debian on usb stick than adding a freeagent HDD ?

Posted by Fred 
Hi,

first of all thank you to jeff and all the geeks making this small box working great with a debian :)

I installed squeeze on a new dock, on a usb stick. I'm looking for a freeagent HDD, in order to make a small NAS of the dockstar.

Question : if i had the freeagent disk on the usb on the top of the dock, will it still boot on the usb or do i have to change something in the boot configuration ? Is there an order in the 4 usb plug ?

Thanks !
Fred
Re: installed debian on usb stick than adding a freeagent HDD ?
July 03, 2011 02:35PM
Have a look at this:

http://forum.doozan.com/read.php?3,12

When using the unmodified uboot environment (boot command) the dockstar will try to boot from the first detected USB device. The usb port that is scanned first is the one on top. So you would be out of luck, as the dockstar would probably seize to boot with the harddisk in place.

The solution is described in the link above. With this modification the dockstar will scan all usb devices, look for the kernel boot files on them and if successful, will boot from the first BOOTABLE. That should work, unless you have a linux install on the hdd, too. ;-)
Thank you very much !
No the disk will be a classical non bootable NTFS or FAT32 drive... i will read this, hoping i will be able to make it without bricking my dockstar ! Seems not so easy :(

Fred
Re: installed debian on usb stick than adding a freeagent HDD ?
July 03, 2011 03:31PM
Seems harder than it actually is.

1) Boot your dockstar into linux.
2) Paste the full command, from the linked posting, into the command line:

fw_setenv usb_init 'usb start; if ext2load usb 0:1 0x800000 /boot/uImage; then setenv usb_device 0:1; setenv usb_root /dev/sda1; elif ext2load usb 1:1 0x800000 /boot/uImage; then setenv usb_device 1:1; setenv usb_root /dev/sdb1; elif ext2load usb 2:1 0x800000 /boot/uImage; then setenv usb_device 2:1; setenv usb_root /dev/sdc1; elif ext2load usb 3:1 0x800000 /boot/uImage; then setenv usb_device 3:1;setenv usb_root /dev/sdd1;fi;'

3) Hit enter.
4) Check if the "usb_init" command was really successfully set to exactly what the posting by Jeff said. You can do so by issueing a "fw_printenv" directly under linux.
5) If it was set correctly, then the new way of scanning USB devices will work correctly, next time you reboot the dockstar.
6) If something went wrong with the command, just repeat 2) with the corrected version, until it's OK.

Edit: BTW, if I'm not mistaking, you need root rights, at least for the fw_setenv. The fw_printenv could work as a normal user, too.



Edited 1 time(s). Last edit at 07/03/2011 03:32PM by ingmar_k.
Re: installed debian on usb stick than adding a freeagent HDD ?
July 04, 2011 12:08PM
The usb_scan "function" runs through all the usb ports in a fixed order (until it can e2load /boot/uImage) and assigns that disk a device id based on the it's port. This is then device is passed to the kernel as the root parameter. The problem is that when the kernel boots, it can identify the devices in a different order, making the kernel load the root file system from the wrong disk.

The proper way to address this is how any modern Linux distro does it, by setting the root to a LABEL or UUID. Look at my response here. I just tested this and it seems to work fine:

http://forum.doozan.com/read.php?2,5073

The only issue is that U-boot cannot dynamically get the device LABEL or UUID, so you have to manually configure it in the bootargs. (But this is really no different than a Linux distro where the root parameter is configured in the LILO or GRUB menu entry.)

I've just not had the chance to take this a step further and work up the exact configuration to permanently store in the U-boot environment so that it will persist after reboots. I think the only change would be this though:

fw_setenv usb_init run usb_scan; setenv usb_root LABEL=[LABEL]

This should run the "usb_scan" which is critical to setting the usb_device variable to where it should load /boot/uImage and /boot/uInitrd. But force the usb_root variable that's passed to the kernel as the root parameter to use the specified label.
Thank you for your answers.

But, am i wrong but when you say :
ingmar_k Wrote:
-------------------------------------------------------
> Seems harder than it actually is.
>

> 6) If something went wrong with the command, just
> repeat 2) with the corrected version, until it's
> OK.

Isit me or if something goes wrong when modifying the boot, there is a possibility that you won't reboot ?

Fred
Thank you for your answers.

But, am i wrong but when you say :
ingmar_k Wrote:
-------------------------------------------------------
> Seems harder than it actually is.
>

> 6) If something went wrong with the command, just
> repeat 2) with the corrected version, until it's
> OK.
-------------------------------------------------------
Isit me or if something goes wrong when modifying the boot, there is a possibility that you won't reboot ?

Fred
Re: installed debian on usb stick than adding a freeagent HDD ?
July 06, 2011 03:59PM
kraqh3d Wrote:
-------------------------------------------------------
> The usb_scan "function" runs through all the usb
> ports in a fixed order (until it can e2load
> /boot/uImage) and assigns that disk a device id
> based on the it's port. This is then device is
> passed to the kernel as the root parameter. The
> problem is that when the kernel boots, it can
> identify the devices in a different order, making
> the kernel load the root file system from the
> wrong disk.
>
> The proper way to address this is how any modern
> Linux distro does it, by setting the root to a
> LABEL or UUID. Look at my response here. I just
> tested this and it seems to work fine:
>
> http://forum.doozan.com/read.php?2,5073
>
> The only issue is that U-boot cannot dynamically
> get the device LABEL or UUID, so you have to
> manually configure it in the bootargs. (But this
> is really no different than a Linux distro where
> the root parameter is configured in the LILO or
> GRUB menu entry.)
>
> I've just not had the chance to take this a step
> further and work up the exact configuration to
> permanently store in the U-boot environment so
> that it will persist after reboots. I think the
> only change would be this though:
>
> fw_setenv usb_init run usb_scan; setenv usb_root
> LABEL=
>
> This should run the "usb_scan" which is critical
> to setting the usb_device variable to where it
> should load /boot/uImage and /boot/uInitrd. But
> force the usb_root variable that's passed to the
> kernel as the root parameter to use the specified
> label.

Nice idea and info. I think I'll give that a try. Seems to be an intersting solution.

Fred Wrote:
-------------------------------------------------------
> Thank you for your answers.
>
> But, am i wrong but when you say :
> ingmar_k Wrote:
> --------------------------------------------------
> -----
> > Seems harder than it actually is.
> >
>
> > 6) If something went wrong with the command,
> just
> > repeat 2) with the corrected version, until
> it's
> > OK.
> --------------------------------------------------
> -----
> Isit me or if something goes wrong when modifying
> the boot, there is a possibility that you won't
> reboot ?
>
> Fred

Well if the usb_init function/command got set wrong then of course you shouldn't reboot, but correct the error and check again. Of couse the system won't be able to boot from USB when your usb_init command doesn't do anything useful. That doesn't mean however that the dockstar is completely bricked.

You could alternatively try the solution that kraqh3d posted.
Anyway there will always be the possibility of making a mistake and being unable to boot the device You have to be aware of that. But, if you want your setup to work the way you described it, then you'll have no other choice but to change the usb_init entry one way ot the other.
Ok. thank you to both of you.
In fact i put the new hard drive when the dockstar is booted... it is due to be always up... so i will stay with a manual boot sequence ;) Take the HDD out when i boot then put it back and mount it. For now.... i will se if it enough for my needs.

Fred
Re: installed debian on usb stick than adding a freeagent HDD ?
July 09, 2011 07:57AM
You you give my suggestion a try? It can tested without making any permanent changes. The U-boot environment has setenv and saveenv. Setenv is transient. Saveenv is permanent like fw_setenv from the linux shell.

First, set the label of your root stick. From the linux shell:
tune2fs -L ROOTFS /dev/sda1
(Make sure you use the right device. It should be sda1 if you don't have anything else connected.)

Then set up netconsole to access the U-boot environment before it loads the kernel. (It's a few fw_setenv commands that define a static ip address for the dockstar, and open up a net console session to a remote ip address on port 6666.) This is just useful to have anyway.
http://forum.doozan.com/read.php?3,14,14

I suggest using this tool that another member wrote, instead of netcat or socat. It's much more reliable for bidirectional communication.
http://svolli.org/software/asuc/

Start up your netconsole, and reboot...
You should see a prompt to abort the boot... Control-J a few times will get you to a Marvell>> prompt

Connect your hard drive. and do:

printenv usb_init
setenv usb_init run usb_scan; setenv usb_root LABEL=ROOTFS
(it'll echo the change back you so you can verify it changed.)
run usb_init

(None of these changes are permanent. and if all goes well, it'll boot properly.)
Hi, thank you for your proposition. But i made a small test yesterdy : i rebooted with my hard drive and the usb key. In fact it booted on the key, probably because the hard drive is not bootable. The only thing a little annoying was the fact that the HDD was sda and the usb key was sdb. It was a little bad for my udev rules for automouting usb devices. But, it booted correctly, so even if i had to reboot, it will be ok in fact. I have nothing to do.

For info i installed debian two weeks ago. Perhaps some changes have been made to the uboot of jeff... don't know. But that's ok for me ! :) Perhaps someone else will try the trick for his needs ;)

Thanks for all !

Fred
Re: installed debian on usb stick than adding a freeagent HDD ?
July 10, 2011 03:35AM
Strange but good for you. I don't know, maybe Jeff already made the newer usb_init script the default in the meantime.
Could you perhaps run fw_printenv and post the "usb_init" part?
Here it is :

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


Hope that will help you to understand why it booted like that :)
Very strange this line :
usb_root=/dev/sda1

This is not what i observed. The system IS up and running on /dev/sdb.

Result of a mount
# mount
rootfs on / type rootfs (rw)
/dev/root on / type ext2 (rw,noatime,errors=remount-ro)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,relatime,mode=755)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev type tmpfs (rw,relatime,size=10240k,mode=755)
/dev/sdb1 on /media/usbhd-sdb1 type ext2 (rw,noatime,errors=remount-ro)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,relatime)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620)
tmpfs on /tmp type tmpfs (rw,relatime)
/dev/sda1 on /media/FreeAgent type ext3 (rw,relatime,barrier=0,data=ordered)


This is from the fdisk on a running system

Disk /dev/sdb: 4040 MB, 4040724480 bytes
125 heads, 62 sectors/track, 1018 cylinders
Units = cylinders of 7750 * 512 = 3968000 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x323c3f33

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 926 3588219 83 Linux
/dev/sdb2 927 1018 356500 82 Linux swap / Solaris



But my skills are overflowed right now :)
I installed debian few days ago. Launched jeff's script, but error... so launched another one found on this forum.
But the jeff's script installed the uboot.

Fred
Re: installed debian on usb stick than adding a freeagent HDD ?
July 10, 2011 03:02PM
Doesn't look like a updated version.
My wild guess would be that the hdd took too long to answer the uboot request, so it was skipped, but later seen by the kernel, thus the reversed order. As I said, only a guess. Could be that next time you reboot it won't boot, like it did this time. You could try.
Re: installed debian on usb stick than adding a freeagent HDD ?
July 10, 2011 06:44PM
Fred...

The difference between booting and not booting rests on how the kernel enumerates the disks and assigns them device names. It really doesn't matter which disks may be bootable or not. The U-boot passes a root parameter to the kernel. But since U-boot doesn't have devices, it tries to assume what linux will call the device that it determines is the boot disk (by looking for the file /boot/uImage.)

I'm pretty sure you did not boot from /dev/sda1. The environment variable "usb_device=/dev/sda1" is a default starting value that's stored in the uboot environment section of flash. It's not what that variable was evaluated to when usb_scan ran. As I was explaining earlier, the U-boot has two different commands... setenv and saveenv. Setenv modifies the environment in memory, but doesn't save them to flash. You need to do a saveenv to have those variable be stored to flash. The linux command fw_printenv only shows what's saved on flash.

"cat /proc/cmdline" to see what really happened. It'll show you the usb_bootargs parameter that was passed to the kernel. Look at the "root=" bit in particular. This is what usb_root was found to be.

Here's mine as a comparison. My system is still booted up from when I was playing about with using a label for the root filesystem.

root@debian:~# fw_printenv usb_root
usb_root=/dev/sda1

root@debian:~# cat /proc/cmdline
console=ttyS0,115200 root=LABEL=ROOTFS rootdelay=10 rootfstype=ext3 mtdparts=orion_nand:1M(u-boot),4M(uImage),32M(rootfs),-(data)

** edit **
My boot procedure earlier isn't correct. You need to do this from the Marvell>> prompt:

usb start
run usb_scan
setenv usb_root=LABEL=ROOTFS
run usb_set_bootargs
printenv bootargs
(verify the root parameter)
run usb_boot

** edit **
What are your udev rules? Maybe we can tweak thoses? I posted the details of my udev rules and auto-mounting procedure in another thread for reference.



Edited 3 time(s). Last edit at 07/10/2011 07:02PM by kraqh3d.
Re: installed debian on usb stick than adding a freeagent HDD ?
September 28, 2011 04:10PM
Hi kraqh3d,
if I do your commands manually I can boot from a USB-Stick even if a SATA HD is connected to the GoFlex Net device.

usb start
run usb_scan
setenv usb_root=LABEL=ROOTFS
run usb_set_bootargs
printenv bootargs
(verify the root parameter)
run usb_boot

There is one typo: setenv usb_root=LABEL=ROOTFS should be setenv usb_root LABEL=ROOTFS .

Now my question:
1. How can I change the U-Boot environment to save this settings permanently, so I can savely boot from USB, even if a HD is connected?
2. Can I still boot from NAND (Rescue-System) if no Stick and no HD is connected?
3. Can I still boot from SATA?

Greetings,
Thomas
Re: installed debian on usb stick than adding a freeagent HDD ?
September 29, 2011 07:53AM
Sorry about that. The easiest way to make this permanent is to fw_setenv from linux. I modified usb_init to make the change. I don't have access to my system at his very moment, but I'm fairly certain this is what I did:

fw_setenv usb_init "run usb_scan ; setenv usb_root LABEL=ROOTFS"

If you trace through the usb startup procedure, it goes like this:
1. bootcmd eventually runs usb_bootcmd
2. usb_bootcmd first runs usb_init
3. usb_init runs usb_scan which is needed to find the usb device for loading the kernel, but it also can incorrectly define the rootfs as /dev/sda1. so we changed usb_init to change it to a label aftewards.
4. usb_bootcmd then continues and runs usb_set_bootargs which sets the bootargs that are passed to the kernel (now with a label for the rootfs)
5. finally it runs usb_boot which loads the kernel and initrd



Edited 1 time(s). Last edit at 09/29/2011 07:54AM by kraqh3d.
Re: installed debian on usb stick than adding a freeagent HDD ?
September 30, 2011 02:26AM
Hi kraqh3d,
thanks a lot for the answer. I think I'll go crasy with this! For me it works, but for a friend of mine not. To become more clear, here some points:

1. is the command <fw_setenv usb_init "run usb_scan ; setenv usb_root LABEL=ROOTFS"> all I need if I have the actual Jeff's bootloader (U-Boot) installed ?
2. Are the quotationsmarks <"> right or should the be <'> ?
3. Is the capitalized <ROOTFS> important or can it be also with lower cases like <rootfs> ?
4. Must the name of the partition also be <ROOTFS> (capitalized) or does <rootfs> fit as well ?
5. How should the entry in the /etc/fstab be ?
6. Are these settings only important for a Goflex Net with attached SATA HD or are they good for the Dockstar with attached USB-HD as well ?

Thanks a lot,
Greetings

Thomas
Re: installed debian on usb stick than adding a freeagent HDD ?
October 04, 2011 04:09PM
1. Yes this assumes you have the default uBoot installed.

2. Either quotes are acceptable. It won't matter in this case.

3/4. No. It doesn't have to be "ROOTFS" specifically, but it must exactly match the label of your root file system, that you set via e2label. That't just what I use ROOTFS on my Dockstar. The capital letters stand out.

5. Leave it as is which should be "/dev/root". This is just a symlink to whatever the kernel root parameter maps to, in my case it would be a symlink to something like /dev/disk/by-label/ROOTFS

(Now that I think about it, I suspect using a /dev/disk/by-label/<label> path as your root parameter would work as well, but I've never tried.)

6. This definitely works for the Dockstar. I'm currently using this boot technique on my Dockstar with three USB hard drives attached. My root stick is connected to the top USB port where a Freeagent drive would sit, but I've disconnected that port and wired a standard type A port to the header on the board to accept my root stick. I haven't had the top cover on my Dockstar since I got it ;)
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: