Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Installing Gentoo
  • Search

[Solved] Boot from USB

Having problems with the Gentoo Handbook? If you're still working your way through it, or just need some info before you start your install, this is the place. All other questions go elsewhere.
Post Reply
Advanced search
22 posts • Page 1 of 1
Author
Message
lindegur
Apprentice
Apprentice
User avatar
Posts: 293
Joined: Sat Aug 14, 2004 10:20 pm
Location: Swiss mountains
Contact:
Contact lindegur
Website

[Solved] Boot from USB

  • Quote

Post by lindegur » Fri May 06, 2005 10:45 am

I installed Gentoo on my USB drive. Except that I replaced hda with sda, I did the installation as written in the Handbook. Grub starts and I can select the kernel to boot. During boot it hangs with the following lines:

VFS: Cannot open root device "sda3" or unknown_block(0,0)
Please append a correct "root=" boot option
Kernel panic - not syncing: VFS: unable to mont fs on unknown_block(0,0)
<6>usb 1-3: new high speed USB drive using ehci_hcd and address2

It looks to me as boot gets in troubles when the kernel re-initializes the USB hardware while it is booting from it at the same time. Am I correct and is there a way out of that?

I'm looking into initrd, but this seems for me to be a too big challenge.
Last edited by lindegur on Mon May 09, 2005 7:05 pm, edited 5 times in total.
Top
lindegur
Apprentice
Apprentice
User avatar
Posts: 293
Joined: Sat Aug 14, 2004 10:20 pm
Location: Swiss mountains
Contact:
Contact lindegur
Website

  • Quote

Post by lindegur » Fri May 06, 2005 8:08 pm

I managed to go one step further. I built a custom initrd and a new 2.6 kernel with initrd support and loopback device. As guide I took usr/src/linux/documentation/initrd.txt

It seems to run so far, but my init option gets lost:

Kernel panic - not syncing: No init found. Try passing init=option to kernel

I can plug in and out my usbhd and the system is alive and reports it. Without passing an init option that the kernel accepts, I can not write and debug the linuxrc script that sould finally bring back the usbhd as root device.

What are the necessary files to pack in the initrd? :oops:
Last edited by lindegur on Sat May 07, 2005 5:19 pm, edited 1 time in total.
Top
nixnut
Bodhisattva
Bodhisattva
User avatar
Posts: 10974
Joined: Fri Apr 09, 2004 1:43 pm
Location: the dutch mountains

  • Quote

Post by nixnut » Fri May 06, 2005 8:20 pm

Here's something related: http://forums.gentoo.org/viewtopic-t-32 ... t+usb.html
Maybe it will give you some pointers to solving your problem.
Please add [solved] to the initial post's subject line if you feel your problem is resolved. Help answer the unanswered

talk is cheap. supply exceeds demand
Top
lindegur
Apprentice
Apprentice
User avatar
Posts: 293
Joined: Sat Aug 14, 2004 10:20 pm
Location: Swiss mountains
Contact:
Contact lindegur
Website

  • Quote

Post by lindegur » Sat May 07, 2005 4:07 pm

:D an other step forward, no kernel panics anymore.

My major problem was, that I did not copy all libraries to the initrd. A chroot initrd would have shown this without boot. ldd shows what would have been required. Exept linux-gate.so that seems to be a so ghost on my computer.

I did two versions of Grub options, one that brings me into a shell where I can interactively work, the other version starts linuxrc that contains currently just some kind of hello world program.

The remaining work is now to pass the root back from the ramdisk to the usbhd using pivot_root and regularly start /sbin/init.

If everything works, I will clean up my personal notes and write a simple howto in n00b language. I also have to maintain my custom initrd and linuxrc.

:lol:
Top
lindegur
Apprentice
Apprentice
User avatar
Posts: 293
Joined: Sat Aug 14, 2004 10:20 pm
Location: Swiss mountains
Contact:
Contact lindegur
Website

  • Quote

Post by lindegur » Sat May 07, 2005 10:38 pm

:lol: Cool it works! I'm able to boot from the USB Harddisk. Ready to install KDE and all the fun stuff!

initrd got all the files necessary including the devices in /dev (as sda1,sda2,sda3).

