Booting a gentoo install-minimal iso from USB stick

Hi!
I've spending so mutch time to install a gentoo for the first time. The hardest thing was to make gentoo boot from USB stick, so I write you down what I did.

I needed to boot from USB because my new Core2 Duo mainboard (Asus) has quite fresh chipset which is not supported well even in the latest kernels. Nowadays we have the 2.6.18 kernel and in the days this blog was written only a few distributions boots with this kernel version.

I also write you a kernel compatibility matrix, which kernel version supports which part of my hardware:
. . . . JMicron JBM363 . Intel IHC8 . Realtek
. . . . . SATA/PATA . . . SATA . . . . LAN RTL 8111B
2.6.17* only SATA . . . not . . . . . not
2.6.18 . only SATA . . . yes . . . . . not

So let's get back to the boot recipe. I was using windowsXP environment, but I believe it is better to use linux. (But, if I had a linux I should not need to hack the boot.)

1. download the latest (install-amd64-minimal-2006.1.iso) gentoo install.

2. unpack the contents of it (i've used daemon tools)
The contents of the iso is:
./Getting_Online.txt
./image.squashfs
./isolinux
./isolinux/boot.cat
./isolinux/boot.msg
./isolinux/F2.msg
./isolinux/F3.msg
./isolinux/F4.msg
./isolinux/F5.msg
./isolinux/F6.msg
./isolinux/F7.msg
./isolinux/gentoo
./isolinux/gentoo.igz
./isolinux/isolinux.bin
./isolinux/isolinux.cfg
./isolinux/kernels.msg
./isolinux/memtest86
./livecd
./README.txt

3. your will need the following file structure to follow my steps. Just copy the files
./gentoo
./gentoo2.igz *
./image.squashfs
./isolinux/ **
./ldlinux.sys ***
./livecd
./syslinux.cfg ***

* - Will described later
** - I'm not sure you need anything else from this folder
*** - these files are used by syslinux boot loader

4. insert and format your usb stick to fat16

5. Get syslinux. You can use it from linux and win as well.
- I'm not going to tell the usage of syslinux here. try to find some manual!
- You can use any other boot loader, but I don't know whether you can find better one for this job.

6. Install syslinux to the stick

7. Edit the syslinux.cfg to look like this:
default debian
timeout 150
prompt 1

label gentoo
kernel gentoo
append root=/dev/ram0 init=/linuxrc dokeymap looptype=squashfs loop=/image.squashfs cdroot=/dev/sdb1 initrd=gentoo2.igz ramdisk_size=20000 splash=silent,theme:livecd-2006.1 CONSOLE=/dev/tty1 quiet

- I was figured out that my USB stick will be mapped to /dev/sdb1, yours may be different. You just have to figure out, or guess, or try. But gentoo should search for other devices.
- Note the initrd, while we are not going to use the original one
- I used the original boot settings of the gentoo install, but the fancy vga settings. (I have a really bad display)

8. We will hack the initrd. This should be done, because gentoo is using some really stupid initrd format generated by stipts, so you can not restore the original initrd file system. And there is a very annoying script code in it.

8a. gUnzip the original initrd (initrd.igz)

8b. get a binary (hex) editor. You can use bvi or some other editor, maybe a normal editor can also do the job, if it is not willing to reformat your "text".

8c. Find this line:
00027F50: 68 65 6E 0A 09 09 09 09 │ 67 6F 6F 64 5F 6D 73 67 hen◙○○○○good_msg
00027F60: 20 22 41 74 74 65 6D 70 │ 74 69 6E 67 20 74 6F 20 "Attempting to
00027F70: 6D 6F 75 6E 74 20 43 44 │ 3A 2D 20 24 7B 78 7D 22 mount CD:- ${x}"
00027F80: 0A 09 09 09 09 6D 6F 75 │ 6E 74 20 2D 72 20 2D 74 ◙○○○○mount -r -t
00027F90: 20 69 73 6F 39 36 36 30 │ 20 24 7B 78 7D 20 24 7B iso9660 ${x} ${
00027FA0: 4E 45 57 5F 52 4F 4F 54 │ 7D 2F 6D 6E 74 2F 63 64 NEW_ROOT}/mnt/cd
00027FB0: 72 6F 6D 20 3E 20 2F 64 │ 65 76 2F 6E 75 6C 6C 20 rom > /dev/null

8d. Replace the text "-t iso9660" with spaces.
- So gentoo will find the boot files even if you are not booting from iso formatted device.
- With bvi you will find text with pressing '/', start replace with 'R', stop replace with 'Esc', and save modifications with ':wq'

8e. gzip the new initrd

9. copy all files to the USB-stick

10. boot and install gentoo. Follow the installation steps, as you were booted from CD.

You can find some notes and useful tips here: http://gentoo-wiki.com/HOWTO_Gentoo_LiveCD_and_LiveUSB

Balázs Kelemen
http://www.sdkmi.hu/dev/

Hozzászólások

Okay.
Don't tell me that I don't give a try. Here is my modification to the blog above.

The following cards are supported by linux, or at least there is a driver called "official realtek gigabit driver". (Actualy I could not find any original Realtek download for this driver.)
The chips are: RTL8169, RTL8169S/8110S, RTL8169S/8110S, RTL8169SB/8110SB, RTL8169SC/8110SC, RTL8168B/8111B, RTL8101E
You can download the driver from some mirror sites. The name is: r1000_v1.04.tgz

For kernel 2.6.18 you have to patch both the kernel and the driver.

I copyed the src/r1000* to the drivers/net/ folder of my kernel, and applied the patch you can see below.
Applying the patch means: patch -p0 < r1000_kb.diff, in the kernel source root.
Now you can config (or menuconfig) to compile the gigabit card driver.
Note#1: I do not say it will work for you
Note#2: The tgz contains dos format files, so the patch will fail. First you have to convert it to unix format. 'nano -w drivers/net/r1000_n.c' Ctrl-O Alt-D whould do it.
Note#3: I could not test the functionality of the card or the driver. So it may fail. I was able to use it at 10Mbps, but thats all.
Note#4: The original patch is by paolo. See http://www.mail-archive.com/netdev@vger.kernel.org/msg21749.html

Regard,
Balázs Kelemen
http://www.sdkmi.hu/dev/

The patch:

--- drivers/net/Kconfig 2006-09-06 22:26:23.000000000 +0200
+++ drivers/net/Kconfig 2006-09-06 22:24:33.000000000 +0200
@@ -2002,6 +2002,63 @@

If in doubt, say Y.

+config R1000
+ tristate "Realtek support for 8169S/SB/SC 8168B 8101E"
+ depends on PCI
+ ---help---
+ Say Y here if you have a Realtek LAN chip of the family below.
+
+ E.g. the 810x may be identified as 'Unknow device 8136' as
+ of 2.6.18-rc6, with PCI_ID=10ec:8136, on recent (as of Aug 2006)
+ Toshiba laptops.
+
+ Also, this r1000 may be a better (it's newer at least) choice
+ for RTL8169 as well than r8169 above.
+
+ To compile this driver as a module, choose M here: the module
+ will be called r1000. This is recommended.
+
+ == Most relevant excerpt from original README ==
+ Chips supported:
+ 1. RTL8169S/SB/SC (Gigabit Ethernet with PCI interface)
+ 2. RTL8168B (Gigabit Ethernet with PCI-Express interface)
+ 3. RTL8101E (Fast Ethernet with PCI-Express interface)
+
+ Advanced feature:
+
+ - Supports Jumbo Frame
+ - Hardware Tx/Rx flow control
+
+ Force the link status when insert the driver.
+ If the user is in the path ~/r1000, the link status can be
+ forced to one of the 5 modes as following command.
+
+ #insmod ./src/r1000.ko speed=SPEED_MODE duplex=DUPLEX_MODE
+ autoneg=NWAY_OPTION
+
+ where
+ SPEED_MODE = 1000 for 1000Mbps
+ = 100 for 100Mbps
+ = 10 for 10Mbps
+ DUPLEX_MODE = 0 for half-duplex
+ = 1 for full-duplex
+ NWAY_OPTION = 0 for auto-negotiation off
+ = 1 for auto-negotiation on
+
+ Force the link status by using ethtool:
+
+ #ethtool -s eth? speed SPEED_MODE duplex DUPLEX_MODE
+ autoneg NWAY_OPTION
+
+ where
+ SPEED_MODE = 1000 for 1000Mbps
+ = 100 for 100Mbps
+ = 10 for 10Mbps
+ DUPLEX_MODE = half for half-duplex
+ = full for full-duplex
+ NWAY_OPTION = off for auto-negotiation off
+ = on for auto-negotiation on
+
config SIS190
tristate "SiS190/SiS191 gigabit ethernet support"
depends on PCI
--- drivers/net/Makefile 2006-09-06 22:28:38.000000000
+0200
+++ drivers/net/Makefile 2006-09-06 22:29:18.000000000
+0200
@@ -145,6 +145,10 @@
obj-$(CONFIG_3C515) += 3c515.o
obj-$(CONFIG_EEXPRESS) += eexpress.o
obj-$(CONFIG_EEXPRESS_PRO) += eepro.o
+obj-$(CONFIG_R1000) += r1000.o
+
+r1000-objs := r1000_n.o r1000_ioctl.o
+
obj-$(CONFIG_8139CP) += 8139cp.o
obj-$(CONFIG_8139TOO) += 8139too.o
obj-$(CONFIG_ZNET) += znet.o

--- ../a/drivers/net/r1000_n.c 2006-10-10 02:44:42.192074500 +0200
+++ drivers/net/r1000_n.c 2006-10-10 01:18:00.000000000 +0200
@@ -48,9 +48,12 @@
MODULE_DEVICE_TABLE (pci, r1000_pci_tbl);
MODULE_AUTHOR ("Realtek");
MODULE_DESCRIPTION ("Linux device driver for Realtek Ethernet Controllers");
-MODULE_PARM (speed, "1-" __MODULE_STRING(MAX_UNITS) "i");
-MODULE_PARM (duplex, "1-" __MODULE_STRING(MAX_UNITS) "i");
-MODULE_PARM (autoneg, "1-" __MODULE_STRING(MAX_UNITS) "i");
+MODULE_PARM_DESC (speed, "Speed mode: [10,100,1000] Mbps");
+module_param_array (speed, int, NULL, 0444);
+MODULE_PARM_DESC (duplex, "Duplex mode: 0=half, 1=full");
+module_param_array (duplex, int, NULL, 0444);
+MODULE_PARM_DESC (autoneg, "Nway option: [0,1]=auto-negotiation [off,on]");
+module_param_array (autoneg, int, NULL, 0444);
MODULE_LICENSE("GPL");

--- ../a/include/linux/pci_ids.h 2006-10-10 02:44:42.196074750 +0200
+++ include/linux/pci_ids.h 2006-10-10 01:19:24.000000000 +0200
@@ -1227,7 +1227,11 @@
#define PCI_DEVICE_ID_INTERG_5050 0x5050

#define PCI_VENDOR_ID_REALTEK 0x10ec
-#define PCI_DEVICE_ID_REALTEK_8139 0x8139
+#define PCI_DEVICE_ID_REALTEK_8139 0x8139
+#define PCI_DEVICE_ID_REALTEK_8167 0x8167
+#define PCI_DEVICE_ID_REALTEK_8168 0x8168
+#define PCI_DEVICE_ID_REALTEK_8169 0x8169
+

#define PCI_VENDOR_ID_XILINX 0x10ee
#define PCI_DEVICE_ID_RME_DIGI96 0x3fc0