Jump to content











Photo
- - - - -

Patching Linux kernel to accept live-media-path


  • Please log in to reply
13 replies to this topic

#1 Holmes.Sherlock

Holmes.Sherlock

    Gold Member

  • Team Reboot
  • 1444 posts
  • Location:Santa Barbara, California
  •  
    United States

Posted 17 January 2011 - 01:56 AM

I'm working on an USB multiboot project where I need to two Ubuntu based custom distros having the same directory & file structure - samurai - 0.8 & MultiISO- 2.0-Final.(Basically MultiISO is a combination od several Linux distros where one of them is Ubuntu based). The samurai ISO contains .disk/info file which contains the line

Ubuntu 9.04 "jaunty" - Release i386 (20100103)


What I did is as follows:

---------------------------------------------------------------------------------------

1) To extract the contents of the ISO to a folder called samurai on the UFD & then put the following lines in the Grub4DOS menu.lst





title Samurai

kernel /samurai/casper/vmlinuz file=/samurai/preseed/custom.seed boot=casper ignore_uuid live-media-path=samurai/casper quiet splash vga=791

initrd /samurai/casper/initrd.gz


I got the message "Assuming drive cache - write through", then the boot process got stuck & lastly it dropped me to a BusyBox shell. With mount command, I found the live squash filesystem, i.e. filesystem.squashfs has not been mounted. So, I concluded that the custom kernel based on Ubuntu-9.04 does not support live-media-path parameter.

2) Next, I replaced the above kernel & initrd with those from Ubuntu-10.10.
The output was a bit verbose in the sense that it displayed messages which shows that it has found the squashfs fileystem(& it is version 3.0) (showing that it accepts live-media-path) BUT, the process terminated with an "Invalid argument" error. The squashfs docs on the net says that it has got many revisions & has versions from 1.0 to 4.0. I thought that - there is a version mismatch since the squashfs support has to be enabled in the kernel beforehand. Issuing the mount command again shows that squashfs has not been mounted.

3) The partition of UFD was mounted in /cdrom automatically during the boot process.
With the configuration of (2), I tried the following command

mkdir /filesystem.squashfs

mount -o loop -t squashfs /cdrom/samurai/casper/filesystem.squashfs /filesystem.squashfs


It terminated with the same error message.

4) With the configuration (1), I issued the same command set as in (3) & it got mounted with a success message. I could peek into the mounted squashfs filesystem from the BusyBox shell. The I tried to start the /init from the mounted initramfs filesystem manually

./init


But it terminated with error message & dropped me again to BusyBox.


5) I repeated the process of (1) with original kernel - initrd combinations from Ubuntu - 9.04, but there was only a black screen with no error/ boot message.

6) I tried other kernel & initrd combinations which I can't remember but none of them worked.

------------------------------------------------------------------------------------------------------------------------------

I had this link earlier, but I was tired & moreover, not sure whether it'll definitely work, So, I gave up for the time being. The referenced page says to add live-media-path as a kernel parameter for the Ubuntu kernels not supporting it. It sound like an excellent idea. Beacuse, most of the times when a Linux based distro fails to boot from UFD, we try to make the boot by altering Grub4DOS commands. But, wouldn't it be nice to understand the Linux boot process & accordingly customize the kernel parametres so that it can boot on its own without Grub4DOS ISO mapping? Does anybody have any other idea regarding this kernel patching?

#2 karyonix

karyonix

    Frequent Member

  • Advanced user
  • 472 posts
  •  
    Thailand

Posted 17 January 2011 - 06:18 AM

I think you don't have to patch kernel.
Some parameters are processed by scripts in initrd (or initramfs).
Try extract initrd (or initramfs) and read the scripts inside.

#3 Holmes.Sherlock

Holmes.Sherlock

    Gold Member

  • Team Reboot
  • 1444 posts
  • Location:Santa Barbara, California
  •  
    United States

Posted 17 January 2011 - 06:26 AM

Some parameters are processed by scripts in initrd (or initramfs).
Try extract initrd (or initramfs) and read the scripts inside.


I've already done that. Here is the link to download the init script situated at the root of initramfs.

#4 shamurshamur

shamurshamur

    Frequent Member

  • Developer
  • 322 posts
  •  
    India

Posted 17 January 2011 - 06:49 AM

parameters like live-media-path and iso-scan/filename are supported in initrd (or initramfs) and have nothing to do with kernel.


In case of ubuntu extract initrd (or initramfs).
(Now look inside folder "scripts" . it contains all the scripts which implements various kernel parameters.)
1) live-media-path parameter is supported in script
/scripts/casper

2) iso-scan/filename parameter is supported in
/scripts/casper-premount/20iso_scan


if these scripts are removed in an ubuntu based distro , then these parameters will not work.
so look in to the initrd of samurai and tell us if these scripts are present.

#5 Holmes.Sherlock

Holmes.Sherlock

    Gold Member

  • Team Reboot
  • 1444 posts
  • Location:Santa Barbara, California
  •  
    United States

Posted 17 January 2011 - 06:57 AM

In case of ubuntu extract initrd (or initramfs).
(Now look inside folder "scripts" . it contains all the scripts which implements various kernel parameters.)
1) live-media-path parameter is supported in script
/scripts/casper

Here is the link to download the script. Can anybody try to figure out how to add the support?


