Bekijk de volledige versie : Is it possible to boot from USB disk?

21-03-2004, 21:03
To make easier mods to the system, would it be possible to boot from a HD attached to the USB?

I guess it involves changing this
Kernel command line: root=/dev/mtdblock2 noinitrd console=ttyS0,115200
to something like root=/dev/sda2, and compiling the kernel to have the usb stuff, and a ext2 driver not as modules

The thing I did sofar is to make a ext2 partition, copied the whole filesystem to it. Then I try to mount it

~ # mount
/dev/root on / type cramfs (ro)
none on /dev type devfs (rw)
none on /proc type proc (rw)
/ramfs on /mnt/ramfs type ramfs (rw)
/dev/scsi/host0/bus0/target0/lun0/part1 on /mnt/usbfs type vfat (rw)
/dev/scsi/host0/bus0/target0/lun0/part2 on / type ext2 (rw)
/dev/scsi/host0/bus0/target0/lun0/part2 on /mnt/usbfs/n type ext2 (rw)

although it appears from the mount that it is mounted to /, there is also still the cramfs mounted. I don't seem to be able to unmount it.

One more strange thing, I mounted a swap partition. But somehow I don't see it with the mount command. Anyway, as I see there is not a whole lot of memory left. Will removing the ramfs improve this?

~ # cat /proc/meminfo
total: used: free: shared: buffers: cached:
Mem: 14782464 13082624 1699840 0 905216 7626752
Swap: 123367424 1224704 122142720
MemTotal: 14436 kB
MemFree: 1660 kB
MemShared: 0 kB
Buffers: 884 kB
Cached: 6688 kB
SwapCached: 760 kB
Active: 7136 kB
Inactive: 1924 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 14436 kB
LowFree: 1660 kB
SwapTotal: 120476 kB
SwapFree: 119280 kB

22-03-2004, 00:16
I'll be interested to see what you come up with. You might want to take a look at the O'Reilly book "Building Embedded Linux Systems" by Karim Yaghmour.

22-03-2004, 19:21
The idea is to use the existing cramfs in the way of using it as initrd. So, then the linux boots it will call /linuxrc - this will be a script which in fact loads the modules both for usb & fs, tries to mount new root filesystem from flash and then if it succeeds just exec init from it, otherwise it's just calling good old cramfs init.
This seems be easy to do, but needs time...