Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[S]how to extract kernel by genkernel --integrated-initramfs
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
FKK
n00b
n00b


Joined: 11 Jan 2014
Posts: 14
Location: Middle Land

PostPosted: Sat Jan 11, 2014 11:58 am    Post subject: [S]how to extract kernel by genkernel --integrated-initramfs Reply with quote

with --integrated-initramfs flag, genkernel tar kernel.image and initramfs together as one file,

what's the format of this file?

I need to check some init scripts inside.
how can i extract it out?

Normal kernel bzImage extract works:
Code:

# file kernel
kernel: Linux kernel x86 boot executable bzImage, version 3.10.25-gentoo (root@gentoo) #22 SMP Sat Jan 11 19:25:37 UTC 2, RO-rootFS, swap_dev 0xA, Normal VGA

# od -t x1 -A d kernel | grep "1f 8b 08"
# dd if=kernel bs=1 skip=16492 | zcat > vmlinux

# file vmlinux
vmlinux: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, BuildID[sha1]=dc....8c, stripped

# ls -l *
-rw-r--r-- 1 root root 10604576 Jan 11 19:49 kernel
-rw-r--r-- 1 root root 25118324 Jan 11 19:52 vmlinux
# size vmlinux
   text    data     bss     dec     hex filename
5225740 19362152        1572864 26160756        18f2e74 vmlinux

but where is the initramfs ?

Question 2:
how to modify init script inside initramfs(bzImage) by genkernel?
by genkernel's man page, there is a flag
Quote:
init=<...>
Override location of init script, default is "/sbin/init".

but in my system, this /sbin/init is a ELF bin, not shell script
is there a location i can put my init script for genkernel ?

by gen log, i found this copy step. but how that tmp dir made......
Quote:

=================================================================
* >> Appending auxilary cpio data...
* >> Copying keymaps
=================================================================
About to add these files from '/var/tmp/genkernel/3410.746.24855.14234/initramfs-aux-temp' to cpio archive:
drwxr-xr-x 5 root root 4096 Jan 11 20:08 .
drwxr-xr-x 2 root root 4096 Jan 11 20:08 ./etc
-rwxr-xr-x 1 root root 2118 Jan 11 20:08 ./etc/initrd.defaults
-rwxr-xr-x 1 root root 34384 Jan 11 20:08 ./etc/initrd.scripts
-rwxr-xr-x 1 root root 21453 Jan 11 20:08 ./init
drwxr-xr-x 3 root root 4096 Jan 11 20:08 ./lib
drwxr-xr-x 2 root root 4096 Jan 11 20:08 ./lib/keymaps
-rw-r--r-- 1 root root 2823 Jan 11 20:08 ./lib/keymaps/10.map


I want to change these 3 scripts:
./etc/initrd.defaults ./etc/initrd.scripts ./init
_________________
config config config
build build build
boot boot boot
crash crash crash


Last edited by FKK on Tue Jan 14, 2014 11:06 am; edited 1 time in total
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1724

PostPosted: Sat Jan 11, 2014 1:04 pm    Post subject: Reply with quote

Not sure if it's gonna be helpful by any means, but perhaps you can just run `genkernel --no-clean initramfs` to make another one?

When you have initramfs decompress it and then extract with cpio. You will get another directory with little linux system inside. Change what you want and run
`find <path to directory with modified initramfs> | cpio -H newc -o | gzip -c > <path to new initramfs image file>`
you can of course use another compression tool, but gzip is fast and I had some glitch with xz. file says initramfs made by genkernel is in xz format, I can extract it with xz, but when I compress new image with xz kernel suddenly is unable to use it.

btw, don't worry, init inside initramfs IS a shell script. And it's big, but not really hard to hack if you have at least basic knowlege on bash
Back to top
View user's profile Send private message
FKK
n00b
n00b


Joined: 11 Jan 2014
Posts: 14
Location: Middle Land

PostPosted: Sat Jan 11, 2014 1:41 pm    Post subject: Reply with quote

szatox wrote:
Not sure if it's gonna be helpful by any means, but perhaps you can just run `genkernel --no-clean initramfs` to make another one?

thx for reply and cmd for separate initramfs .

I'm compiling new gentoo for my unlucky box, but all fail.
One kernel I made month ago works well, i want to look inside initramfs what's diff....
I remember i put something inside initramfs or changed the scripts, but forgot the detail ...........
_________________
config config config
build build build
boot boot boot
crash crash crash
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2968
Location: Germany

PostPosted: Sat Jan 11, 2014 1:47 pm    Post subject: Re: how to extract kernel by genkernel --integrated-initramf Reply with quote

FKK wrote:
I need to check some init scripts inside.
how can i extract it out?


This may be of help: https://wiki.gentoo.org/wiki/Custom_Initramfs#Salvaging

If it's the same format you can use this method directly; if it's a different format, binwalk should still be able to point you in the right direction.
Back to top
View user's profile Send private message
FKK
n00b
n00b


Joined: 11 Jan 2014
Posts: 14
Location: Middle Land

PostPosted: Sat Jan 11, 2014 2:00 pm    Post subject: Re: how to extract kernel by genkernel --integrated-initramf Reply with quote

frostschutz wrote:
FKK wrote:
I need to check some init scripts inside.
how can i extract it out?


This may be of help: https://wiki.gentoo.org/wiki/Custom_Initramfs#Salvaging

If it's the same format you can use this method directly; if it's a different format, binwalk should still be able to point you in the right direction.


how can i miss this wiki !!!

watching....... ty ty
_________________
config config config
build build build
boot boot boot
crash crash crash
Back to top
View user's profile Send private message
FKK
n00b
n00b


Joined: 11 Jan 2014
Posts: 14
Location: Middle Land

PostPosted: Tue Jan 14, 2014 11:04 am    Post subject: Reply with quote

i didnt find the file i want, but this question is solved.

https://wiki.gentoo.org/wiki/Custom_Initramfs#Salvaging
_________________
config config config
build build build
boot boot boot
crash crash crash
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum