Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
PXE Boot into LiveCD over network without using NFS
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Lightspeed
n00b
n00b


Joined: 21 Feb 2003
Posts: 57
Location: UK

PostPosted: Sat Mar 20, 2004 1:53 am    Post subject: PXE Boot into LiveCD over network without using NFS Reply with quote

So long as the systems on which Gentoo is to be installed have enough RAM, it is possible to alter the initrd file from the LiveCD so that it already contains the entire root filesystem, so that it is then run from RAM rather than either mounting from the CD or attempting to mount over NFS.

Assuming you have a copy of the "install-x86-minimal-2004.0.iso" somewhere, here is how to achieve this:

Code:

mount -o loop,ro install-x86-minimal-2004.0.iso /mnt/cdrom
cp /mnt/cdrom/isolinux/gentoo.igz gentoo.gz
gunzip gentoo.gz
mkdir /mnt/gentoo /mnt/initrd
mount -o loop,ro gentoo /mnt/gentoo
dd if=/dev/zero of=initrd bs=1024 count=165000
mke2fs -m0 initrd 165000
mount -o loop initrd /mnt/initrd
cp -a /mnt/gentoo/* /mnt/initrd/
mkdir -p /mnt/initrd/newroot/dev
mkdir -p /mnt/initrd/newroot/mnt/cdrom
mkdir /mnt/initrd/newroot/mnt/livecd
mkdir /mnt/initrd/newroot/mnt/gentoo
mkdir -p /mnt/initrd/newroot/tmp/.initrd
cp -a /mnt/cdrom/zisofs /mnt/initrd/newroot/mnt/cdrom/

# remove cd specific stuff from linuxrc, see below for details
nano -w /mnt/initrd/linuxrc

# remove remount rw stuff from checkroot, see below for details
nano -w /mnt/initrd/etc/init.d/checkroot

umount /mnt/initrd
cp initrd initrd2
gzip initrd2
/sbin/splash -s -f /mnt/cdrom/zisofs/etc/bootsplash/livecd-2004.0/config/bootsplash-1024x768 >> initrd2.gz
mv initrd2.gz gentoo.igz


The parts of the two files that I mentioned above as requiring alteration are shown here (the changes being all the commented out lines):

linuxrc
Code:

.
.
.

# mkdir /newroot
if [ "${CDROOT}" -eq "1" ]
then
   # mount -t tmpfs tmpfs /newroot
   #mkdir /newroot/dev /newroot/mnt /newroot/mnt/cdrom /newroot/mnt/livecd /newroot/tmp /newroot/tmp/.initrd /newroot/mnt/gentoo
   [ ! -e /newroot/dev/.devfsd ] && mount -t devfs devfs /newroot/dev
   devfsd /newroot/dev -np
   sleep 1

   # findcdmount /newroot/dev/cdroms/*
   # not in /dev/cdroms try /dev/ide/cd
   # if [ "${REAL_ROOT}" = "" ]
   # then
      # findcdmount /newroot/dev/ide/cd/*
   # fi


   # if [ "${REAL_ROOT}" = "" ]
   # then
      # echo "Dropping to shell so you can fix your shit"
      # exec /bin/ash

      # Undo stuff      
      # kill_devfsd # We run devfsd with -np now
      # sleep 1
      # umount /newroot/dev/
      # sleep 1
      # umount /newroot
      # shouldn't be anything in here b/c it was on tmpfs
      # rm -rf /newroot/*
      # CDROOT=0
      # echo "Could not find CD to boot, gonna need something else"
   # fi
fi

.
.
.

echo "STEP 4: Determining root device"

# while true
# do
   # while [ "${got_good_root}" != "1" ]
   # do
      
      # if [ "${REAL_ROOT}" = "shell" ]
      # then
         # /bin/ash

         #set REAL_ROOT to "" so we get a prompt for the real root after the shell exits.
         # REAL_ROOT=""
         # got_good_root=0
         # continue
      # elif [ "${REAL_ROOT}" = "" ]
      # then
         #no REAL_ROOT determined/specified. Prompt user for root block device.
         # echo "Root block device unspecified or not detected."
         # echo "Please specify a device to boot, or \"shell\" for a shell."
         # echo -n ": "
         # read REAL_ROOT
         # got_good_root=0
      # elif [ -b "${REAL_ROOT}" ]
      # then
         # got_good_root=1
      # else
         # REAL_ROOT=""
         # got_good_root=0
      # fi
   # done


   # if [ "${CDROOT}" -eq "1" -a "${got_good_root}" = "1" ]
   # then
      # break
   # else
      # echo "STEP 4a: Mounting root"

      # mount -o rw ${REAL_ROOT} /newroot
      # if [ "$?" = "0" ]
      # then
         # break
      # else
         # echo "Could not mount specified ROOT, try again"
         # got_good_root=0
         # REAL_ROOT=""
      # fi
   # fi
# done

.
.
.


checkroot
Code:

.
.
.

   # Should we mount root rw ?
   # if mount -vf -o remount / 2> /dev/null | \
         # awk '{ if ($6 ~ /rw/) exit 0; else exit 1; }'
   # then
      # ebegin "Remounting root filesystem read/write"
      # mount / -n -o remount,rw &>/dev/null
      # if [ "$?" -ne 0 ]
      # then
         # eend 2 "Root filesystem could not be mounted read/write :("
         # /sbin/sulogin ${CONSOLE}
      # else
         # eend 0
      # fi
   # fi

.
.
.


The resulting "gentoo.igz" file can then be used instead of the original one from the LiveCD, simply by adding the kernel parameter "ramdisk_size=165000". The exact same procedure can be used to alter the smp.igz initrd as well.

Amongst other potential uses, this method can be used to trick a Microsoft RIS (Remote Installation Services) system into deploying a Gentoo LiveCD environment instead of a scripted Windows install :D

Here is how to do that...

First ensure that RIS is properly installed and working (ie make sure it is already capable of deploying Windows installs).
Inside the RIS machine's "\\SERVER\REMINST" share, create the necessary folders for the following directory to exist: "\\SERVER\REMINST\Setup\English\Images\gentoo\i386\templates\".
Copy everything except the two "isolinux.*" files and the two "*.igz" files from the "isolinux" subdirectory of the 2004.0 LiveCD into this folder.
Also create the folder "\\SERVER\REMINST\Setup\English\Images\gentoo\i386\templates\pxelinux.cfg\" and copy "isolinux.cfg" from the "isolinux" subdirectory of the LiveCD to this directory, then rename it to "default".
Edit this file by adding "ramdisk_size=165000" to each of the four sets of kernel parameters.
Copy your modified "gentoo.igz" and "smp.igz" files into "\\SERVER\REMINST\Setup\English\Images\gentoo\i386\templates\".
Download the latest version of syslinux from http://www.kernel.org/pub/linux/utils/boot/syslinux/, extract it, and copy the "pxelinux.0" file into "\\SERVER\REMINST\Setup\English\Images\gentoo\i386\templates\".
Now make up a skeletal "ristndrd.sif" file inside "\\SERVER\REMINST\Setup\English\Images\gentoo\i386\templates\" with the following contents:

Code:

[OSChooser]
Description ="Gentoo Linux 2004.0"
Help ="Boots the Gentoo Linux Live CD."
LaunchFile = "%INSTALLPATH%\%MACHINETYPE%\templates\pxelinux.0"
ImageType =Flat
Version="2004.0"


Finally, restart the RIS service using "net stop binlsvc" followed by "net start binlsvc".

You can now install Gentoo from the MS RIS system! Enjoy :)

Perhaps coupled with something along the lines of GLIS, RIS could then deliver a scripted Gentoo install as well, just as it does for Windows.
Back to top
View user's profile Send private message
Kalin
Tux's lil' helper
Tux's lil' helper


Joined: 22 Dec 2002
Posts: 122
Location: Germany

PostPosted: Tue Sep 07, 2004 3:30 pm    Post subject: New HOWTO:Use LiveCD in PXE booting environment Reply with quote

Hello,

I used your post as a starting point and updated quite a few things...
Plese have a look at https://forums.gentoo.org/viewtopic.php?p=1512026
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum