LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-10-2012, 03:54 PM   #1
ciclonite
LQ Newbie
 
Registered: Jun 2012
Posts: 4

Rep: Reputation: Disabled
Bootable USB with two partition


Hi all,
I have an USB stick with two partiton (called for semplicity P1 and P2).
I need to create bootable usb with this constrain:
1. The bootloader stay on P1
2. The Linux OS stay on P2
3. Before the Bootloader load the root Partition on P2, I NEED TO CALL A BASH SCRIPT. (this is the most important thing).
I've try to doing this with SYSLINUX + initrd without success.

My idea was SYSLINUX boot initrd, call the script and after load the root partition.

Have any idea or tutorial?
Thanks a lot.
 
Old 06-11-2012, 04:32 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,838

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
how do you want to execute a bash script without an os? what is in that script?
 
Old 06-11-2012, 04:50 AM   #3
ciclonite
LQ Newbie
 
Registered: Jun 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
Using INITRD teorically im able to execute command. The script call a binary executable.
 
Old 06-11-2012, 05:29 AM   #4
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,371

Rep: Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749
Theoretically you cannot use the initrd to execute a command. From http://www.ibm.com/developerworks/li...y/l-linuxboot/
Quote:
Init

After the kernel is booted and initialized, the kernel starts the first user-space application. This is the first program invoked that is compiled with the standard C library. Prior to this point in the process, no standard C applications have been executed.

In a desktop Linux system, the first application started is commonly /sbin/init. But it need not be. Rarely do embedded systems require the extensive initialization provided by init (as configured through /etc/inittab). In many cases, you can invoke a simple shell script that starts the necessary embedded applications.
If you are looking to run a script after the kernel is loaded but before the root partition is mounted, then you will need to look at the init process.
 
Old 06-11-2012, 06:58 AM   #5
ciclonite
LQ Newbie
 
Registered: Jun 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thanks for quick reply.
I dont understand where is /sbin/init.
I've no access on P2 (the root partition) before invoking the binary executable.
 
Old 06-11-2012, 10:22 AM   #6
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,371

Rep: Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749
The /sbin/init executable is included in the initrd. As I do not use Ubuntu, I cannot really help you much further with this.
 
Old 06-11-2012, 12:08 PM   #7
abdul_ahad
LQ Newbie
 
Registered: Jan 2008
Distribution: ubuntu
Posts: 6

Rep: Reputation: 0
after the kernel is loaded, if an initrd is present, the kernel looks for a file named linuxrc in the root directory of the initrd and executes it. then the actual root is mounted and /sbin/init is executed.

if you want to run a bash script before the root filesystem is mounted, put it in the root directory of the initrd, make it executable and name it linuxrc

Last edited by abdul_ahad; 06-13-2012 at 05:38 AM.
 
Old 06-12-2012, 03:36 PM   #8
ciclonite
LQ Newbie
 
Registered: Jun 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thanks for reply.
I'm able to boot the initrd and execute the relative command using init. But now i need a method to found the root partition and boot it.. Any ideas?
Thanks a lot.
 
Old 06-13-2012, 05:29 AM   #9
abdul_ahad
LQ Newbie
 
Registered: Jan 2008
Distribution: ubuntu
Posts: 6

Rep: Reputation: 0
the normal procedure for the kernel, if an initrd is found is to execute linuxrc or init from it and then proceed to mount the root filesystem from the device given in the kernel command line at boot time, and then run /sbin/init from the actual rootfs. there is generally no need to run any special commands for mounting the actual root from the initrd.

Quote:
Originally Posted by ciclonite View Post
Thanks for reply.
I'm able to boot the initrd and execute the relative command using init. But now i need a method to found the root partition and boot it.. Any ideas?
Thanks a lot.
are you referring to a shell script you have named as init in the initrd. if so, can you post its contents here so that we can have some idea of what goes on after loading the initrd and then work from there.

Last edited by abdul_ahad; 06-13-2012 at 05:33 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Making one partition of a USB stick bootable Ubuntu install aurora72 Ubuntu 1 05-16-2012 05:54 AM
[SOLVED] If I dd copy a bootable usb drive to an iso will the iso be bootable? mgallatin Linux - Software 5 03-23-2011 04:46 PM
Creating bootable CDROM from a bootable USB drive seaquesttr Linux - Desktop 2 08-01-2010 11:57 AM
Making a USB stick bootable from a bootable cdrom cwwilson721 Slackware 2 10-23-2009 09:18 PM
Error: invalid or damaged bootable partition, when booting from USB. tarekahf Puppy 5 03-19-2008 09:09 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration