* [gentoo-user] Self created initramfs cannot work
@ 2009-06-27 1:32 David Shen
2009-06-27 6:33 ` Dirk Heinrichs
0 siblings, 1 reply; 8+ messages in thread
From: David Shen @ 2009-06-27 1:32 UTC (permalink / raw
To: gentoo-china, gentoo-amd64, gentoo-user
Hi,
I build by gentoo kernel without genkernel, and I want to create the
initramfs by hand. Following is the steps I did:
Build the kernel with initramfs support;
mkdir -p /usr/src/initramfs{dev,bin,sbin,etc,root,proc,sys}
cp -aL /bin/bb /usr/src/initramfs/bin # copy the busybox
cp -a /sbin/lvm /usr/src/initramfs/sbin # i created my root on lvm
cp -a /dev/{hda,hda1,hda2,ram0} /usr/src/initramfs/dev # i am not sure
if i am correct here
vim /usr/src/initramfs/init # create the init script, it based on
http://en.gentoo-wiki.com/wiki/Initramfs
#!/bin/busybox sh
# Mount the /proc and /sys filesystems.
mount -t proc none /proc
mount -t sysfs none /sys
# Do your stuff here.
echo "This script mounts rootfs and boots it up, nothing more!"
# active lvm
lvm vgscan
lvm vgchange -ay
# Mount the root filesystem.
mount -o ro /dev/vgsys/root /mnt/root
# Clean up.
umount /proc
umount /sys
# Boot the real thing.
exec switch_root /mnt/root /sbin/init
#####################################################
chmod +x /usr/src/initramfs/init
then I use find /usr/src/initramfs/init | cipo -oHnewc | gzip -9 >
/boot/initramfs.gz
But when I try to boot my system, I got kernel panic, and it says it
cannot find the init script. If I remove the 'initrd' instruction from
the grub.conf file, the error message does different, which means the
system WAS trying to process the initramfs. But I do not know why it
cannot find the init script.
I modified the initramfs that the genkernel generated before, and the
system works fine after that. But I never created a initramfs from
scratch before
--
Best Regards,
David Shen
http://twitter.com/davidshen84
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-user] Self created initramfs cannot work
2009-06-27 1:32 [gentoo-user] Self created initramfs cannot work David Shen
@ 2009-06-27 6:33 ` Dirk Heinrichs
2009-06-27 8:25 ` David Shen
0 siblings, 1 reply; 8+ messages in thread
From: Dirk Heinrichs @ 2009-06-27 6:33 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 457 bytes --]
Am Samstag 27 Juni 2009 03:32:50 schrieb David Shen:
> I build by gentoo kernel without genkernel, and I want to create the
> initramfs by hand. Following is the steps I did:
I also did this for some years, I could send you my setup script if you want.
Nowadays I've switched to putting the stuff I had in an initramfs into /boot,
which is always a separate partition on my systems. You can get that script
too if you want.
Bye...
Dirk
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 190 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-user] Self created initramfs cannot work
2009-06-27 6:33 ` Dirk Heinrichs
@ 2009-06-27 8:25 ` David Shen
2009-06-27 11:49 ` Dirk Heinrichs
0 siblings, 1 reply; 8+ messages in thread
From: David Shen @ 2009-06-27 8:25 UTC (permalink / raw
To: gentoo-user
yep, i'd like to learn from your script.
BTW, I also put my initramfs into a separate partition /boot.
On Sat, Jun 27, 2009 at 2:33 PM, Dirk Heinrichs<dirk.heinrichs@online.de> wrote:
> Am Samstag 27 Juni 2009 03:32:50 schrieb David Shen:
>
>> I build by gentoo kernel without genkernel, and I want to create the
>> initramfs by hand. Following is the steps I did:
>
> I also did this for some years, I could send you my setup script if you want.
> Nowadays I've switched to putting the stuff I had in an initramfs into /boot,
> which is always a separate partition on my systems. You can get that script
> too if you want.
>
> Bye...
>
> Dirk
>
--
Best Regards,
David Shen
http://twitter.com/davidshen84
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-user] Self created initramfs cannot work
2009-06-27 8:25 ` David Shen
@ 2009-06-27 11:49 ` Dirk Heinrichs
2009-06-27 12:55 ` David Shen
0 siblings, 1 reply; 8+ messages in thread
From: Dirk Heinrichs @ 2009-06-27 11:49 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1.1: Type: text/plain, Size: 1762 bytes --]
Am Samstag 27 Juni 2009 10:25:11 schrieb David Shen:
> yep, i'd like to learn from your script.
OK, here you are.
> BTW, I also put my initramfs into a separate partition /boot.
Seems you misunderstood. I don't use an initramfs anymore, /boot _is_ my
initramfs replacement. Whatever you put into an initramfs can as well be put
into /boot.
I've attached both set of scripts, just choose the one you like more.
mkinitfs_script.tar.bz2 contains the script to put stuff to /boot, while
mkinitramfs_script.tar.bz2 contains the script to create an initramfs for use
inside the kernel (kernel+initramfs will be one file).
In both cases, you should adapt the /etc/mkinit*fs/config file to your needs,
just adapt the list of executables you need/want in your init*fs and run the
desired script.
The mkinitramfs.sh script will put everything into /usr/src/initramfs. You
should configure this in your kernel config so that the kernel build system can
create the image for you.
The other one will put everything into /boot.
Out of the box, the resulting fs will be suited for accessing / from a logical
volume which may optionally be encrypted using LUKS. The init script will find
out at boot time wether the LV is encrypted and will run cryptsetup to prompt
for a password.
Finally, you need to adapt your bootloader, depending on which approach you
choose:
initramfs: realroot=/dev/vg/root (* NO root=, because that's the initramfs).
initfs: You'll need both root=/dev/sda1, which should be your /boot, realroot=
as above and rw (this is important).
BTW: Newer kernels also have a configuration option for this: CONFIG_CMDLINE.
In case of further questions, just send a mail.
Bye...
Dirk
[-- Attachment #1.2: initfs_script.tar.bz2 --]
[-- Type: application/x-bzip-compressed-tar, Size: 2447 bytes --]
[-- Attachment #1.3: initramfs_script.tar.bz2 --]
[-- Type: application/x-bzip-compressed-tar, Size: 2474 bytes --]
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 190 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-user] Self created initramfs cannot work
2009-06-27 11:49 ` Dirk Heinrichs
@ 2009-06-27 12:55 ` David Shen
2009-06-29 12:08 ` David Shen
0 siblings, 1 reply; 8+ messages in thread
From: David Shen @ 2009-06-27 12:55 UTC (permalink / raw
To: gentoo-user
thanks a lot
On Sat, Jun 27, 2009 at 7:49 PM, Dirk Heinrichs<dirk.heinrichs@online.de> wrote:
> Am Samstag 27 Juni 2009 10:25:11 schrieb David Shen:
>
>> yep, i'd like to learn from your script.
>
> OK, here you are.
>
>> BTW, I also put my initramfs into a separate partition /boot.
>
> Seems you misunderstood. I don't use an initramfs anymore, /boot _is_ my
> initramfs replacement. Whatever you put into an initramfs can as well be put
> into /boot.
>
> I've attached both set of scripts, just choose the one you like more.
>
> mkinitfs_script.tar.bz2 contains the script to put stuff to /boot, while
> mkinitramfs_script.tar.bz2 contains the script to create an initramfs for use
> inside the kernel (kernel+initramfs will be one file).
>
> In both cases, you should adapt the /etc/mkinit*fs/config file to your needs,
> just adapt the list of executables you need/want in your init*fs and run the
> desired script.
>
> The mkinitramfs.sh script will put everything into /usr/src/initramfs. You
> should configure this in your kernel config so that the kernel build system can
> create the image for you.
>
> The other one will put everything into /boot.
>
> Out of the box, the resulting fs will be suited for accessing / from a logical
> volume which may optionally be encrypted using LUKS. The init script will find
> out at boot time wether the LV is encrypted and will run cryptsetup to prompt
> for a password.
>
> Finally, you need to adapt your bootloader, depending on which approach you
> choose:
>
> initramfs: realroot=/dev/vg/root (* NO root=, because that's the initramfs).
>
> initfs: You'll need both root=/dev/sda1, which should be your /boot, realroot=
> as above and rw (this is important).
>
> BTW: Newer kernels also have a configuration option for this: CONFIG_CMDLINE.
>
> In case of further questions, just send a mail.
>
> Bye...
>
> Dirk
>
--
Best Regards,
David Shen
http://twitter.com/davidshen84
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-user] Self created initramfs cannot work
2009-06-27 12:55 ` David Shen
@ 2009-06-29 12:08 ` David Shen
2009-06-29 16:23 ` Dirk Heinrichs
0 siblings, 1 reply; 8+ messages in thread
From: David Shen @ 2009-06-29 12:08 UTC (permalink / raw
To: gentoo-user
my /init script is running now, but I got '/bin/sh: can't access tty;
job control turned off' error. I google a lot, and I think it would
relate with my HD. When this error occurs, I got a simple shell. I
tried 'lvm vgscan' in that shell, and it cannot find my lvm. I copied
my block devices with:
cp -a /dev/hda /usr/src/initramfs/dev
cp -a /dev/hda1 /usr/src/initramfs/dev
cp -a /dev/hda2 /usr/src/initramfs/dev
what I missed?
On Sat, Jun 27, 2009 at 8:55 PM, David Shen<davidshen84@googlemail.com> wrote:
> thanks a lot
>
>
> On Sat, Jun 27, 2009 at 7:49 PM, Dirk Heinrichs<dirk.heinrichs@online.de> wrote:
>> Am Samstag 27 Juni 2009 10:25:11 schrieb David Shen:
>>
>>> yep, i'd like to learn from your script.
>>
>> OK, here you are.
>>
>>> BTW, I also put my initramfs into a separate partition /boot.
>>
>> Seems you misunderstood. I don't use an initramfs anymore, /boot _is_ my
>> initramfs replacement. Whatever you put into an initramfs can as well be put
>> into /boot.
>>
>> I've attached both set of scripts, just choose the one you like more.
>>
>> mkinitfs_script.tar.bz2 contains the script to put stuff to /boot, while
>> mkinitramfs_script.tar.bz2 contains the script to create an initramfs for use
>> inside the kernel (kernel+initramfs will be one file).
>>
>> In both cases, you should adapt the /etc/mkinit*fs/config file to your needs,
>> just adapt the list of executables you need/want in your init*fs and run the
>> desired script.
>>
>> The mkinitramfs.sh script will put everything into /usr/src/initramfs. You
>> should configure this in your kernel config so that the kernel build system can
>> create the image for you.
>>
>> The other one will put everything into /boot.
>>
>> Out of the box, the resulting fs will be suited for accessing / from a logical
>> volume which may optionally be encrypted using LUKS. The init script will find
>> out at boot time wether the LV is encrypted and will run cryptsetup to prompt
>> for a password.
>>
>> Finally, you need to adapt your bootloader, depending on which approach you
>> choose:
>>
>> initramfs: realroot=/dev/vg/root (* NO root=, because that's the initramfs).
>>
>> initfs: You'll need both root=/dev/sda1, which should be your /boot, realroot=
>> as above and rw (this is important).
>>
>> BTW: Newer kernels also have a configuration option for this: CONFIG_CMDLINE.
>>
>> In case of further questions, just send a mail.
>>
>> Bye...
>>
>> Dirk
>>
>
>
>
> --
> Best Regards,
> David Shen
>
> http://twitter.com/davidshen84
>
--
Best Regards,
David Shen
http://twitter.com/davidshen84
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-user] Self created initramfs cannot work
2009-06-29 12:08 ` David Shen
@ 2009-06-29 16:23 ` Dirk Heinrichs
2009-06-30 1:22 ` David Shen
0 siblings, 1 reply; 8+ messages in thread
From: Dirk Heinrichs @ 2009-06-29 16:23 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 822 bytes --]
Am Montag 29 Juni 2009 14:08:54 schrieb David Shen:
> my /init script is running now, but I got '/bin/sh: can't access tty;
> job control turned off' error. I google a lot, and I think it would
> relate with my HD. When this error occurs, I got a simple shell. I
> tried 'lvm vgscan' in that shell, and it cannot find my lvm.
Do you have dm_mod compiled into the kernel?
> I copied
> my block devices with:
> cp -a /dev/hda /usr/src/initramfs/dev
> cp -a /dev/hda1 /usr/src/initramfs/dev
> cp -a /dev/hda2 /usr/src/initramfs/dev
There's no need to do that, that's what udev is for.
Did you look into the scripts I've send? They should setup everything for you.
Initially, you only need console, null and initctl in /dev of your initrd,
udev takes care of everything else.
Bye...
Dirk
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 190 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-user] Self created initramfs cannot work
2009-06-29 16:23 ` Dirk Heinrichs
@ 2009-06-30 1:22 ` David Shen
0 siblings, 0 replies; 8+ messages in thread
From: David Shen @ 2009-06-30 1:22 UTC (permalink / raw
To: gentoo-user
yeah, I see you used udev. But I see the gentoo wiki, they do not use
udev, so I think I can work without udev, too.
I will check if I have dm_mod in my kernel.
Thanks.
On Tue, Jun 30, 2009 at 12:23 AM, Dirk
Heinrichs<dirk.heinrichs@online.de> wrote:
> Am Montag 29 Juni 2009 14:08:54 schrieb David Shen:
>
>> my /init script is running now, but I got '/bin/sh: can't access tty;
>> job control turned off' error. I google a lot, and I think it would
>> relate with my HD. When this error occurs, I got a simple shell. I
>> tried 'lvm vgscan' in that shell, and it cannot find my lvm.
>
> Do you have dm_mod compiled into the kernel?
>
>> I copied
>> my block devices with:
>> cp -a /dev/hda /usr/src/initramfs/dev
>> cp -a /dev/hda1 /usr/src/initramfs/dev
>> cp -a /dev/hda2 /usr/src/initramfs/dev
>
> There's no need to do that, that's what udev is for.
>
> Did you look into the scripts I've send? They should setup everything for you.
> Initially, you only need console, null and initctl in /dev of your initrd,
> udev takes care of everything else.
>
> Bye...
>
> Dirk
>
>
>
--
Best Regards,
David Shen
http://twitter.com/davidshen84
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-06-30 1:22 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-27 1:32 [gentoo-user] Self created initramfs cannot work David Shen
2009-06-27 6:33 ` Dirk Heinrichs
2009-06-27 8:25 ` David Shen
2009-06-27 11:49 ` Dirk Heinrichs
2009-06-27 12:55 ` David Shen
2009-06-29 12:08 ` David Shen
2009-06-29 16:23 ` Dirk Heinrichs
2009-06-30 1:22 ` David Shen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox