PDA

View Full Version : How to boot from USB HD?


qole
2008-08-21, 00:37
Hey all hacker-types,

I have created an ext3 partition on my USB HDD, and I cloned my Diablo to it. I then tried to boot from this partition, but my bootmenu just says N/A beside that option. Is it because the USB drive doesn't mount right away? Is there something I have to add to the initfs / bootmenu to get the drive to mount?

just for your info, it is /sys/block/sda/sda2

I have several working bootable partitions on my SD cards, I just wanted to try an actual HD and see what the speed difference is...

Thanks in advance!

EDIT: Got it working! See this post for the how-to (http://www.internettablettalk.com/forums/showthread.php?p=216853#post216853).

qole
2008-08-21, 17:06
I notice that older versions of fanoush's bootmenu had a USB HD menu choice. Can someone post the details for that menu item here? fanoush? qwerty12?

This is what I have:

USB_HDD="sda"
MENU_5_NAME="External USB HDD"
MENU_5_ID="usbsda"
MENU_5_DEVICE="sda2"
MENU_5_MODULES="mbcache ext3"
MENU_5_FSTYPE="ext3"
MENU_5_FSOPTIONS="noatime"
[ -d "/sys/block/${USB_HDD}/${MENU_5_DEVICE}" ] || MENU_5_NAME="(${MENU_5_NAME}) N/A"


Perhaps there's something that has to be done to put the N800 into host mode (I do have the OTG dongle)?

qwerty12
2008-08-21, 17:11
I notice that older versions of fanoush's bootmenu had a USB HD menu choice. Can someone post the details for that menu item here? fanoush? qwerty12?

This is what I have:

USB_HDD="sda"
MENU_5_NAME="External USB HDD"
MENU_5_ID="usbsda"
MENU_5_DEVICE="sda2"
MENU_5_MODULES="mbcache ext3"
MENU_5_FSTYPE="ext3"
MENU_5_FSOPTIONS="noatime"
[ -d "/sys/block/${USB_HDD}/${MENU_5_DEVICE}" ] || MENU_5_NAME="(${MENU_5_NAME}) N/A"


Perhaps there's something that has to be done to put the N800 into host mode (I do have the OTG dongle)?

It's still in the latest bootmenu, just only in bootmenu.sh and not bootmenu.conf.example.n8x0 (something like that) and bootmenu.conf, as you know, "overwrites" options in bootmenu.conf if it is present.

Anyway, this is the entries I took from bootmenu.sh:
MENU_4_NAME="USB hard drive"
MENU_4_ID="usb"


usb is a "special" identifer and is identifed in linuxrc as follows:
usb)
root_dev=sda1
root_dev_name="USB hard drive"
root_dev_set=1
root_fstype=""
root_fsoptions=""
;;

Fanoush has a command for setting the usb mode with a menu entry:
MENU_4_USBMODE=host

qole
2008-08-21, 18:43
I added the line

MENU_5_USBMODE=host

..and I removed the line that makes it N/A. I also tried adding the stock USB command.

Still no luck.

