Remote Booting Linux on Intel Processors (CERN Variant) Concurrent Technologies Plc. Application Engineering Technical Reference Remote Booting Linux on Intel Processors (CERN Variant) Subject: Remote booting a Concurrent Technologies Intel based processor board from another Concurrent Technologies Intel based processor board with Red Hat Linux. Date: March 3rd, 2005 Products Discussed: VME and CPCI Intel based processor boards with mass storage module (DS MSS/IFP24) or external drives.
Remote Booting Linux on Intel Processors (CERN Variant) • • • • Floppy drive Either Red Hat Linux 7.1, 7.2, 7.3, 8.0, 9.0, RHE3 Network connection between the Client and Server boards Keyboard, mouse and monitor Hardware Set-up Hardware set-up is quite simple. Just plug the Concurrent Technologies processor boards into a chassis.
Remote Booting Linux on Intel Processors (CERN Variant) • • 5. Install the TFTP server, “rpm -ivh $RPMSHOME/tftp-server-0.28-*.i386.rpm” While we are here, install some nice utilities that convert files from DOS to Unix format1, “rpm -ivh $RPMSHOME/dos2unix*.i386.rpm” To install the DHCP server download the latest server from ftp://ftp.isc.org/isc/dhcp/ and then download the software to the Red Hat machine and type the following, • • • • • • “gzip -d dhcp-latest.tar.gz” “tar -xf dhcp-latest.
Remote Booting Linux on Intel Processors (CERN Variant) } } host client2 { hardware ethernet 00:40:9E:00:FF:F1; fixed-address 192.67.84.172; server-name "192.67.84.170"; option host-name "Client2" option dhcp-message "192.67.84.170:/home/ClientLocalRootFs/client2/home"; #Checks vendor class for a PXE Client. if substring (option vendor-class-identifier, 0, 9) = "PXEClient" { filename "pxelinux.0"; } else { filename "LinuxBootImage.
Remote Booting Linux on Intel Processors (CERN Variant) • • 10. Install the NFS utilities, “rpm –ivh $RPMSHOME/nfs-utils-0.3.3-*.i386.rpm” To have the NFS start on boot type “chkconfig nfs on”. Create the NFS exports file “/etc/exports” with the following lines, /tftpboot/192.67.84.
Remote Booting Linux on Intel Processors (CERN Variant) • 14. “cp /root/syslinux-2.11/pxelinux.0 /tftpboot” The Syslinux boot loader will look for a client’s configuration file in the “/tftpboot/pxelinux.cfg” directory. The LILO style configuration file tells the boot loader, among other things, where the client’s kernel, and root file system file, if any, is located.
Remote Booting Linux on Intel Processors (CERN Variant) 2. Next we configure a basic kernel for the client based on the default settings, • • • • • Change in to the Linux source directory, “cd /usr/src/linux-2.4” Ensure the source tree is clean, “make mrproper” Edit the Makefile and change the EXTRAVERSION = to “EXTRAVERSION=Client”, where the is the original content, if any.
Remote Booting Linux on Intel Processors (CERN Variant) “mkdir /root/netboot” “cp /usr/src/linux/arch/i386/boot/bzImage /root/netboot” Configuring the root File System and Performing the Network Boot As well as a kernel, the Client also needs a root file system. There are several ways of serving up a root file system to the Client, we discuss three possibilities below and show how the kernel and root file system are put together to perform a network boot using Etherboot. NFS Only 1.
Remote Booting Linux on Intel Processors (CERN Variant) # Remove any modules in /tftpboot/$1/lib/modules # We don't need them in our example rm -rf /tftpboot/$1/lib/modules/* echo -n . # Next two steps are necessary to make the rfs fit into # the 64MB RamDisk, as used in the NFS+RamDisk rfs example # later.
Remote Booting Linux on Intel Processors (CERN Variant) done echo Done. 2. Now modify the lines in the following files, Edit “/tftpboot/192.67.84.171/etc/sysconfig/network” NETWORKING=yes HOSTNAME=”LinuxClient” Edit “/tftpboot/192.67.84.171/etc/sysconfig/network-scripts/ifcfg-eth0” … IPADDR=192.67.84.171 … Edit “/tftpboot/192.67.84.171/etc/fstab” to look like this, 192.67.84.170:/tftpboot/192.67.84.171 192.67.84.
Remote Booting Linux on Intel Processors (CERN Variant) 4. Reboot the client machine. It should execute a BOOTP or DHCP request, TFTP the boot image, and start the Linux kernel mounting its root file system from the Server with NFS. RamDisk Only (For Embedded Systems) 1. If the client needs to be run independently of the network then Linux maybe run entirely from RAM.
Remote Booting Linux on Intel Processors (CERN Variant) cp -a /lib/ld* /tftpboot/$1/lib cp -a /lib/libc-2* /tftpboot/$1/lib cp -a /lib/libc.so* /tftpboot/$1/lib echo -n . # Strip down the libraries for f in `find /tftpboot/$1/lib/ -type f`; do strip $f -o $f chmod 755 $f done echo -n . # Make the library .conf files ldconfig -r /tftpboot/$1 >& /dev/null # Copy the kernel.h file cp /boot/kernel.h /tftpboot/$1/boot echo -n .
Remote Booting Linux on Intel Processors (CERN Variant) mknod ttyS4 c 4 68 echo Done. 3. Creating the binary directories. Instead of the using the standard binary files in our RamDisk, as we did for the NFS example above, we will use a set of binaries that have been optimised for embedded systems. The standard set of binaries will occupy a good few megabytes of disk space. However, the optimised versions will occupy a mere few hundred kilobytes.
Remote Booting Linux on Intel Processors (CERN Variant) • • • • • • “cd /root/BusyBox/udhcp-0.9.8” “make” #Make the client and server “cp udhcpc /tftpboot/RamDiskFs/sbin” #Install the client “mkdir /tftpboot/RamDiskFs/etc/udhcpc” #Make client script directory “cp -a samples/* /tftpboot/RamDiskFs/etc/udhcpc” #Install client scripts Edit the “exec” line in the file “/tftpboot/RamDiskFs/etc/udhcpc/sample.script” to read, “exec /etc/udhcpc/sample.$1” • 7. “chmod 755 /tftpboot/RamDiskFs/etc/udhcpc/sample.
Remote Booting Linux on Intel Processors (CERN Variant) • • • “dos2unix /tftpboot/RamDiskFs/etc/init.d/rcN” “chmod 755 /tftpboot/RamDiskFs/etc/init.d/rcN” Cut and Paste the following and save it to “/tftpboot/RamDiskFs/etc/init.d/rcL” #!/bin/sh # This script will be executed after all the other initialisation scripts. You can put your own initialisation stuff here • • 9. “dos2unix /tftpboot/RamDiskFs/etc/init.d/rcL” “chmod 755 /tftpboot/RamDiskFs/etc/init.
Remote Booting Linux on Intel Processors (CERN Variant) How to create a PXE Image • • • Ensure the PXELINUX configuration files “/tftpboot/pxelinux.cfg/C04354AB” and “/tftpboot/pxelinux.cfg/C04354AB” have the correct “APPEND initrd=rootfs.gz root=/dev/ram rw” statement, or if you are using a board without a VGA adapter, or simply wish to use a serial console then use “APPEND console=ttyS0,9600 initrd=rootfs.gz root=/dev/ram rw” “cp /root/netboot/bzImage /tftpboot/” “cp /root/netboot/rootfs.
Remote Booting Linux on Intel Processors (CERN Variant) • • • • • 6. “umount /mnt/loop” “losetup -d /dev/loop0“ Compress the root file system file, • • 9. “cp -a /tftpboot/RamDiskFs/* /mnt/loop” Detach the root file system file, • • 8. Initialises the file system to zero Attach rootfs to loop device Create an EXT2 file system Make a mount directory Mount the root file system file Transfer the root file system created in the NFS section above into the mounted root file system file, • 7.
Remote Booting Linux on Intel Processors (CERN Variant) its functionality. First we must prepare the Server by adding and modifying a few files and directories on the Server. 2. Replace the NFS exports file “/etc/exports” with the following, # Exports Global Root and Diskless Clients # Global file system /home/ClientCommonRootFs/ *(ro,no_root_squash) #Diskless Clients /home/ClientLocalRootFs/client1 *(rw,no_root_squash) /home/ClientLocalRootFs/client2 *(rw,no_root_squash) 3.
Remote Booting Linux on Intel Processors (CERN Variant) 192.67.84.170:/home/ClientLocalRootFs/client2/etc 5. /etc nfs rw,lock 0 0 Upon boot the client will mount the directories specified in the “.fstab.global” and “.fstab.local” fstab files. The mount points must exist in the RamDisk and any directory in the existing root file system RamDisk bearing the same name as a mount point will be mounted over forming the client’s final root file system.
Remote Booting Linux on Intel Processors (CERN Variant) NOTE: The Ram disk built later in this section will configure all network devices. The above disables the Linux network-script from reconfiguring the network devices and avoids the possibility of the NFS root file system mount being lost.
Remote Booting Linux on Intel Processors (CERN Variant) echo -n Making Root File System template for $1. mkdir -p /tftpboot/$1 # Just make these ones for d in home mnt proc tmp usr root boot lib etc dev rootfs bin sbin do mkdir /tftpboot/$1/$d echo -n . done # And a var for d in `find /var -type d` do d=`echo $d | cut -c2-` mkdir /tftpboot/$1/$d done echo -n .
Remote Booting Linux on Intel Processors (CERN Variant) cp -a /lib/libattr* /tftpboot/$1/lib echo -n . # Copy the /etc/resolv.conf file cp -a /etc/resolv.conf /tftpboot/$1/etc echo -n . # Strip down the libraries for f in `find /tftpboot/$1/lib/ -type f`; do strip $f -o $f chmod 755 $f done echo -n . # Make the library .conf files ldconfig -r /tftpboot/$1 >& /dev/null # Copy the kernel.h file cp /boot/kernel.h /tftpboot/$1/boot echo -n .
Remote Booting Linux on Intel Processors (CERN Variant) echo -n . # Serial tty mknod ttyS0 c 4 64 mknod ttyS1 c 4 65 mknod ttyS2 c 4 66 mknod ttyS3 c 4 67 mknod ttyS4 c 4 68 echo -n . # Storage cp -af /dev/hd[abcd]* /dev/fd0* . # Set chmod's chmod 666 * 2&> /dev/null chmod 600 console echo Done. 8. Cut and Paste the following and save to files, • Save to “/tftpboot/ClientRamDisk/etc/inittab” # System initialisation. si::sysinit:/etc/init.
Remote Booting Linux on Intel Processors (CERN Variant) • • Edit the “exec” line in the file “/tftpboot/ClientRamDisk/etc/udhcpc/sample.script” to read, “exec /etc/udhcpc/sample.$1” “chmod 755 /tftpboot/ClientRamDiskFs/etc/udhcpc/sample.script” 11. In this example the client hostname and the client home directory information supplied by the DHCP server will be used to set the client’s hostname, update the “/etc/hosts” file, and mount the client’s home directory on “/home”.
Remote Booting Linux on Intel Processors (CERN Variant) ifconfig lo 127.0.0.1 ifconfig lo up # Start portmap /sbin/portmap # Configure Ethernet port and mount home file system through udhcpd and scipts for p in 0 1 do echo udhcpc attempting to configure eth$p udhcpc -n -i eth$p -s /etc/udhcpc/sample.script 2&> /dev/null done # Updating /etc/fstab file system if [ -f /home/.fstab.global ] then echo Updating /etc/fstab with /home/.fstab.global cat /home/.fstab.global >> /etc/fstab fi if [ -f /home/.fstab.
Remote Booting Linux on Intel Processors (CERN Variant) • • • • “losetup /dev/loop0 rootfs” “mkfs.ext2 -F -i 2000 rootfs” “mkdir /mnt/loop” “mount –o loop rootfs /mnt/loop” Attach rootfs to loop device Create an EXT2 file system Make a mount directory Mount the root file system file 15. Transfer the root file system into the mounted root file system file, • “cp -a /tftpboot/ClientRamDisk/* /mnt/loop” 16. Detach the root file system file, • • “umount /mnt/loop” “losetup -d /dev/loop0“ 17.
Remote Booting Linux on Intel Processors (CERN Variant) 8254x.img 21143.img 82559er.img flash.exe boot image for boards fitted with the 8254x Ethernet controller. boot image for boards fitted with 21143 Ethernet controller. boot image for boards fitted with 82559er Ethernet controller. DOS utility used to program the boot image into Flash memory.
Remote Booting Linux on Intel Processors (CERN Variant) (L)ocal : Boots an operation system image from Flash memory. • • Using the “Ramdisk and NFS example for multiple configurable servers and clients” example above. Press ‘s’ at the prompt perform to remote boot the “LinuxBootImage.nbi” via the network and save the download the image to Flash memory. Once the image has booted, reboot the system, and without pressing any keys, the “LinuxBootImage.nbi” will now boot from the Flash memory.
Remote Booting Linux on Intel Processors (CERN Variant) Appendix A: Client Kernel Configuration File3 CONFIG_X86=y CONFIG_UID16=y CONFIG_MODULES=y CONFIG_MODVERSIONS=y CONFIG_KMOD=y CONFIG_MPENTIUMIII=y CONFIG_X86_WP_WORKS_OK=y CONFIG_X86_INVLPG=y CONFIG_X86_CMPXCHG=y CONFIG_X86_XADD=y CONFIG_X86_BSWAP=y CONFIG_X86_POPAD_OK=y CONFIG_X86_L1_CACHE_SHIFT=5 CONFIG_RWSEM_XCHGADD_ALGORITHM=y CONFIG_X86_HAS_TSC=y CONFIG_X86_GOOD_APIC=y CONFIG_X86_PGE=y CONFIG_X86_USE_PPRO_CHECKSUM=y CONFIG_X86_F00F_WORKS_OK=y CON
Remote Booting Linux on Intel Processors (CERN Variant) CONFIG_E1000_NAPI=y CONFIG_VT=y CONFIG_VT_CONSOLE=y CONFIG_SERIAL=y CONFIG_SERIAL_CONSOLE=y CONFIG_UNIX98_PTYS=y CONFIG_UNIX98_PTY_COUNT=256 CONFIG_MOUSE=y CONFIG_PSMOUSE=y CONFIG_WATCHDOG=y CONFIG_AUTOFS4_FS=y CONFIG_EXT3_FS=y CONFIG_JBD=y CONFIG_FAT_FS=y CONFIG_MSDOS_FS=y CONFIG_VFAT_FS=y CONFIG_RAMFS=y CONFIG_JFS_FS=y CONFIG_NTFS_FS=y CONFIG_PROC_FS=y CONFIG_DEVPTS_FS=y CONFIG_EXT2_FS=y CONFIG_NFS_FS=y CONFIG_NFS_V3=y CONFIG_ROOT_NFS=y CONFIG_NFSD=