LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 12-13-2011, 10:45 AM   #1
wdli
Member
 
Registered: Sep 2008
Location: California
Posts: 105

Rep: Reputation: 15
How to boot and using ramdisk in a diskless environment?


Hello,

Here is my requirement:

I need to boot a diskless x86 server with RHEL6 from an embedded TFTP device separate from the server. The server has plenty of memory (48G) but the device is very limited to about 250MB DRAM (It has no harddrive, only a flash for its own kernel). However the server doesn't need a full-featured RHEL6. A lot of it can be stripped off.

RHEL6 normally can be PXEbooted with a general kernel and a initial ramdisk. However I have to use ramdisk as my storage after the boot because the server is diskless. Otherwise I 'll need to NFS mount the root filesystem from another server. I don't want NFS to be running in the server.

I know how to use dracut to make initial ramdisk (initramfs) for RHEL6. But I am not sure how to make ramdisk part of the file system that can be mounted and used after boot in an environment like this.

In addtion I will have to stripped down RHEL6 to be as small as possible for the server.

The questions are:

1. How to make ramdisk part of the RHEL6 filesystem after the boot? Can I continue to use the initramfs after the boot?

2. What's the proper process to strip down the RHEL6 file system for the ramdisk?

Thanks.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 12-13-2011, 03:28 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
I have been able to create a minimal Linux based on Microcore Linux, that boots disklessly from a PXE/TFTP server, and can run entirely from the initrd. Basically, I took the entire Microcore distro, stripped out a few things I didn't need, added a couple of things I did need, and balled it up into an initrd. I exploited the Microcore scheme of parsing the kernel commandline at boot-time, to add capability to launch applications. The applications are specified as kernel arguments (kernel ignores arguments it doesn't need/understand) in the PXE bootloader.
I did attempt to start from a full-blown distro like RHEL, but found there to be way too much effort to locate and remove things I didn't want. Given the same task to repeat, I would now build everything myself from scratch. There is surprisingly little required to support one or two text-mode applications running headlessly. Busybox provides the principle functions need for most admin/diagnostics tasks. I built a kernel from scratch, that includes as little as I think I require. I could spend more time trimming there, but I'm satisfied with what I was able to create. I have a very limited number hardware targets to support.
To create the initrd, simply use cpio + gzip to archive an entire directory tree that contains your target root filesystem (as root):
Code:
cd /your/target/root
find . | cpio -H newc -o | gzip -9 -n > ../yourInitrd.gz
--- rod.

Last edited by theNbomr; 12-13-2011 at 03:31 PM.
 
2 members found this post helpful.
Old 12-13-2011, 04:16 PM   #3
wdli
Member
 
Registered: Sep 2008
Location: California
Posts: 105

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by theNbomr View Post
I have been able to create a minimal Linux based on Microcore Linux, that boots disklessly from a PXE/TFTP server, and can run entirely from the initrd. Basically, I took the entire Microcore distro, stripped out a few things I didn't need, added a couple of things I did need, and balled it up into an initrd. I exploited the Microcore scheme of parsing the kernel commandline at boot-time, to add capability to launch applications. The applications are specified as kernel arguments (kernel ignores arguments it doesn't need/understand) in the PXE bootloader.
I did attempt to start from a full-blown distro like RHEL, but found there to be way too much effort to locate and remove things I didn't want. Given the same task to repeat, I would now build everything myself from scratch. There is surprisingly little required to support one or two text-mode applications running headlessly. Busybox provides the principle functions need for most admin/diagnostics tasks. I built a kernel from scratch, that includes as little as I think I require. I could spend more time trimming there, but I'm satisfied with what I was able to create. I have a very limited number hardware targets to support.
To create the initrd, simply use cpio + gzip to archive an entire directory tree that contains your target root filesystem (as root):
Code:
cd /your/target/root
find . | cpio -H newc -o | gzip -9 -n > ../yourInitrd.gz
--- rod.
Hi Rod,
Thanks for the info. I never played with TinyCore before. The reason I use RHEL6 is its KVM support. I need to have a hypervisor running on the server. Do you know if TinyCore can support KVM?

David
 
Old 12-13-2011, 04:37 PM   #4
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
There are some packages for KVM host support in Tinycores repository, so I would think that it can act as hypervisor.
 
Old 12-13-2011, 05:09 PM   #5
wdli
Member
 
Registered: Sep 2008
Location: California
Posts: 105

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by TobiSGD View Post
There are some packages for KVM host support in Tinycores repository, so I would think that it can act as hypervisor.
you are right it seems KVM packages were added not long ago. But I don't see libvirt packages. I also need that.
 
Old 12-13-2011, 06:31 PM   #6
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Just to be clear, the server (boot host, if you prefer) does not have any particular architectural connection to the diskless target hosts. From the server perspective, is is just serving up data from a TFTP server, and dispensing IP and other info from the DHCP server. In deed, I don't advocate at all using the same components for each. Servers should be set up with all of the things that make good servers, and the thin clients should use what makes them best for their purpose.
Now that I re-read your original post, I see confusing wording: 'I need to boot a diskless x86 server with RHEL6 from an embedded TFTP device separate from the server' Is your question about how to create the boot host server, or is it about creating the diskless client code? Or both, or something else altogether?

--- rod.
 
Old 12-13-2011, 10:21 PM   #7
wdli
Member
 
Registered: Sep 2008
Location: California
Posts: 105

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by theNbomr View Post
Just to be clear, the server (boot host, if you prefer) does not have any particular architectural connection to the diskless target hosts. From the server perspective, is is just serving up data from a TFTP server, and dispensing IP and other info from the DHCP server. In deed, I don't advocate at all using the same components for each. Servers should be set up with all of the things that make good servers, and the thin clients should use what makes them best for their purpose.
Now that I re-read your original post, I see confusing wording: 'I need to boot a diskless x86 server with RHEL6 from an embedded TFTP device separate from the server' Is your question about how to create the boot host server, or is it about creating the diskless client code? Or both, or something else altogether?

--- rod.
Hi Rod,

I know how to create a DHCP/TFTP server (or the boot host server if you prefer) to serve up the files in a PXE boot. My question is more about the latter - how to create the diskless client code (the boot files) with the smallest footprint in a single ramdisk image. Ideally the diskless client should also support KVM/libvirt to run as hypervisor. But let's put the hypervisor requirement aside for the moment. Strange as it is, my boot host server is a tiny device with less than 250MB space available to hold the bootable ramdisk image.

That said, I am interested in what you have done using Microcore Linux - esp. when you could put the entire thing in a ram disk image and pxeboot. How big was your Microcore ramdisk image? If I were to follow down the same path, how would I start to build such a ramdisk image for my diskless client architecture?

David
 
Old 12-13-2011, 11:26 PM   #8
hurry_hui
Member
 
Registered: Oct 2008
Location: Near Jakarta
Distribution: Slackware, Arch, Slax, Porteus, Tiny Core, Slitaz
Posts: 355
Blog Entries: 1

Rep: Reputation: 52
Hi,

I follow this discussion and at first want to recommend using slitaz-base (~5MB) as basis for creating rootfs since it already has KVM. However after reading next posts and finding out that OP need libvirt package I can only refer to slitaz scratchbook where you can create your initramfs/rootfs from the scratch.

As for the question how to use microcore to build customized ramdisk. You can extract microcore.gz (~5MB) and add everything like how you create ramdisk from slitaz (i.e., from sratch, downloading source, etc) or just boot to microcore and adding extensions (.TCZ packages) using appbrowser-cli.
 
Old 12-14-2011, 09:33 AM   #9
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
The mechanics of crafting the initrd root filesystem from the Microcore (or any similar ISO-based distro) are, in general:
  1. Download the ISO image
  2. Mount the ISO image on a loop device
  3. Copy the ISO filesystem data to conventional disk storage
  4. Modify the contents of the filesystem according to your needs (extract the kernel to separate storage)
  5. Use the cpio script to create the initrd
  6. Copy the initrd and kernel to the boot host