Is there something else I can try (maybe I'm using the wrong device name? maybe I have to force-mount the partition?), or is there just no support for booting from a second partition on an external drive (sda2)?

nhanquy
2008-08-22, 05:55
MENU_5_USBMODE=host

will let set_usb_mode() to set the IT in host mode but I still don't know at what time we have /sys/block/sda/sda2 ....

MENU_5_MODULES="mbcache ext3"
MENU_5_FSTYPE="ext3"

Don't you need jbd in MENU_5_MODULES ?

fanoush
2008-08-22, 07:12
Is there something else I can try (maybe I'm using the wrong device name? maybe I have to force-mount the partition?), or is there just no support for booting from a second partition on an external drive (sda2)?
if you need sda2 don't use 'usb' id, it is hardcoded to sda1 in linuxrc. In that case fill same fields like with any card partition and enable host mode (if you don't have cable that does it for you).

Most probably there are two issues left (did not try)

1. there may be missing /dev/sda2 device node in initfs

2. there is timing problem, usb storage device discovery is slow

1 can be solved by creating it by hand (in initfs_flasher/initfs/dev) from another shell while initfs_flasher is waiting for dropbear/bootmenu.conf answer

2 can be solved by hacking end of bootmenu.sh, there is case for special ids so you may need to add similar one to the end after line that sets usb mode to host. Simple sleep should be enough.

Benson
2008-08-22, 15:29
Hey all hacker-types,

I have created an ext3 partition on my USB HDD, and I cloned my Diablo to it. I then tried to boot from this partition, but my bootmenu just says N/A beside that option. Is it because the USB drive doesn't mount right away? Is there something I have to add to the initfs / bootmenu to get the drive to mount?
Well, note that saying N/A is a different problem from not being able to boot; you can still boot even if it wasn't detected at the time the boot-menu was generated. IIUC, it'll always be bracketed out (if you use the standard test), because you're not in host mode at the time it checks for the device. So do make sure you actually try booting it; though I guess you already did.

qole
2008-08-22, 17:45
nhanquy: Yes, I noticed the missing jbd. Thanks for pointing it out. Still no luck.
Benson: I did try booting it, no luck, and I have an OTG adapter so shouldn't that force host mode?
fanoush: You've suggested some very interesting things, but your "x can be solved" lines are way too vague and over my head. Can you give me more detailed instructions? Something I can edit in the /initfs_flasher folder before flashing? Lines I can paste into bootmenu.conf?


1 can be solved by creating it by hand (in initfs_flasher/initfs/dev) from another shell while initfs_flasher is waiting for dropbear/bootmenu.conf answer


I don't have the initfs/dev file in my initfs_flasher folder.

2 can be solved by hacking end of bootmenu.sh, there is case for special ids so you may need to add similar one to the end after line that sets usb mode to host. Simple sleep should be enough.

A specific example would be excellent and most appreciated here!

nhanquy
2008-08-22, 23:06
[
I don't have the initfs/dev file in my initfs_flasher folder.


look under /mnt

qole
2008-08-22, 23:26
I don't have the initfs/dev file in my initfs_flasher folder.


look under /mnt

I don't have an initfs_flasher folder under /mnt either. I have an initfs folder, but fanoush wrote initfs_flasher. :confused:

Can I copy the file from /mnt/initfs/dev and drop it into the initfs_flasher folder somewhere and get it to copy over when I flash the initfs?

EDIT: AAHHH I think I get it. When the initfs_flasher process gets to the part where it is waiting for an answer from the user about dropbear, I open a second terminal window and "touch .../initfs_flasher/dev/sda2" ? Or maybe "cp .../initfs_flasher/dev/sda1 .../initfs_flasher/dev/sda2"? Then carry on with the install in the first window. Theoretically, this file will get copied over to the initfs.

qole
2008-08-23, 00:07
Ok, connected my HD, opened two terminals, and then when the flasher was waiting at the dropbear prompt, I went to the second terminal (as root, in the directory above my initfs_flasher dir) and did:

cp /dev/sda2 initfs_flasher/initfs/dev/sda2
I now have /mnt/initfs/dev/sda2 but I still can't boot to that partition. So now I need some guidance on workaround #2, the "simple sleep" command at the end of bootmenu.sh.

An interesting side effect: When I boot to internal flash or to an SD partition with the HD connected, my home screen comes up with the USB symbol in the tray and the drive already mounted. When I attempt to boot to the HD, and it fails and then boots to the internal flash, there's no USB symbol, nor is the HD attached (nothing showing under /dev)... An unplug-replug gets the drive online again... I wonder why? (EDIT: This is not the case, after all)

Benson
2008-08-23, 00:25
I don't have an initfs_flasher folder under /mnt either. I have an initfs folder, but fanoush wrote initfs_flasher. :confused:

Can I copy the file from /mnt/initfs/dev and drop it into the initfs_flasher folder somewhere and get it to copy over when I flash the initfs?

EDIT: AAHHH I think I get it. When the initfs_flasher process gets to the part where it is waiting for an answer from the user about dropbear, I open a second terminal window and "touch .../initfs_flasher/dev/sda2" ? Or maybe "cp .../initfs_flasher/dev/sda1 .../initfs_flasher/dev/sda2"? Then carry on with the install in the first window. Theoretically, this file will get copied over to the initfs.
Close, but no. the names of devices are merely conventional; the actual determination of what gets accessed through the file is from the major and minor numbers (you can see these with ls -l, where the size of an ordinary file would be), so touch will make a regular file, and cp will make a block special file named sda2 and accessing sda1.

Either copy the one from the root filesystem (and maybe chmod to match the others in the initfs?) or use mknod.

qole
2008-08-23, 04:41
Either copy the one from the root filesystem (and maybe chmod to match the others in the initfs?) or use mknod.

As you can see from the post above, this is what I did; I connected the drive and then copied the /dev/sda2 ... I will check the permissions in /mnt/initfs/dev/... hm, slightly different! sda1 (like all of the other partitions) is brw------- and sda2 is brw-r-----. Would that make a difference?

Also, the major and minor numbers of sda, sda1 and sda2 look correct;
sda: 8, 0
sda1: 8, 1
sda2: 8, 2

I would love some guidance on fanoush's second idea...

2 can be solved by hacking end of bootmenu.sh, there is case for special ids so you may need to add similar one to the end after line that sets usb mode to host. Simple sleep should be enough.

qole
2008-08-23, 05:23
OK. So, I set the permissions after copying sda2 (chmod g-r initfs_flasher/initfs/dev/sda2) and I added a new section "usb2)" (which matches my current MENU_5_ID) to the special cases at the bottom of the bootmenu.sh file:

case "$default_root" in
off)
${T2S} -c
poweroff
;;
usb2)
sleep 5
;;
esac


