View previous topic :: View next topic |
Author |
Message |
Raffi l33t
Joined: 17 Mar 2003 Posts: 731 Location: Moscow, Id.
|
Posted: Mon May 14, 2007 8:01 pm Post subject: [minihowto] Network bootable (no nfs) minimal livecd |
|
|
This mini howto will address the changes needed to the livecd init
script and cpio ramdisk image in order to make it bootable via pxe
without using NFS. I will not be spending any time on setting up the pxe
server (other than the specific configuration needed to boot the livecd
image).
I have seen another howto on this topic, but I could not find it when I
was getting ready to convert the 2007.0 minimal livecd so I had to start
from scratch.
Recent version of cpio are able to deal the the multi part cpio
archive without the need to run them through a special spiller
program first. Due to various bugs in cpio, I would suggest using the
app-arch/cpio-2.7-r2 version.
The following patch will patch the init script on the livecd so that it
can mount the included squashfs image.
Code: |
*** init.orig 2007-05-09 08:23:52.000000000 -0700
--- init 2007-05-09 09:32:11.000000000 -0700
***************
*** 370,375 ****
--- 370,381 ----
got_good_root=0
continue
+ elif [ "${REAL_ROOT}" = '/' ]
+ then
+ got_good_root=1
+ mkdir -p ${NEW_ROOT}/mnt/cdrom
+ mkdir -p ${NEW_ROOT}/mnt/livecd
+ cp /image.squashfs ${NEW_ROOT}/mnt/cdrom
elif [ "${REAL_ROOT}" = '' ]
then
# No REAL_ROOT determined/specified. Prompt user for root block device.
|
Edit 7/8/08 Added Patch for init on 2008.0
Code: |
*** init.orig 2008-07-08 10:09:42.000000000 -0700
--- init 2008-07-08 10:09:04.000000000 -0700
***************
*** 356,362 ****
;;
esac
! if [ "${REAL_ROOT}" = '' ]
then
# No REAL_ROOT determined/specified. Prompt user for root block device.
whereis "REAL_ROOT" "root block device"
--- 356,368 ----
;;
esac
! if [ "${REAL_ROOT}" = '/' ]
! then
! got_good_root=1
! mkdir -p ${NEW_ROOT}/mnt/cdrom
! mkdir -p ${NEW_ROOT}/mnt/livecd
! cp /image.squashfs ${NEW_ROOT}/mnt/cdrom
! elif [ "${REAL_ROOT}" = '' ]
then
# No REAL_ROOT determined/specified. Prompt user for root block device.
whereis "REAL_ROOT" "root block device"
|
Edit 11/6/09 Added Patch for init on latest minimal cd (20091103)
Code: |
*** init.orig Fri Nov 6 08:40:31 2009
--- init Fri Nov 6 08:58:00 2009
***************
*** 423,428 ****
--- 423,434 ----
then
got_good_root=1
+ elif [ "${REAL_ROOT}" = '/' ]
+ then
+ got_good_root=1
+ mkdir -p ${NEW_ROOT}/mnt/cdrom
+ mkdir -p ${NEW_ROOT}/mnt/livecd
+ cp /image.squashfs ${NEW_ROOT}/mnt/cdrom
else
bad_msg "Block device ${REAL_ROOT} is not a valid root device..."
REAL_ROOT=""
|
Edit 4/30/10 Added Patch for init on latest minimal cd (20100408)
Code: |
*** init.orig Thu Apr 8 06:29:36 2010
--- init Thu Apr 29 13:37:54 2010
***************
*** 422,428 ****
elif [ -b "${REAL_ROOT}" ] || [ "${REAL_ROOT}" = "/dev/nfs" ]
then
got_good_root=1
!
else
bad_msg "Block device ${REAL_ROOT} is not a valid root device..."
REAL_ROOT=""
--- 422,433 ----
elif [ -b "${REAL_ROOT}" ] || [ "${REAL_ROOT}" = "/dev/nfs" ]
then
got_good_root=1
! elif [ "${REAL_ROOT}" = '/' ]
! then
! got_good_root=1
! mkdir -p ${NEW_ROOT}/mnt/cdrom
! mkdir -p ${NEW_ROOT}/mnt/livecd
! cp /image.squashfs ${NEW_ROOT}/mnt/cdrom
else
bad_msg "Block device ${REAL_ROOT} is not a valid root device..."
REAL_ROOT=""
|
Edit 12/14/10 Added Patch for init on latest minimal cds (20101123 and 20101209)
Code: |
*** init.orig Tue Nov 23 04:54:52 2010
--- init Mon Dec 13 17:16:14 2010
***************
*** 458,464 ****
elif [ -b "${REAL_ROOT}" ] || [ "${REAL_ROOT}" = "/dev/nfs" ]
then
got_good_root=1
!
else
bad_msg "Block device ${REAL_ROOT} is not a valid root device..."
REAL_ROOT=""
--- 458,469 ----
elif [ -b "${REAL_ROOT}" ] || [ "${REAL_ROOT}" = "/dev/nfs" ]
then
got_good_root=1
! elif [ "${REAL_ROOT}" = '/' ]
! then
! got_good_root=1
! mkdir -p ${NEW_ROOT}/mnt/cdrom
! mkdir -p ${NEW_ROOT}/mnt/livecd
! cp /image.squashfs ${NEW_ROOT}/mnt/cdrom
else
bad_msg "Block device ${REAL_ROOT} is not a valid root device..."
REAL_ROOT=""
|
Edit 7/17/2012 Added Patch for init on latest minimal cds (20120710 and 20120621)
Code: |
*** init.orig Mon Jul 16 14:11:54 2012
--- init Tue Jul 17 06:33:02 2012
***************
*** 456,462 ****
elif [ -b "${REAL_ROOT}" ] || [ "${REAL_ROOT}" = "/dev/nfs" ]
then
got_good_root=1
!
else
bad_msg "Block device ${REAL_ROOT} is not a valid root device..."
REAL_ROOT=""
--- 456,465 ----
elif [ -b "${REAL_ROOT}" ] || [ "${REAL_ROOT}" = "/dev/nfs" ]
then
got_good_root=1
! elif [ "${REAL_ROOT}" = '/' ]
! then
! got_good_root=1
! cp /image.squashfs ${CDROOT_PATH}
else
bad_msg "Block device ${REAL_ROOT} is not a valid root device..."
REAL_ROOT=""
|
Edit 5/9/2013 Added Patch for init on latest minimal cds (20130423 and 20130425)
Code: |
--- init.orig 2013-05-09 13:19:04.952112000 -0700
+++ init 2013-05-09 13:20:58.643969000 -0700
@@ -589,7 +589,10 @@
elif [ -b "${REAL_ROOT}" ] || [ "${REAL_ROOT}" = "/dev/nfs" ]
then
got_good_root=1
-
+ elif [ "${REAL_ROOT}" = '/' ]
+ then
+ got_good_root=1
+ cp /image.squashfs ${CDROOT_PATH}
else
bad_msg "Block device ${REAL_ROOT} is not a valid root device..."
REAL_ROOT=""
|
The basic steps needed for this to work are
- Unpack the cpio ramdisk file included in the minimal livecd
- Edit the init file to work with the squashfs file system included
- Add the squashfs image to the unpacked ramdisk image.
- Re-cpio gzip the ramdisk image
- Add image entry to pxe server.
The following needs to be done as root:
Code: |
# Mount iso through loopback device so you can access the cpio file.
#
mount -o loop [i]/path/to/livecd_image.iso[/i] /mnt/loop
# Create a directory to unpack the cpio ramdisk info
#
mkdir ramdisk
cd ramdisk
zcat /mnt/loop/isolinux/gentoo.igz | cpio -ivmd
# Patch the init script in the ramdisk image
patch <[i]/path/to/where/you/saved/init.patch[/i]
# Copy in squashfs image
cp /mnt/loop/image.squashfs .
# re-cpio ramdisk image
find . -print | cpio -H newc -o | gzip -9 >../gentoo.igz
|
Edit 5/9/2013 using xz insead of gzip for initrd
Code: |
find . -print | cpio -H newc -o | xz --check=crc32 >../gentoo.igz
|
You will now have a minimal livecd ramdisk image that can be used to
boot a system via pxe. This can be used along with the kernel from the
livecd to do a network boot.
Code: |
cp gentoo.igz /tftpboot
cp /mnt/loop/isolinux/gentoo /tftpboot
|
To configure pxe linux to boot the system add the following to
/tftpboot/pxelinux.cfg/default or whatever name you have configured to
use.
Code: |
label gentoo
kernel gentoo
append initrd=gentoo.igz root=/dev/ram0 init=/linuxrc loop=image.squashfs looptype=squashfs cdroot=1 real_root=/
|
I have successfully applied these changes to both the x86 and the amd64
version of the minimal live cd.
Last edited by Raffi on Thu May 09, 2013 9:11 pm; edited 6 times in total |
|
Back to top |
|
|
elgato319 Guru
Joined: 15 Sep 2005 Posts: 546
|
Posted: Tue May 15, 2007 9:45 am Post subject: |
|
|
thanks for this post, worked like a charm on 2007.0 |
|
Back to top |
|
|
ManOfMilk n00b
Joined: 25 Sep 2005 Posts: 9 Location: Oregon
|
Posted: Thu Jul 12, 2007 8:20 pm Post subject: |
|
|
I attempted to make this image and I must be having some issues, on the 945, i can get the system to post up, however, it panics with this error.
"Cannot open root device "<NULL>" or unknown-block(8,2)"
i thought passing it the /dev/ram0 is the correct root= option? Is it different with the 2007.0-r1 CD?
any help is appreciated.. |
|
Back to top |
|
|
st0kk n00b
Joined: 26 Sep 2007 Posts: 1
|
Posted: Wed Sep 26, 2007 12:20 pm Post subject: |
|
|
Here is a init.patch for 2007.0-r1
Code: |
--- init 2007-05-07 22:23:48.000000000 +0200
+++ /tmp/init 2007-09-26 14:17:26.000000000 +0200
@@ -370,6 +370,13 @@
got_good_root=0
continue
+ elif [ "${REAL_ROOT}" = '/' ]
+ then
+ got_good_root=1
+ mkdir -p ${NEW_ROOT}/mnt/cdrom
+ mkdir -p ${NEW_ROOT}/mnt/livecd
+ cp /image.squashfs ${NEW_ROOT}/mnt/cdrom
+
elif [ "${REAL_ROOT}" = '' ]
then
# No REAL_ROOT determined/specified. Prompt user for root block device.
|
Many thnx for the 1st patch, it solved my 1 problem.. _________________ *doh* |
|
Back to top |
|
|
cnrs n00b
Joined: 30 Sep 2007 Posts: 11
|
Posted: Sun Sep 30, 2007 10:40 pm Post subject: Problem with a Patch... |
|
|
Hello,
Sorry for my English, i'm French...
I have a problem with patch:
Quote: | *** init.orig 2007-05-09 08:23:52.000000000 -0700
--- init 2007-05-09 09:32:11.000000000 -0700
***************
*** 370,375 ****
--- 370,381 ----
got_good_root=0
continue
+ elif [ "${REAL_ROOT}" = '/' ]
+ then
+ got_good_root=1
+ mkdir -p ${NEW_ROOT}/mnt/cdrom
+ mkdir -p ${NEW_ROOT}/mnt/livecd
+ cp /image.squashfs ${NEW_ROOT}/mnt/cdrom
elif [ "${REAL_ROOT}" = '' ]
then
# No REAL_ROOT determined/specified. Prompt user for root block device. |
See my problem:
Quote: | patch < init.patch
patching file init
Hunk #1 FAILED at 370.
1 out of 1 hunk FAILED -- saving rejects to file init.rej
|
i'm paste your code in vim
Quote: |
opteron144 ramdisk # cat init.patch
*** init.orig 2007-05-09 08:23:52.000000000 -0700
--- init 2007-05-09 09:32:11.000000000 -0700
***************
*** 370,375 ****
--- 370,381 ----
got_good_root=0
continue
+ elif [ "${REAL_ROOT}" = '/' ]
+ then
+ got_good_root=1
+ mkdir -p ${NEW_ROOT}/mnt/cdrom
+ mkdir -p ${NEW_ROOT}/mnt/livecd
+ cp /image.squashfs ${NEW_ROOT}/mnt/cdrom
elif [ "${REAL_ROOT}" = '' ]
then
# No REAL_ROOT determined/specified. Prompt user for root block device.
|
thx for help me, and sorry for my English |
|
Back to top |
|
|
Raffi l33t
Joined: 17 Mar 2003 Posts: 731 Location: Moscow, Id.
|
Posted: Tue Oct 02, 2007 2:48 am Post subject: |
|
|
Try the -l option to patch. |
|
Back to top |
|
|
fabiim n00b
Joined: 18 Oct 2007 Posts: 2
|
Posted: Thu Oct 18, 2007 5:03 pm Post subject: |
|
|
I've tried :
Code: | root@black:~/ramdisk# patch -l < ../init.patch
missing header for context diff at line 3 of patch
patching file init
Hunk #1 FAILED at 370.
1 out of 1 hunk FAILED -- saving rejects to file init.rej
|
As you can see it gives me some error .
Anyway I "patched" it by hand and it did boot , i'm really thankful for your post .
|
|
Back to top |
|
|
solamour l33t
Joined: 21 Dec 2004 Posts: 726 Location: San Diego, CA
|
Posted: Mon Jun 09, 2008 7:02 am Post subject: |
|
|
It worked great with 2007.0-r1 release, but when I tried it on 2008.0-beta2, it didn't seem to find "image.squashfs" correctly. I'd appreciate any help.
__
sol |
|
Back to top |
|
|
Raffi l33t
Joined: 17 Mar 2003 Posts: 731 Location: Moscow, Id.
|
Posted: Mon Jun 09, 2008 11:56 am Post subject: |
|
|
I have not looked at any of the 2008 betas. I have been waiting for the final release. Can you find the image.squashfs on the cd? Did the location change? |
|
Back to top |
|
|
solamour l33t
Joined: 21 Dec 2004 Posts: 726 Location: San Diego, CA
|
Posted: Mon Jun 09, 2008 5:30 pm Post subject: |
|
|
"image.squashfs" is there, and "init" script didn't seem to be changed much as well. However, one thing that I noticed is that GRUB is used in 2008 beta, although I'm not certain how that would make things different. Anyhow, no big deal. I'm sure things would work out when the final version is released.
__
sol |
|
Back to top |
|
|
Raffi l33t
Joined: 17 Mar 2003 Posts: 731 Location: Moscow, Id.
|
Posted: Tue Jul 08, 2008 5:20 pm Post subject: |
|
|
I have posted a patch that will work for 2008.0. So far, I have edited the x86 version and things work. I will be doing the amd64 next. |
|
Back to top |
|
|
Raffi l33t
Joined: 17 Mar 2003 Posts: 731 Location: Moscow, Id.
|
Posted: Tue Jul 08, 2008 5:51 pm Post subject: |
|
|
Works for amd64 as well, but the name of the directory on that cd is boot instead of isolinux. |
|
Back to top |
|
|
richard.scott Veteran
Joined: 19 May 2003 Posts: 1497 Location: Oxfordshire, UK
|
Posted: Fri Nov 14, 2008 12:38 pm Post subject: |
|
|
Hi,
Is there a size limit on the final initramfs file?
Before copy in my squashfs image pxelinux can find it, and after it can't
Cheers,
Rich |
|
Back to top |
|
|
Raffi l33t
Joined: 17 Mar 2003 Posts: 731 Location: Moscow, Id.
|
Posted: Fri Nov 14, 2008 1:02 pm Post subject: |
|
|
I have not run into a size limit, how big is your file? Mine are around 60M. |
|
Back to top |
|
|
richard.scott Veteran
Joined: 19 May 2003 Posts: 1497 Location: Oxfordshire, UK
|
Posted: Fri Nov 14, 2008 2:09 pm Post subject: |
|
|
Raffi wrote: | I have not run into a size limit, how big is your file? Mine are around 60M. |
LOL, my initramfs file ends up being over 168M
My SquashFS file is around that size and works fine from a CD or USB stick
(I was hoping it would work via this method too) |
|
Back to top |
|
|
Raffi l33t
Joined: 17 Mar 2003 Posts: 731 Location: Moscow, Id.
|
Posted: Fri Nov 14, 2008 2:51 pm Post subject: |
|
|
Interesting. I would not have expected a size limit, but that is a lot of data. When you said it did not see it, I assume that means it says file not found or some such and does not try to load for a while and then stop.
It would be interesting for your to try to narrow down when it stops working. We have a data point at around 60M, if you can try something at that size and it still does not work, the size is not the issue. If it does, keep upping the size until it breaks. |
|
Back to top |
|
|
richard.scott Veteran
Joined: 19 May 2003 Posts: 1497 Location: Oxfordshire, UK
|
Posted: Fri Nov 14, 2008 2:58 pm Post subject: |
|
|
Raffi wrote: | Interesting. I would not have expected a size limit, but that is a lot of data. When you said it did not see it, I assume that means it says file not found or some such and does not try to load for a while and then stop.
It would be interesting for your to try to narrow down when it stops working. We have a data point at around 60M, if you can try something at that size and it still does not work, the size is not the issue. If it does, keep upping the size until it breaks. |
It's the pxelinux part that doesn't see the file. I get the Loading /kernel........ part and then the next line errors on not finding the /initramfs file.
I'll try using files from a LiveCD and increase the initramfs file to see when it does error again. I'll start at a 60MB file and work up |
|
Back to top |
|
|
richard.scott Veteran
Joined: 19 May 2003 Posts: 1497 Location: Oxfordshire, UK
|
Posted: Fri Nov 14, 2008 3:55 pm Post subject: |
|
|
Ah, apparently it seems that there is a limit of about 90MB for files when using atftpas your tftp server |
|
Back to top |
|
|
Raffi l33t
Joined: 17 Mar 2003 Posts: 731 Location: Moscow, Id.
|
Posted: Fri Nov 14, 2008 4:15 pm Post subject: |
|
|
That's good to know. I'm using tftp-hpa, I wonder if it has a similar limit or not. |
|
Back to top |
|
|
Raffi l33t
Joined: 17 Mar 2003 Posts: 731 Location: Moscow, Id.
|
Posted: Fri Nov 06, 2009 5:18 pm Post subject: |
|
|
I have updated the mini howto with a patch for the current minimal live cd. |
|
Back to top |
|
|
Raffi l33t
Joined: 17 Mar 2003 Posts: 731 Location: Moscow, Id.
|
Posted: Fri Apr 30, 2010 2:37 pm Post subject: |
|
|
Added another patch for latest minimal cd. |
|
Back to top |
|
|
Raffi l33t
Joined: 17 Mar 2003 Posts: 731 Location: Moscow, Id.
|
Posted: Tue Dec 14, 2010 4:26 pm Post subject: |
|
|
Another update for the latest cds |
|
Back to top |
|
|
Raffi l33t
Joined: 17 Mar 2003 Posts: 731 Location: Moscow, Id.
|
Posted: Tue Jul 17, 2012 2:01 pm Post subject: |
|
|
Added updated patch for latest minimal cds. |
|
Back to top |
|
|
Raffi l33t
Joined: 17 Mar 2003 Posts: 731 Location: Moscow, Id.
|
Posted: Thu May 09, 2013 9:11 pm Post subject: |
|
|
Added patch and directions for latest minimal iso |
|
Back to top |
|
|
solamour l33t
Joined: 21 Dec 2004 Posts: 726 Location: San Diego, CA
|
Posted: Fri Oct 18, 2013 7:40 pm Post subject: |
|
|
I tried "install-amd64-minimal-20131010.iso" and received the following message.
Code: | # zcat /mnt/cdrom/isolinux/gentoo.igz | cpio -ivmd
gzip: /mnt/cdrom/isolinux/gentoo.igz: not in gzip format
cpio: premature end of archive |
I guess it's because "gentoo.igz" is compressed with xz instead of gzip.
Code: | # file /mnt/cdrom/isolinux/gentoo.igz
/mnt/cdrom/isolinux/gentoo.igz: XZ compressed data
|
So I had to use "xzcat" instead of "zcat".
Code: | xzcat /mnt/cdrom/isolinux/gentoo.igz | cpio -ivmd |
__
sol |
|
Back to top |
|
|
|