You may need to use an intermediate tarball of the mounted ISO filesystem, or use something like rsync to perform the copy to conventional storage. Just be sure to preserve all of the filesystem properties and any soft links in the filesystem structure.
There may be other/better ways to do this; I describe how I did it. It is a one-time-only effort.

My final compressed initrd is about 11MB, including some special hardware drivers that I added, GNU screen, and the dropbear SSH server. I use the exact same image and kernel to boot many hosts, so this would seem to address your concern about the space required for your smallish boot host.
There is application-specific scripting to mount an NFS share (on the boot host), and applications are loaded from that share. All of the application-specific stuff is specified in the PXE bootloader commands. Deploying a new host is as simple as adding a new entry to the DHCP server config, and a new entry in the pxelinux.cfg directory.

--- rod.
 
1 members found this post helpful.
Old 12-14-2011, 11:15 AM   #10
wdli
Member
 
Registered: Sep 2008
Location: California
Posts: 105

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by theNbomr View Post
The mechanics of crafting the initrd root filesystem from the Microcore (or any similar ISO-based distro) are, in general:
  1. Download the ISO image
  2. Mount the ISO image on a loop device
  3. Copy the ISO filesystem data to conventional disk storage
  4. Modify the contents of the filesystem according to your needs (extract the kernel to separate storage)
  5. Use the cpio script to create the initrd
  6. Copy the initrd and kernel to the boot host
You may need to use an intermediate tarball of the mounted ISO filesystem, or use something like rsync to perform the copy to conventional storage. Just be sure to preserve all of the filesystem properties and any soft links in the filesystem structure.
There may be other/better ways to do this; I describe how I did it. It is a one-time-only effort.

My final compressed initrd is about 11MB, including some special hardware drivers that I added, GNU screen, and the dropbear SSH server. I use the exact same image and kernel to boot many hosts, so this would seem to address your concern about the space required for your smallish boot host.
There is application-specific scripting to mount an NFS share (on the boot host), and applications are loaded from that share. All of the application-specific stuff is specified in the PXE bootloader commands. Deploying a new host is as simple as adding a new entry to the DHCP server config, and a new entry in the pxelinux.cfg directory.

--- rod.
Got it. My client is a 16core x86 server. Should I start with the MultiCore ISO or MicroCore ISO?
 
Old 12-14-2011, 11:18 AM   #11
wdli
Member
 
Registered: Sep 2008
Location: California
Posts: 105

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by theNbomr View Post
The mechanics of crafting the initrd root filesystem from the Microcore (or any similar ISO-based distro) are, in general:
  1. Download the ISO image
  2. Mount the ISO image on a loop device
  3. Copy the ISO filesystem data to conventional disk storage
  4. Modify the contents of the filesystem according to your needs (extract the kernel to separate storage)
  5. Use the cpio script to create the initrd
  6. Copy the initrd and kernel to the boot host
You may need to use an intermediate tarball of the mounted ISO filesystem, or use something like rsync to perform the copy to conventional storage. Just be sure to preserve all of the filesystem properties and any soft links in the filesystem structure.
There may be other/better ways to do this; I describe how I did it. It is a one-time-only effort.

My final compressed initrd is about 11MB, including some special hardware drivers that I added, GNU screen, and the dropbear SSH server. I use the exact same image and kernel to boot many hosts, so this would seem to address your concern about the space required for your smallish boot host.
There is application-specific scripting to mount an NFS share (on the boot host), and applications are loaded from that share. All of the application-specific stuff is specified in the PXE bootloader commands. Deploying a new host is as simple as adding a new entry to the DHCP server config, and a new entry in the pxelinux.cfg directory.