There is a noticeable pause after pressing the button on the HD menu choice, but it still fails to boot. Very frustrating.

Is there any kind of diagnostic message I can print on the screen to see exactly what part of the boot attempt is failing? The vague failure message, so typical of this device, is extremely unhelpful...

EDIT: Hmmm, I wonder if I put the special usb2 case at the very end... I think that's what fanoush meant... okay trying again...

EDIT2: Still no dice... interesting note, the HD shows no activity during the boot process, but after the boot failure, there is some activity as OS2008 mounts it.

fanoush
2008-08-23, 08:02
you got it, so maybe the sleep timeout is still too short? you can boot system, as root run 'cat /proc/kmsg' and measure time between switching to host mode or attaching cable and final message with disk partitions detected

I'll try it this evening, usb card reader with my regular bootable card should be enough for such test.

fanoush
2008-08-23, 21:00
OK, got it to boot. There is one more gotcha. The host mode is not enabled until any usb client (!!) module is inserted. So you need to add e.g. 'g_ether' to list of modules. Also for me the device scan took more than 5 seconds. Worked with sleep 7.

The bug/feature of host mode not working with no gadget driver loaded is known, I was already bitten (http://www.gossamer-threads.com/lists/maemo/developers/28720#28720) by this in OS2007 days.

bunanson
2008-08-23, 21:36
OK, got it to boot....

Hey, how about me, the totally uninitiated......, please, some instructions pleeeeeeease?

TIA,

bun

qole
2008-08-23, 21:51
C'mon, bun, you know me. When I figure it out, I'll post a how-to.

qole
2008-08-24, 00:18
OK, got it booting.

First: it was a disappointment. Not really any noticeable speed difference, and difficult to use because your entire system is running over a wiggly little USB cable connected to the HD. Perhaps an advantage to this is being able to load your system up with huge apps. But who does that anyway? If you really needs lots of system space, just get a 16GB flash card instead. Perhaps another advantage is being able to boot any computer from a single drive; you can install boot partitions for linux, Mac, Windows, NIT etc.... Hmm, still dubious.

After I've said all that, here's what I did (thanks fanoush, Benson et al!) to get it working. This of course assumes that you've got multiboot, and you've got an external usb storage device that mounts as "sda" on the tablet (you can determine this by looking at /media/usb when you plug in the device). This device could be a USB key or a flash card inserted in a supported flash reader instead of an HD, of course.

1. Use a partitioning app to create a second partition on your HD, formatted as ext2 or ext3 (I used ext3, so the howto assumes this). I used Debian QTParted to shrink my fat32 partition and create a new ext3 partition. It is just not a good idea to make the first partition of any removable device into a linux partition. Windows computers will have difficulty mounting it, and the tablet will do weird things, too, if you boot to it.

http://farm4.static.flickr.com/3014/2779867436_6a2c714792.jpg?v=0 (http://www.flickr.com/photos/qole2/2779867436/)

2. I cloned my OS2008 to my new partition. First I mounted my my new HD partition as /opt. As root:

insmod /mnt/initfs/lib/modules/2.6.21-omap1/mbcache.ko
insmod /mnt/initfs/lib/modules/2.6.21-omap1/jbd.ko
insmod /mnt/initfs/lib/modules/2.6.21-omap1/ext3.ko
mount -t ext3 /dev/sda2

(note that one or more of the first three commands may fail with "file exists", that's OK)

...and then I used Milhouse's nupgrade.sh script (http://www.internettablettalk.com/forums/showthread.php?t=8631) (steps 2-4) to do the cloning.

3. I edited my initfs_flasher/bootmenu.conf file to have the following entry:

MENU_5_USBMODE=host
MENU_5_NAME="External USB HDD"
MENU_5_ID="usb2"
MENU_5_DEVICE="sda2"
MENU_5_MODULES="g_ether mbcache jbd ext3"
MENU_5_FSTYPE="ext3"
MENU_5_FSOPTIONS="noatime"


4. I added the following to the very end of my initfs_flasher/bootmenu.sh file:


case "$default_root" in
usb2)
sleep 7
;;
esac


5a. I started the initfs_flash script to set up the bootmenu. I worked my way through the script, answering yes or no, until the "dropbear ssh" question. I stopped here and ...

5b. ...I opened a second terminal window. I gained root in the second terminal and, in the directory above the initfs_flasher dir (in my case, this is /root), I made sure that the drive was plugged in and working and then issued the following commands:


cp /dev/sda2 initfs_flasher/initfs/dev
chmod g-r initfs_flasher/initfs/dev/sda2


5c. I then went back to the initfs_flash screen and finished the flashing process.

DONE.

When the system reboots, your tablet should be able to boot to partition 2 on the external usb storage device.

So, fanoush, any possibility of adding some stuff to your initfs_flasher package to eliminate the need to do those hacks?

computerfreek
2008-09-05, 20:32
OK, got it booting.
3. I edited my initfs_flasher/bootmenu.conf file to have the following entry:

MENU_5_USBMODE=host
MENU_5_NAME="External USB HDD"
MENU_5_ID="usb2"
MENU_5_DEVICE="sda2"
MENU_5_MODULES="g_ether mbcache jbd ext3"
MENU_5_FSTYPE="ext3"
MENU_5_FSOPTIONS="noatime"


4. I added the following to the very end of my initfs_flasher/bootmenu.sh file:


case "$default_root" in
usb2)
sleep 7
;;
esac


?

Can you send me your bootmenu.conf and bootmenu.sh .. I edited mine over and over .. it seems like my usb starts working but then i can not boot to my exteral flash card on my n810.

I need a boot menu setup
like this

internal flash
external mmc card partition 2 ext 2
And the one you made for USB2 !

Hope u can help .

Thank you
Compuerfreek

fanoush
2008-09-06, 20:17
you also need to copy sda2 device node to initfs as explained previously, it won't boot without it

computerfreek
2008-09-08, 00:07
you also need to copy sda2 device node to initfs as explained previously, it won't boot without it

I get that far but after the flash my beetmenu is all messed up where i can not boot from my MMC card on my n810 .This is what i have so far . But after useing this bootmenu.conf I can not boot from my mmc . Can you or anyone see where my error is ? if i flash initfs without bootmenu.conf it boots my flash and mmc card just fine .I also like to have it boot auto to my mmc card too.


# bootmenu customisation file
#
# included from bootmenu.sh after default menu is defined
# you can change some items or redefine menu completely

# timeout for automatic selection when no key is pressed
# set to -1 for no timeout (not recommended, can drain battery when device reboots unatteded)
MENU_TIMEOUT=30

# IP address for USB networking
USB_IP=192.168.2.103

# dim screen when in menu
#/usr/sbin/dsmetest -l 1

# menu items
MENU_MIN=1 # first item index

#no need to redefine
#MENU_1_NAME="Internal flash"
#MENU_1_ID="flash"

MENU_2_NAME="Internal MMC, partition 2, ext2"
MENU_2_ID="mmc2"
MENU_2_DEVICE="mmcblk1p2"
MENU_2_MODULES="mbcache ext2"
MENU_2_FSTYPE="ext2"
MENU_2_FSOPTIONS="noatime"

