iPXE discussion forum

Full Version: Any Recommendation on creating a custom iso from installed OS
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I wanted to create a custom image from the installed Linux machine.
i am fine with any distributions. i tried relinux to create a custom image from installed linux OS.. but if i ipXEboot to this iso it always taking me to busybox state.

Is there any recommendations for me to create a custom image..

My intention:
1. I wanted to ipXE boot to the custom image which has my tool which will be running as a startup program.
Any ideas /directions will be really helpfull.

Note:
created custom image thrws below error
"/init: line 3: cant' open /dev/sr0:no medium found"
and after that it boots to buysbox env.
The reason you're stopping at busybox is because once the linux kernel starts and starts using its drivers, the sanbooted CD is no longer accessible to the operating system, which is causing a drop to busybox.

A netbootable ISO must support some way of fetching its files from a network location instead of the local CDROM drive. My guess is your custom ISO doesn't do that. All files needed to bring up network and fetch the extra files must be inside the initrd.

You can see how I do it for Ubuntu in the ubuntu-installer menu options here: https://gist.github.com/robinsmidsrod/2234639
Do i need to setup a NFS share to boot the custom iso ?
Do i need to extract the custom.iso and put in the http or tftp folder?
Do i need to comment out the CDROM options somewhere before i make custom.iso using relinux ?
Is there any place i can add netboot to yes?if yes what should be the ipxe config file?

let me reiterate my steps:
1. Installed Ubuntu 12 in physical host
2. Edit and make initrd
vi $ /etc/initramfs-tools/initramfs.conf
"MODULES"=netboot
$ mkinitramfs -o ~/initrd.img-`uname -r`
$ reboot
3. Installed my script
4. Installed Relinux tools
5. Packaged the installed Ubuntu to "custom.iso" using relinux tool
$ relinux iso relinux.conf
# custom.iso is created in /home/relinux/
4. Configuring ISO file for iPXE boot:
$ mount -o loop -t iso9660 <ISO Filename>.iso /<temp mount point>/
$ cp -R <temp mount point dir> <sandbox path>
$ mv isolinux/ syslinux/
$ mv isolinux.bin -> syslinux.bin
$ mv isolinux.cfg -> syslinux.cfg
# Remake Bootable ISO:
$mkisofs -q -V <VolumeLabel> -b <syslinux.bin file> -c < boot.cat file> -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -T -o <recustom.iso> .

======
Note: If i use recustom.iso to boot the VM using vCNETER.. it works without any issues.

Below are the iPXE config:
$ sanboot http://192.168.13.5/download/recustom.iso

============

Can you please let me know where to make specific config changes .

Thanks in advance for your response..
Any thoughts ?
any directions would be of really helpfull.. i am in PST timing.. desperately waiting for next steps/
Thanks in advance!
Will that work only if i netboot the custom iso file by copying all the OS files in NFS share?
Is that the only way ?

I dont want to have a NFS share and netboot the custom iso file?

Is there any workaround to sanboot the custom iso ?
does any one comeacross this issue?
any workaround..
Looking forward to take up any suggestions.. open for new directions also.
I'm not sure how much you know about the general way Linux is loaded. It seems to me that there is some confusion about what goes where, and how it's loaded.

1. A boot loader is responsible for loading your kernel and initrd into memory, and specifying the kernel command line (which among other things tell you where your root mountpoint is located). This is usually ipxe, grub or syslinux's job.
2. The kernel is started, it will find its initrd (ramdisk) in memory, initialize all the hardware it can see, and then start /sbin/init (inside the initrd/ramdisk).
3. /sbin/init will ensure that other software is started that does a bunch of different things.
4. One of them is to find the storage media for the root mount point and mount that.

Usually the root mount point is on a local storage device (like a HDD) so it's just a matter of looking through your device list and connect things together.

When you netboot you usually don't have any local storage, and you need to start the network first, before you can mount your root fs. In most installers this is usually a squashfs located somewhere on the CD. When you netboot, you'll need to find out a way to tell the /sbin/init-scripts on the initrd where to locate that file instead of using a locally connected CD. That is usually done using some kernel command line paramter.

Ubuntu, using its software called casper, supports finding this file using either NFS or SMB file sharing. SystemRescueCD supports both of those, but also HTTP and FTP. It all depends on the distro what options you have.

If you look closely at my menu example at https://gist.github.com/robinsmidsrod/2234639 you can see that I've figured out how to load a bunch of different distros via the network by carefully setting the kernel command line paramters to something that works. Finding out how has been a thorough work looking through a lot of documentation for the different distros, and sometimes unpacking the initrds to see how the boot scripts are put together and what parameters they accept.

A quick way to study an initrd is to boot your kernel with init=/bin/sh (or init=/bin/bash if available) which will give you a shell straight onto the initrd. If the initrd has bash, I'd use that instead, and with a bit of clever usage of the busybox tools available, it is usually quite easy to look around and get an understanding of how the initrd works.

Hope this will help you on your netbooting quest.
thanks for the detailed response Robin!..

1. I mounted the custom iso[created using relinux] and extracted all the files and copied to my Http server under 192.168.13.5/mount/
2. chmod +x mount/
In PXE server: below is my config
"echo booting from custom image
set root-path http://192.168.13.5/mount/
sanboot ${root-path} || goto failed
goto start "

o/p : booting from custom image

its just hangs here itself.. I don't think sanboot is getting executed..
any clue?
please let me know if I am doing something basic in correct?
I made some progress today ..
after i add netboot options like below its found the mnt point.
but now its failing in the network confi..


below is my bootloader.cfg:
set root-path /tftpboot/ipxe/nfsshare
set nfs-server 192.168.13.5
kernel http://192.168.13.5/nfsshare/casper/vmlinuz
initrd http://192.168.13.5/nfsshare/casper/initrd.gz
imgargs vmlinuz root=/dev/nfs boot=casper netboot=nfs nfsroot= "http://192.168.13.5/nfsshare/"

Output:
its keep looking in the network config,[please refer the attached screenshot]

please let me know if i am missing something?
how do i pass the nfsroot arg?
Appreciate your contiguous response.
sanboot is for booting block storage, like an ISO file, or iSCSI/AoE block devices. In your case you have unpacked the ISO, so sanboot is no longer the tool you should use. Using kernel+initrd is the correct approach. You're a bit mistaken with the imgargs you supply. Specifying nfsroot with a string that starts with http:// isn't right. The parameter should look like this:
Code:
nfsroot=192.168.13.5:/nfsshare/
(and no quotes). The "set root-path" and "set nfs-server" commands are redundant and can be removed. Also be aware that iPXE now supports booting from NFS, so the kernel and initrd lines can use nfs://192.168.13.5/nfsshare/casper/ as the start instead of http://... Just remember you need to enable NFS support in iPXE first.
**** IT WORKED *******
Thanks foryour contiguous response.highly appreciate your contribution..

OK. below is what i did:
looks like my iPXE setup doesnt support NFS.
# install NFS support in iPXE
1. git clone git://git.ipxe.org/people/mareo/ipxe.git
cd ipxe/src
git checkout nfs
echo "#define DOWNLOAD_PROTO_NFS" >> config/local/general.h
make
make everything
2. replace the "undionly.kpxe" with new ipxe
3. restart the service

Below is my bootloader.cfg file:

Code:
kernel nfs://192.168.13.5/nfsshare/casper/vmlinuz
initrd nfs://192.168.13.5/nfsshare/casper/initrd.gz
imgargs vmlinuz root=/dev/nfs boot=casper netboot=nfs nfsroot=192.168.13.5:/nfsshare

Note: I have exported the 192.168.13.5/nfshare where i have casper directory of my custom image.
I think key here is we need to have nfs mount point.
Thanks again for your work!!

One another question: for some reason while pxe booting it takes while in ntwork config [> 64 sec]..
something like below:
IP-config: eth1 hardwar address <macaddress> mtu 1500 DHCP RARP
...
is there any way to skip this step?

Thanks again!!!
NFS support has been added to the main branch. You're not required to compile mareo's branch anymore. The only thing you need to remember is to enable NFS in src/config/local/general.h (which you already did) and recompile. Make sure you're using the most recent master branch on the main ipxe repo.

Your timeout issue seems to be related to the fact that it completes on eth1, not eth0, which seems to indicate you have another network card (wireless maybe?) that is taking a long time to timeout.
thanks robin!.
I have disabled all nics in my server.. i have only enabled port 4 [forPXE] and port 1 for OS.
Sometimes timeout is expiring and going to kernel panic mode.. i dont know where to get teh logs?
is there any workaround for this n/w timeout issue..?

If i liveboot to custom image and cat /etc/network/interfaces below is what i see:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet manual
autoeth1
iface eth1 inet manual
auto eth2
iface eth2 inet manual
auto eth3
iface eth3 inet maual
auto ath0
iface ath0 inet dhcp
auto wlan0
iface wlan0 inet dhcp

- Is this wlan0 is generated by relinux tool ?
If you get an ath0 device auto-populated inside that file, it does seem like you have a wireless card in the machine. You could completely disable wireless support in iPXE (see the files in src/config/*.h for details) which should hopefully avoid the timeout issue. Also, I would suggest using the first port on the multiport network adapter for PXE, as it means iPXE won't need to cycle through DHCP on the other ports first. Also, you should use either the command dmesg or the log file /var/log/dmesg to look up hardware detection information.
Reference URL's