--- rod.
Nnother question: do you have to nfs mount from the boot host to make it work? My requirement is no NFS at all, only ramdisk. In other words everything should be run from the ramdisk after boot. Is that possible?
 
Old 12-14-2011, 12:46 PM   #12
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
You can start from whatever base distro you want. I don't know anything about Multicore, but in principle it should work. I went for the smallest footprint I could find at the time, and that was Microcore. I did disregard a couple of other packages for reasons I can no longer remember. Just from the name, it sounds like Multicore addresses your virtualization requirement; sorry I don't know anything about that part.

I probably shouldn't have brought up the NFS stuff. Yes, you can include all of your application in the initrd. There is probably some limit to how large an initrd can be, but I think it is probably pretty large. My objective was to avoid making any application-specific initrd, and isolate the application-specific part on a server. Your objective(s) may be different.

--- rod.
 
Old 12-14-2011, 07:48 PM   #13
hurry_hui
Member
 
Registered: Oct 2008
Location: Near Jakarta
Distribution: Slackware, Arch, Slax, Porteus, Tiny Core, Slitaz
Posts: 355
Blog Entries: 1

Rep: Reputation: 52
Quote:
Originally Posted by wdli View Post
Got it. My client is a 16core x86 server. Should I start with the MultiCore ISO or MicroCore ISO?
Multicore ISO consists of microcore.gz, tinycore.gz, wifi, TC installer and remastering tool. Tinycore is microcore, X and window manager.
 
Old 12-15-2011, 06:13 PM   #14
wdli
Member
 
Registered: Sep 2008
Location: California
Posts: 105

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by theNbomr View Post
I have been able to create a minimal Linux based on Microcore Linux, that boots disklessly from a PXE/TFTP server, and can run entirely from the initrd. Basically, I took the entire Microcore distro, stripped out a few things I didn't need, added a couple of things I did need, and balled it up into an initrd. I exploited the Microcore scheme of parsing the kernel commandline at boot-time, to add capability to launch applications. The applications are specified as kernel arguments (kernel ignores arguments it doesn't need/understand) in the PXE bootloader.
I did attempt to start from a full-blown distro like RHEL, but found there to be way too much effort to locate and remove things I didn't want. Given the same task to repeat, I would now build everything myself from scratch. There is surprisingly little required to support one or two text-mode applications running headlessly. Busybox provides the principle functions need for most admin/diagnostics tasks. I built a kernel from scratch, that includes as little as I think I require. I could spend more time trimming there, but I'm satisfied with what I was able to create. I have a very limited number hardware targets to support.
To create the initrd, simply use cpio + gzip to archive an entire directory tree that contains your target root filesystem (as root):
Code:
cd /your/target/root
find . | cpio -H newc -o | gzip -9 -n > ../yourInitrd.gz
--- rod.
Hi Rod,

I created my initrd following your suggestion. The system booted up but crashed upon being unable to find the root file system. I figure this is because I didn't specify "root=xxx" in my initrd option. But also I am not quite sure what to specify. How do I tell the kernel where to mount the root file system in this case?

David
 
Old 12-15-2011, 07:12 PM   #15
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Your bootloader is the thing that needs to know about the initrd. I use pxelinux, and on the 'append=' line, I have the clause 'initrd=my/initrd/myInitrd-stable.gz'. The bootloader will then load the initrd, and using some system involving 'atags', tell the kernel where to find the initrd. The exact reference to the initrd is with respect to the filesystem on the boot host, relative to the tftp server root.

--- rod.
 
  


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
RAMDISK: couldn't find valid ramdisk image starting at 0. iotc247 Slackware 10 12-10-2010 03:08 PM
diskless environment vishnuvijayan Linux - Newbie 3 06-19-2009 07:09 AM
Diskless Environment bharatlalgupta Linux - Software 0 02-09-2009 06:22 AM
diskless router, using ramdisk? acpi Linux - General 2 08-17-2006 02:04 PM
About Diskless boot fongkakit Linux - Networking 1 07-19-2004 06:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 07:28 AM.

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