2) iso-scan/filename parameter is supported in
/scripts/casper-premount/20iso_scan


There is only one script in the specified folder called 10driver_updates

#6 shamurshamur

shamurshamur

    Frequent Member

  • Developer
  • 322 posts
  •  
    India

Posted 17 January 2011 - 07:14 AM

Here is the link to download the script. Can anybody try to figure out how to add the support?



megaupload.com doesn't work for me . can you please upload it on mediafire.com


There is only one script in the specified folder called 10driver_updates


that means iso-scan/filename parameter will not work in samurai.

#7 Holmes.Sherlock

Holmes.Sherlock

    Gold Member

  • Team Reboot
  • 1444 posts
  • Location:Santa Barbara, California
  •  
    United States

Posted 17 January 2011 - 08:00 AM

megaupload.com doesn't work for me . can you please upload it on mediafire.com

Here is the link of /scripts/casper in mediafire.

#8 shamurshamur

shamurshamur

    Frequent Member

  • Developer
  • 322 posts
  •  
    India

Posted 17 January 2011 - 08:52 AM

Well as far as i can guess , live-media-path parameter is not supported in samurai.
same problem is with Backtrack and some other distros.

If you are interested there's an article written about how to patch the initrd of these distros so that they can support live-media-path parameter.
http://blog.mycila.c...tu-usb-key.html

#9 Holmes.Sherlock

Holmes.Sherlock

    Gold Member

  • Team Reboot
  • 1444 posts
  • Location:Santa Barbara, California
  •  
    United States

Posted 17 January 2011 - 10:59 AM

If you are interested there's an article written about how to patch the initrd of these distros so that they can support live-media-path parameter.
http://blog.mycila.c...tu-usb-key.html

I've already mentioed about the link at the end of my first post. Posted Image

#10 shamurshamur

shamurshamur

    Frequent Member

  • Developer
  • 322 posts
  •  
    India

Posted 17 January 2011 - 11:43 AM

I've already mentioed about the link at the end of my first post. Posted Image

LOL Posted Image
Giving your solution back to you.

Anyway.
I have read the casper file of samurai you uploaded.
There's no mention of live-media-path parameter in that file , so i think its not supported. The Only method now left is to use the patch given in the link you mentioned.

#11 Holmes.Sherlock

Holmes.Sherlock

    Gold Member

  • Team Reboot
  • 1444 posts
  • Location:Santa Barbara, California
  •  
    United States

Posted 17 January 2011 - 11:56 AM

Anyway.
I have read the casper file of samurai you uploaded.
There's no mention of live-media-path parameter in that file , so i think its not supported. The Only method now left is to use the patch given in the link you mentioned.

But, in the referenced blog, there was no mention of the Ubuntu version of initrd to which this patch is applicable. I don't have that depth in shell scripting so that just by looking at the casper.patch, I can be able to customize to suit my needs. Posted Image

#12 Holmes.Sherlock

Holmes.Sherlock

    Gold Member

  • Team Reboot
  • 1444 posts
  • Location:Santa Barbara, California
  •  
    United States

Posted 17 January 2011 - 03:03 PM

I ran the patch & this was the result

patching file scripts/casper
Hunk #2 succeeded at 47 (offset 2 lines).
Hunk #3 succeeded at 60 (offset 2 lines).
Hunk #4 succeeded at 113 (offset 2 lines).
patch unexpectedly ends in middle of line
Hunk #5 succeeded at 422 with fuzz 1 (offset 2 lines).

To me, it seems to be partial success. Am I right? Should I proceed?

#13 shamurshamur

shamurshamur

    Frequent Member

  • Developer
  • 322 posts
  •  
    India

Posted 17 January 2011 - 05:23 PM

I ran the patch & this was the result

To me, it seems to be partial success. Am I right? Should I proceed?


looks good you can proceed.

i just patched the casper file on backtrack. and passed the live-media-path parameter to kernel. and it worked fine.

Here's the content of my patched casper file.

Spoiler


#14 Holmes.Sherlock

Holmes.Sherlock

    Gold Member

  • Team Reboot
  • 1444 posts
  • Location:Santa Barbara, California
  •  
    United States

Posted 17 January 2011 - 05:57 PM

Oh, can't believe!!! The patch works for samurai - 0.8, too. Thanks shamurshamur for being with me all the way.

If, for any reason, the link dies or if anyone wants a neat quick refrence, I am outlining the process in a nutshell:
1)
mkdir tmp
2) Put initrd.gz from BackTrack / samurai / other Ubuntu based distro not accepting live-media-path parameter iso to tmp folder
3)
cd tmp
4)
gzip -dc initrd.gz | cpio -id
5)
rm initrd.gz
6)
patch -u scripts/casper < ../casper.patch
If the Ubuntu distro does not come with patch command preinstalled as in the case of Ubuntu - 10.10 Netbook edition, install it by issuing
sudo apt-get install patch
(You'll find the casper.patch as an attachment at the end of this post)
7)
find . | cpio --quiet --dereference -o -H newc | gzip -9 > ./initrd-patched.gz
8) Pass

ignore_uuid live-media-path=/ubuntu/casper

as kernel parameter from Grub4DOS / ISOLINUX / SYSLINUX (Sample menu.lst in Post #1)

Attached Files






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users