In the linuxrc script, I added some sleep commands to give the kernel some time to find the usbhd and to mount it, before the linuxrc script goes too many some steps ahead (not very clean synchronizing, but simple).

Now I have a USB-Gentoo-HardDisc that I can stick to lots of IBM-PC able to boot from USB (including my company laptop with its strange behaving operating system). :lol:
Top
Kokkor_Hekkus
n00b
n00b
User avatar
Posts: 14
Joined: Tue Feb 03, 2004 7:41 am
Location: Lucerne (CH)

  • Quote

Post by Kokkor_Hekkus » Mon May 09, 2005 3:55 pm

lindegur wrote:including my company laptop with its strange behaving operating system :lol:
Well, I wonder if that "other thing" deserves the name "operating system". 8) :lol: 8) :lol:

- kokor
Top
cmtaylor
n00b
n00b
User avatar
Posts: 36
Joined: Mon Aug 09, 2004 9:32 pm
Location: Houghton, MI
Contact:
Contact cmtaylor
Website

  • Quote

Post by cmtaylor » Mon May 09, 2005 3:59 pm

lindegur,

Sounds like a great thing, and if you're willing, I'd love to see a precis of what you did to make the whole thing work!

Congrats!
Top
pratty70
n00b
n00b
Posts: 24
Joined: Wed Apr 27, 2005 8:03 am
Location: Wales, UK

  • Quote

Post by pratty70 » Wed May 11, 2005 3:00 pm

Yes, I wouldn't mind (if you have the time - just posting some notes on the steps you took and the pitfalls)

Thanks
Top
lindegur
Apprentice
Apprentice
User avatar
Posts: 293
Joined: Sat Aug 14, 2004 10:20 pm
Location: Swiss mountains
Contact:
Contact lindegur
Website

  • Quote

Post by lindegur » Wed May 11, 2005 10:25 pm

Major update to this post Jun 5. 2005.

In meantime I'm satisfyed with my installation: I installed Xorg, KDE, dri, Openoffice, NTFS watch out about not writing to it! Everything works well and I have no reason to modify it.

I do currently some experiments with a memory stick. My main motivation is to learn.

Ok. here what I have so far:
The following things are necessary:
1.) in the Grub.conf I have:

title=Gentoo Linux 2.6.11-r9-21may05 linuxrc rw
root (hd0,0)
kernel /kernel-2.6.11-gentoo-r9-21may05 root=/dev/ram0 init=/linuxrc rw
initrd /boot/initrd.gz


2.) I created /root/USBHD with the following contents:

bash-2.05b# ls -R
.:
bin dev etc lib linuxrc new-root proc sbin

./bin:
bash chroot echo mount sh sleep

./dev:

./etc:
fstab

./lib:
ld-2.3.4.so libblkid.so.1 libc-2.3.4.so libdl-2.3.4.so libm-2.3.4.so libpthread-2.3.4.so librt-2.3.4.so libuuid.so.1
ld-linux.so.2 libblkid.so.1.0 libc.so.6 libdl.so.2 libm.so.6 libpthread.so.0 librt.so.1 libuuid.so.1.2

./new-root:

./proc:

./sbin:
pivot_root


3.) in root I have the following script that converts the directory above into a initrd.gz

