[syslinux] syslinux versus pxelinux
Pascal Vandeputte
pascal.vandeputte at intec.ugent.be
Sun May 6 09:32:32 PDT 2007
Pascal Vandeputte wrote:
> [...] I'll mail details on
> how to create it in a later mail. (short on time right now)
Hello,
What follows is a howto on converting ISOLINUX ISO's into
PXE-bootable disk images.
I hope the provided information is correct and that this can be added
to the SYSLINUX wiki, just like the FreeBSD boot image howto earlier in
this thread.
Pascal Vandeputte's blood-and-tears-and-sleepless-nights howto
for creating a disk image of an ISOLINUX-based bootable ISO file/cd-rom
=======================================================================
But hindsight is 100%... so now it's not that hard at all :-)
We use the "Ultimate Boot CD" as an example of an ISOLINUX-based
bootable cd-rom. See www.ultimatebootcd.com
Versions used: UBCD 4.03
SYSLINUX 3.36
tftp-hpa 0.40-4.1 (Debian Sarge)
Date: 2007-05-06
1. Download the UBCD ISO file to a Linux box as well as the latest
version of SYSLINUX (see http://syslinux.zytor.com/download.php):
# cd /tmp && wget
http://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-3.36.tar.bz2
# cd /usr/local && tar jxf /tmp/syslinux-3.36.tar.bz2
# ls -alh /tmp | grep iso
-rw-r--r-- 1 root root 108M 2007-04-11 20:19 ubcd403.iso
If there's a SYSLINUX package available in the package manager of
your GNU/Linux distro, you'd better NOT use it because it's
likely to be outdated.
2. The ISO file is 108MB large, so we use the mkdiskimage tool to
create a disk image file which is slightly larger, 110MB:
# cd /tmp
# /usr/local/syslinux-3.36/mkdiskimage -o -M ubcd403.img 110 64 32
16384
The -M option makes mkdiskimage interpret the "cylinder count"
parameter (the "110") as the desired image size in MB instead, and
mkdiskimage will figure out the cylinder count by itself, given the
number of heads (64) and sectors (32).
So we use 64 heads and 32 sectors/track (= sectors/cylinder) (with
512 bytes/sector) and vary the number of cylinders to achieve a
certain disk image size. Some people use 16 heads and 63 sectors
per track which seems to work equally well but you end up with a
higher cylinder count.
We need the offset (16384) to be able to access the FAT partition
inside. See steps 3 and 4.
mkdiskimage has created a disk image with a partition table and a
single FAT16-formatted partition.
# ls -al *.iso *.img
-rw-r--r-- 1 root root 115343360 2007-05-04 16:09 ubcd403.img
-rw-r--r-- 1 root root 113141760 2007-04-11 20:19 ubcd403.iso
# fdisk -l -u ubcd403.img
You must set cylinders.
You can do this from the extra functions menu.
Disk ubcd403.img: 0 MB, 0 bytes
64 heads, 32 sectors/track, 0 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes
Device Boot Start End Blocks Id System
ubcd403.img1 * 32 225279 112624 6 FAT16
Note the start of the partition: sector 32 * 512 bytes = 16384, the
offset reported earlier.
The image already contains MBR boot code as well.
# file ubcd403.img
ubcd403.img: x86 boot sector
3. Install the SYSLINUX boot loader:
# /usr/local/syslinux-3.36/unix/syslinux -o 16384 ubcd403.img
syslinux must be pointed at a FAT partition, which is why we need to
specify the right offset here.
4. Attach the image file to a loop device, with the offset reported
by mkdiskimage in step 2. This is the only way to access the
FAT file system inside.
# losetup -o 16384 /dev/loop0 ubcd403.img
(on Ubuntu this may be /dev/loop/0 instead)
5. Mount the ISO file and the FAT file system in the disk image.
# mkdir /tmp/iso /tmp/img
# mount -o loop,ro ubcd403.iso /tmp/iso/
# mount /dev/loop0 /tmp/img/
There should be a file "ldlinux.sys" in the disk image already.
This is the bootloader. If it's missing in action, that means that
the syslinux command in step 3 was unsuccessful.
# cd /tmp/img/
# ls -al
total 27
drwxr-xr-x 2 root root 16384 1970-01-01 01:00 .
drwxrwxrwt 12 root root 1024 2007-05-02 16:48 ..
-r-xr-xr-x 1 root root 10092 2007-05-02 16:47 ldlinux.sys
6. Copy the ISO contents to the disk image (we're still in /tmp/img):
# cp -R /tmp/iso/* .
# ls -al
total 63
drwxr-xr-x 11 root root 16384 2007-05-04 18:07 .
drwxrwxrwt 6 root root 1024 2007-05-04 18:06 ..
-rwxr-xr-x 1 root root 59 2007-05-04 18:07 autorun.inf
drwxr-xr-x 2 root root 2048 2007-05-04 18:07 boot
-rwxr-xr-x 1 root root 2048 2007-05-04 18:07 boot.catalog
drwxr-xr-x 2 root root 2048 2007-05-04 18:07 custom
drwxr-xr-x 73 root root 6144 2007-05-04 18:07 dosapps
drwxr-xr-x 2 root root 4096 2007-05-04 18:07 images
drwxr-xr-x 2 root root 2048 2007-05-04 18:07 isolinux
-r-xr-xr-x 1 root root 10092 2007-05-04 18:06 ldlinux.sys
drwxr-xr-x 2 root root 2048 2007-05-04 18:07 menus
drwxr-xr-x 2 root root 2048 2007-05-04 18:07 syslinux
drwxr-xr-x 4 root root 2048 2007-05-04 18:07 tools
-rwxr-xr-x 1 root root 4382 2007-05-04 18:07 ubcd.ico
drwxr-xr-x 4 root root 4096 2007-05-04 18:07 website
The UBCD ISO already contains the "syslinux" folder with the boot
loader configuration file, no further action is required.
If there's no "syslinux" folder in your ISO, you probably need to
adapt the configuration you find in the "isolinux" folder or the
"isolinux.cfg" file in the root of the ISO. Just renaming the folder
and the file could be enough.
7. That's it. Unmount everything and detach the loop device from the
disk image file.
# cd ..
# umount /tmp/img/ /tmp/iso
# losetup -d /dev/loop0
8. Optional: you can test your image by writing it to a USB flash
drive:
# dd if=/tmp/ubcd403.img of=/dev/sda
And then try to boot from it. If this works, the image itself is
probably okay.
9. To netboot, put the file on your TFTP server and add something like
this to pxelinux.cfg/default (setting up a dhcp + tftp-hpa server
for network booting is not within the scope of this document):
label ubcd
kernel memdisk
append initrd=images/test/ubcd403.img harddisk noedd
The "noedd" option is needed for memdisk version 3.32 up to at
least 3.36, because of a bug which will probably be fixed in future
releases. Without that option the boot process will hang at
"Loading boot sector... booting...".
10. If you get a message that ubcd403.img cannot be found, while you're
absolutely certain that it's in the right location, check that you
are really using tftp-hpa and not aftpd as a TFTP service. The
latter chokes on files larger than 90MB.
Happy netbooting,
Pascal Vandeputte
More information about the Syslinux
mailing list