MENU_3_NAME="External MMC card, partition 2, ext3"
MENU_3_ID="mmc12"
MENU_3_DEVICE="mmcblk0p2"
MENU_3_MODULES="mbcache jbd ext3"
MENU_3_FSTYPE="ext3"
MENU_3_FSOPTIONS="noatime" #",data=writeback"

MENU_4_NAME="Power off (when not on charger)"
MENU_4_ID="off"

MENU_5_USBMODE=host
MENU_5_NAME="External USB HDD"
MENU_5_ID="usb2"
MENU_5_DEVICE="sda2"
MENU_5_MODULES="g_ether mbcache jbd ext3"
MENU_5_FSTYPE="ext3"
MENU_5_FSOPTIONS="noatime"

#last item index, change if you add/remove items
MENU_MAX=5


cp bootmenu.conf.n8x0.example bootmenu.conf


Thanks


computerfreek

nhanquy
2008-09-08, 03:32
1.did you have ext2 or ext3 on the usb drive?

Change /Add if you have ext2:

MENU_5_USBMODE=host
MENU_5_NAME="External USB HDD"
MENU_5_ID="usb2"
MENU_5_DEVICE="sda2"
MENU_5_MODULES="g_ether mbcache jbd ext2"
MENU_5_FSTYPE="ext2"
MENU_5_FSOPTIONS="noatime"

2. did you change bootmenu.sh with sleep 7?

computerfreek
2008-09-08, 04:16
1.did you have ext2 or ext3 on the usb drive?

Change /Add if you have ext2:

MENU_5_USBMODE=host
MENU_5_NAME="External USB HDD"
MENU_5_ID="usb2"
MENU_5_DEVICE="sda2"
MENU_5_MODULES="g_ether mbcache jbd ext2"
MENU_5_FSTYPE="ext2"
MENU_5_FSOPTIONS="noatime"

2. did you change bootmenu.sh with sleep 7?

ext3 ! and i also added sleep to bootmenu.sh . I get this part but

bootmenu.conf.n8x0.example is messing me up as if i use this + add the new "USB hard drive "host" menu 5 to the menu . I then can not BOOT to my mmc card on my n810. Can some one look over my menu and see why after useing the bootmenu.conf.n8x0.example or my own menu i can not boot to mmc it fails . but if I flash with defaults and no bootmenu.conf i can boot just fine to my mmc.

At this pont i just need someone to give me a menu in this order

Intarnal flash
mmc2 ? n810 partition 2 of my mmc card
USB harddrive "host mode"

And have it auto boot after time out to mmc card .


Thank for you help and geting back to me on this..

Computerfreek

fanoush
2008-09-08, 04:59
what you used to edit the file? you need plain text editor like vi,mcedit,leafpad and line endings should be unix (so no notepad or wordpad on Windows)

computerfreek
2008-09-08, 06:17
I used VI to edit all files . The menu is fine .. it just will not boot to my mmc card where the default menu is fine .

nhanquy
2008-09-08, 11:16
I used VI to edit all files . The menu is fine .. it just will not boot to my mmc card where the default menu is fine .

Look at your bootmenu.conf, I think you have a modified copy from an older version of bootmenu.conf.n8x0.example.

You need to download a newer version of initfs_flasher.

Mine look like these:

computerfreek
2008-09-08, 16:32
I downloaded it from here http://fanoush.wz.cz/maemo/ So i am gessing it is upto date here.

I will redownload and start over from step 1 and see if it works using the menu's you have here .


Thanks for your help
computerfreek

computerfreek
2008-09-08, 17:05
UPDATE !! It works now !!

I started over from Step 1 and deleted all initfs_flasher stuff then i redownloaded it and untar it.

2 I used the boot menu's you sent "thanks"

3 reflashed with new boot menu's

4 Stoped at SSH install .. and copy over sda2

4 chmod the sda2 that i copy over

5 let init_flash go the rest of the way..

6 very happy it booted from usb !! ext3

Thanks Guys for all your help this is great way of playing around as i have meny drive images of my mmc card .. with older os on it.

Thank you !!

computerfreek