#!/bin/sh
echo "Creation of initrd to boot from USB HD"
#Urs Lindegger 3.6.5"
#dd creates a initrd file in current directory of bs size filled with zeros
dd if=/dev/zero of=initrd bs=3000k count=1
#format it as file system
mke2fs -F -m0 initrd
#mount file as device
mount -t ext2 -o loop initrd /mnt/initrd
echo "sleep for 5 seconds to give mount time to mount"
sleep 5
mkdir /mnt/initrd/dev
# cd /dev
# ls -t shows major and minor numbers c or b
mknod /mnt/initrd/dev/console c 5 1
mknod /mnt/initrd/dev/sda1 b 8 1
mknod /mnt/initrd/dev/sda2 b 8 2
mknod /mnt/initrd/dev/sda3 b 8 3
cp -R /root/USBHD/* /mnt/initrd
#test if everything is there to run later linuxrc
#if not copy all missing so file ldd /mnt/initrd/linuxrc shows them
#echo "Test if linuxrc starts dont be afraid about error messages, since ramdisk does not exist during test press CR"
#read
#chroot /mnt/initrd /linuxrc
#echo "control contents of /mnt/initrd leave it and press key CR and wait until zip has finished"
#read
#sleep 5
umount /mnt/initrd
sleep 5
gzip -9 initrd
echo "initrd.gz can now be found."


4.) the linuxrc script in /root/USBHD is:

#!/bin/bash
echo "Linuxrc script"

#Give the kernel some time to find the USBHD
sleep 5

echo "Linuxrc: Mount USB drive"
mount -t ext3 -o ro /dev/sda3 /new-root
#Give the kernel some time to mount the USBHD
sleep 5
echo "Linuxrc: Go to new root"
cd /new-root
#actual root will be moved into the old-root directory, whereas new-root takes over the real root.
# /initrd directory in the new root file system must exist

echo "Linuxrc: Exchange old root with new root (pivot root)"
#pivot moves the actual root into /initrd and shifts up new-root into real root.
/sbin/pivot_root . initrd

echo "Linuxrc: Change to new root and start /sbin/init"
#possibility to call bin/sh or /sbin/init
# dev or /dev (absolute or relative path) this is the question
exec chroot . /sbin/init <dev/console >dev/console 2>&1
#exec chroot . /bin/sh <dev/console >dev/console 2>&1

#The following lines would unmount the initial RAM disk and free memory.
#Those lines can not be run from this file, since this file resides in the initial RAM disk
#Eiter run a script from the USB HD to clean it up or keep the initial RAM disk alive and do nothing.
#Due to the reasons above the following lines are just a hint how to unmount the inital RAM disk.
#sleep 5
#
#echo"Linuxrc: Unmount RAM disk"
#umount /initrd
#echo "Linuxrc: Free RAM reserved by RAM disk"
#/sbin/blockdev --flushbufs /dev/ram0
#echo "Linuxrc: End of linuxrc script"


5.) and finally a dummy /etc/fstab with the following contents:

# /etc/fstab: static file system information.
# it is just a dummy file to not cause a kernel warning


Create on your Usb Harddisk a directory /initrd, when every thing went well you will see inside the initial ramdisk.
Last edited by lindegur on Sat Aug 05, 2006 6:27 pm, edited 3 times in total.
Top
pratty70
n00b
n00b
Posts: 24
Joined: Wed Apr 27, 2005 8:03 am
Location: Wales, UK

  • Quote

Post by pratty70 » Thu May 12, 2005 7:44 am

Many many thanks, very useful information - I'm looking forward to the howto
Top
lindegur
Apprentice
Apprentice
User avatar
Posts: 293
Joined: Sat Aug 14, 2004 10:20 pm
Location: Swiss mountains
Contact:
Contact lindegur
Website

  • Quote

Post by lindegur » Sun May 22, 2005 1:46 pm

I found my web page and have put my guide on it. The sample code you find above need still some improvements, but there is not big priority on my side since it runs perfectly. I also applied the same methode to a USB memory stick and will probably make my own Linux USB memory stick, my motivation behind it is learning the internals of Linux.


http://mypage.bluewin.ch/Urs_Lindegger/ ... romUsb.pdf
:lol:
Top
Ma3oxuct
Guru
Guru
User avatar
Posts: 523
Joined: Fri Apr 18, 2003 4:16 am
Contact:
Contact Ma3oxuct
Website

  • Quote

Post by Ma3oxuct » Tue May 31, 2005 9:25 pm

Amazing guide man :D...I got gentoo to boot off of my usb stick (Can't to much else since is only 128 MB :()..
Thanks.
Top
lindegur
Apprentice
Apprentice
User avatar
Posts: 293
Joined: Sat Aug 14, 2004 10:20 pm
Location: Swiss mountains
Contact:
Contact lindegur
Website

  • Quote

Post by lindegur » Sun Jun 05, 2005 9:03 pm

Many thanks for the positive feedback, it keeps me motivated to do some documentation and share my experience.
Note: I did a major update on one of my posts above.
Herewith I consider this project closed.:D
Top
lord_hypno
n00b
n00b
User avatar
Posts: 35
Joined: Fri May 07, 2004 4:43 pm

  • Quote

Post by lord_hypno » Tue Nov 15, 2005 5:56 pm

I found very usefull your guide, thaks for the good hints.
Just a coupple of things:
in your guide you write to use two sample files:
initrd.gz and mkinitrd.
I found the first at http://mypage.bluewin.ch/Urs_Lindegger/Linux/initrd.gz, but I can not find the second.
Hypno
Top
lindegur
Apprentice
Apprentice
User avatar
Posts: 293
Joined: Sat Aug 14, 2004 10:20 pm
Location: Swiss mountains
Contact:
Contact lindegur
Website

  • Quote

Post by lindegur » Tue Nov 15, 2005 8:56 pm

Hi Hypno,

On my linux page you find the following text:
Sample Code: initrd mkinitrd
Click to initrd you get the initrd sample code
Click to mkinitrd you get the mkinitrd sample code (in zipped format)
Or the following link shoud bring you right to it:

http://mypage.bluewin.ch/Urs_Lindegger/ ... trd.tar.gz
Top
lord_hypno
n00b
n00b
User avatar
Posts: 35
Joined: Fri May 07, 2004 4:43 pm

  • Quote

Post by lord_hypno » Tue Nov 15, 2005 9:14 pm

Thanks,
I dont kwon why, but the link in the pdf dont work on my computer.
Hypno
Top
kevintshaver
n00b
n00b
Posts: 49
Joined: Tue Feb 14, 2006 3:06 am

  • Quote

Post by kevintshaver » Wed Apr 05, 2006 6:34 pm

I've used this method and I'm able to get the linuxrc script to start executing but it fails at the following line:

Code: Select all

mount -t ext3 -o ro /dev/sda3 /new-root
The error: /dev/sda3 is not a vaild block device

Any ideas on what causes this? Thanks.
Top
kevintshaver
n00b
n00b
Posts: 49
Joined: Tue Feb 14, 2006 3:06 am

  • Quote

Post by kevintshaver » Tue Apr 11, 2006 6:31 pm

I figured this out. The following option must be set in 2.6.9 and later kernels.

CONFIG_BLK_DEV_UB=n

This will allow you /dev/sdx device files to be created.
Top
aych
Guru
Guru
User avatar
Posts: 304
Joined: Thu May 20, 2004 11:14 pm

  • Quote

Post by aych » Tue Apr 18, 2006 4:23 am

how do you set it. and where do u set it
Top
aych
Guru
Guru
User avatar
Posts: 304
Joined: Thu May 20, 2004 11:14 pm

  • Quote

Post by aych » Tue Apr 18, 2006 4:29 am

lindegur. thanks for ur tutorials. just 1. question. i keep halting on dev/console. anyone has any ideas how to fix it? the file is there. i checked. it just doesn't seem to like it
Top
lindegur
Apprentice
Apprentice
User avatar
Posts: 293
Joined: Sat Aug 14, 2004 10:20 pm
Location: Swiss mountains
Contact:
Contact lindegur
Website

  • Quote

Post by lindegur » Sat Aug 05, 2006 7:34 pm

Since more than a year I'm using my gentoo usb hd and I did all updates as usual (kernel 2.6.17, Xorg 7, Webcam, and so on).
Me and my gentoo usb installation collected many frequent flyer miles that year. :lol:

I forgot a lot, since it runs without problems. Therefore I wrote my guide also for myself to remember what I did. 8O

So what did you do, when you got stuck with /dev/console, what do you see on the screen :?:
Last edited by lindegur on Thu Jun 07, 2007 10:12 am, edited 1 time in total.
Top
lindegur
Apprentice
Apprentice
User avatar
Posts: 293
Joined: Sat Aug 14, 2004 10:20 pm
Location: Swiss mountains
Contact:
Contact lindegur
Website

  • Quote

Post by lindegur » Thu Jun 07, 2007 10:11 am

There is an easier way to do the same see:
http://forums.gentoo.org/viewtopic-t-55 ... ight-.html
If you have a problem Linux offers more than one solution :wink:
Top
Post Reply

22 posts • Page 1 of 1

Return to “Installing Gentoo”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy