----- Original Message ----- From: "Drake Donahue" <[EMAIL PROTECTED]>
To: <gentoo-amd64@lists.gentoo.org>
Sent: Wednesday, April 30, 2008 2:03 PM
Subject: Re: [gentoo-amd64] boot Gentoo from USB key



----- Original Message ----- From: "Raffaele BELARDI" <[EMAIL PROTECTED]>
To: "gentoo-amd64" <gentoo-amd64@lists.gentoo.org>
Sent: Wednesday, April 30, 2008 2:43 AM
Subject: [gentoo-amd64] boot Gentoo from USB key


In the process of building an amd64 diskless box, I am trying to make a
bootable USB key with no success up to now.

The first problem I encountered was related to ext2/vfat. I initially
tried to format the key as ext2, but grub refuses to install on it. Even
though I copied the /boot/grub/* directory into the key, and I see it is
there, grub does not see it. The problem does not happen with vfat.

So I worked around that and created two partitions in the key, a small
vfat for the /boot and a 2Gb ext2 for the /. I copied the stage3 into
the / with no problem. In the /boot I put the kernel image which I am
already using on the same box, for now with discs still connected. All
the modules are compiled in.

When I boot from the key, grub enters the shell (although I did create
the grub.conf and menu.1st, so I don't understand why it doesn't show
the menu). I manually specify the kernel file location and root
parameter:

kernel /linux-2.6.24-gentoo-r4 root=/dev/sdg1
boot

The kernel starts to load, but panics because it is unable to find the
root partition. When it stops it shows the available partitions, these
include all the hard disk partitions but no USB key partition. In fact,
if I omit the 'root' parameter from the grub shell the boot works fine
but it uses the hard disk root partition instead of the USB one.

From the log on the screen the USB controller seems correctly detected,
so I don't understand why it is not finding the root. While writing this
one idea comes to my mind, maybe it is failing because I attach the key
to a SDC/MMC/USB card reader? This evening I'll try to plug it into a
different USB slot.

Any other ideas welcome.

raffaele

--
gentoo-amd64@lists.gentoo.org mailing list

Other ideas and SWAGS:

This link may be useful:
http://www.bootdisk.com/pendrive.htm

Perhaps the pen drive manufacturer did you favors and added some control software? I had a similar problem with fdisk results that I attributed to the helpful manufacturer putting some extra software on the drive to add features for the windows user (the bootable flag would have disappeared upon reboot, the pen drive would not appear in BIOS). I may have been right. I used the HP utilities referenced in the link to rewrite the recalcitrant pen drive into a psuedo floppy drive with linux on board (HP provides a linux based windows computer troubleshooting tool!).

Instead of HP utilities, maybe, quoting:
Solution:
<snip>When you boot into a command shell, as root, simply pick the drive you want to fill [with zeros], sdg presumed, and use the command:

Code:
dd if=/dev/zero of=/dev/sdg bs=1MWARNING! This will destroy ALL data on the hard (pen) drive, all boot sector info and all data on all partitions. It will not however render the disk useless, you simply have a clean disk that only needs to have partitions created and a new boot sector installed, which will happen when you install any OS including Linux or Windows. This is a good way to clean up any bad partitions, viruses, botched installs or data that you don't want to be seen (OK, it is theoretically possible to forensically retrieve data after using this method, but not likely and not doable by the average computer user) and it is simple to do with existing GNU/Linux!

After verifying that I could boot the pen
drive as though it were a huge floppy, I rebooted to my hard drive and used fdisk to delete existing partitions on the pen drive, created a bootable partition, wrote the new partition table, exited fdisk, and formatted it ext2. On reboot it showed as a bootable hard drive in BIOS. Encouraged, I rebooted to the hard drive. Mounted the pen drive and copied /boot from the hard drive to it. Create dummy directory on the pendrive:
mkdir  {pendrive path}/pendrive
Keeping the problem simple, the machine had one sata hard drive, one ide dvd, and the one pen drive. The major problems at this point were identifying which (hd?) to use in editing the grub.conf and in running grub itself.
umount {pendrive}
grub
root (hd0,1)
root (hd1,1)
find /pendrive
quit
As the pen drive first (0) partition was the only ext2 partition on the machine, only one of the two commands would expose an ext2 filesystem; in my case (hd1,1). Find should provide the same information. If the pen drive is the selected boot drive for my motherboard it will be (hd0) for bios and grub.
So the pen drive grub.conf edits to:
timeout 5
default 0
fallback 1
splashimage=(hd0,0)/boot/grub/splash.xpm.gz

title USB Flash boot
root (hd0,0)
kernel (hd0,0)/boot/bzImage root=/dev/sdb1

title  Gentoo Linux on hard drive, first partition (hd1,0)
root (hd1,0)
kernel (hd1,0)/boot/bzImage root=/dev/sda1

So far my hard drive always /dev/sda pendrive /dev/sdb. As a slob, I put everything on one partition so all catastrophes can be catastrophic.

Still need to install grub so proper stage 1 and 1.5 and dynamic links can be written:

grub
root (hd1,0) #should confirm unique ext2 file system in my case
setup (hd1)
quit

Proceeding in similar fashion should allow you to select the kernel on the pen drive from grub and watch it load to the point where it can't find the system because no system is on the pen drive.

Copying the system files may not quite work. Got some copy errors while doing the libraries. Playing with 512 mb pen drive so no room to copy /sys. Can verify that I completed kernel load and got into init.before lack of needed files started an endless reboot cycle with boot sbin bin etc libraries directories present.

.
--
gentoo-amd64@lists.gentoo.org mailing list


--
gentoo-amd64@lists.gentoo.org mailing list

Reply via email to