1 |
Hi, |
2 |
|
3 |
I build by gentoo kernel without genkernel, and I want to create the |
4 |
initramfs by hand. Following is the steps I did: |
5 |
|
6 |
Build the kernel with initramfs support; |
7 |
mkdir -p /usr/src/initramfs{dev,bin,sbin,etc,root,proc,sys} |
8 |
cp -aL /bin/bb /usr/src/initramfs/bin # copy the busybox |
9 |
cp -a /sbin/lvm /usr/src/initramfs/sbin # i created my root on lvm |
10 |
cp -a /dev/{hda,hda1,hda2,ram0} /usr/src/initramfs/dev # i am not sure |
11 |
if i am correct here |
12 |
vim /usr/src/initramfs/init # create the init script, it based on |
13 |
http://en.gentoo-wiki.com/wiki/Initramfs |
14 |
#!/bin/busybox sh |
15 |
|
16 |
# Mount the /proc and /sys filesystems. |
17 |
mount -t proc none /proc |
18 |
mount -t sysfs none /sys |
19 |
|
20 |
# Do your stuff here. |
21 |
echo "This script mounts rootfs and boots it up, nothing more!" |
22 |
|
23 |
# active lvm |
24 |
lvm vgscan |
25 |
lvm vgchange -ay |
26 |
|
27 |
# Mount the root filesystem. |
28 |
mount -o ro /dev/vgsys/root /mnt/root |
29 |
|
30 |
# Clean up. |
31 |
umount /proc |
32 |
umount /sys |
33 |
|
34 |
# Boot the real thing. |
35 |
exec switch_root /mnt/root /sbin/init |
36 |
|
37 |
|
38 |
##################################################### |
39 |
chmod +x /usr/src/initramfs/init |
40 |
|
41 |
then I use find /usr/src/initramfs/init | cipo -oHnewc | gzip -9 > |
42 |
/boot/initramfs.gz |
43 |
|
44 |
But when I try to boot my system, I got kernel panic, and it says it |
45 |
cannot find the init script. If I remove the 'initrd' instruction from |
46 |
the grub.conf file, the error message does different, which means the |
47 |
system WAS trying to process the initramfs. But I do not know why it |
48 |
cannot find the init script. |
49 |
|
50 |
I modified the initramfs that the genkernel generated before, and the |
51 |
system works fine after that. But I never created a initramfs from |
52 |
scratch before |
53 |
|
54 |
-- |
55 |
Best Regards, |
56 |
David Shen |
57 |
|
58 |
http://twitter.com/davidshen84 |