[syslinux] disk image creation, step by step

Pascal Vandeputte pascal.vandeputte at intec.ugent.be
Wed May 2 09:25:25 PDT 2007


Hello,

I've been digging some more during the last couple of days, as no-one
has yet replied to my original e-mail I guess I'll do so myself.

I've progressed a little, but unfortunately I'm not there yet. At least
by starting out with the mkdiskimage tool I can perfectly convert an
ISO to a "disk image" which will boot the machine *if I put it on a USB
stick*.

My ISO file is 108MB large, so I create a 110MB disk image:
    # mkdiskimage -o -M ubcd403.img 110 16 63
    32256

Install boot loader:
    # /usr/local/syslinux-3.36/unix/syslinux -o 32256 ubcd403.img

Mount ISO and disk image:
    # losetup -o 32256 /dev/loop0 ubcd403.img
    # mkdir /tmp/iso /tmp/img
    # mount -o loop,ro ubcd403.iso /tmp/iso/
    # mount /dev/loop0 /tmp/img/

And copy the ISO contents:
    # cd /tmp/imag
    # cp -R /tmp/iso/* .

Unmount everything and detach disk image from loop device:
    # umount /tmp/img/ /tmp/iso
    # losetup -d /dev/loop0

So now I've got a nice ubcd403.img file. If I dd it to a flash drive
in /dev/sda I can perfectly boot the "Ultimate Boot CD" from it.

So I tend to think the disk image file itself is okay.

However, making it available through pxelinux as follows doesn't work:

    label ubcd
        kernel memdisk
        append initrd=images/test/ubcd403.img harddisk

The machine just hangs there at "Loading boot sector... booting..."
(See below for full output)


What am I doing wrong?


Best regards,

Pascal Vandeputte


P.S. In my original post, I pointed out that the image couldn't be
     transferred if it was 94371840 bytes in size. Apparently a
     collegue of mine had swapped out tftpd-hpa for atftpd on our
     file server. :((
     Grrrr...
     At least that problem is fixed now.


P.S. Full output for a 9MB disk image which works on a USB stick:

MEMDISK 3.36 2007-02-10  Copyright 2001-2007 H. Peter Anvin
e820: 0000000000000000 000000000009f400 1
e820: 000000000009f400 0000000000000c00 2
e820: 00000000000dc000 0000000000024000 2
e820: 0000000000100000 0000000005df0000 1
e820: 0000000005ef0000 000000000000f000 3
e820: 0000000005eff000 0000000000001000 4
e820: 0000000005f00000 0000000000100000 1
e820: 00000000fec00000 0000000000010000 2
e820: 00000000fee00000 0000000000001000 2
e820: 00000000fffe0000 0000000000020000 2
Ramdisk at 0x055f4000, length 0x008dc000
command line: initrd=images/test/ubcd403.img harddisk BOOT_IMAGE=memdisk
Disk is hard disk 0, 9072 K, C/H/S = 18/16/63, EDD on
Total size needed = 2412 bytes, allocating 3K
Old dos memory at 0x9f400 (map says 0x9f400), loading at 0x9e800
1588: 0xfff  15E801: 0x3c00 0x045f
INT 13 08: Success, count = 1, BPT = 0000:0000
old: int13 = ebeb25fc  int15 = f000f859
new: int13 = 9e800008  int15 = 9e800376
Loading boot sector... booting...





Pascal Vandeputte wrote:
> Hi,
>
> I am aware that it is impossible to netboot ISO files through 
> pxelinux/memdisk and that there are multiple reasons for not
> even attempting it (like the operating system which will try
> to access a physical optical drive through its own drivers
> anyway, BIOS issues etc.).
>
> When people ask questions regarding ISO support in
> pxelinux/memdisk, they're mostly told to convert the ISO into
> a "disk image" and boot it that way. We usually don't hear back
> from these people. Either they find it obvious how to do this
> and everything always works, or they don't even bother to try
> it.
>
> Unfortunately I don't find it that obvious at all. As far as I
> know it should be relatively straightforward if you can create
> a sufficiently large file, partition it, create the right
> filesystem, modify some OS config files and the bootloader. And
> create an MBR in that file while you're at it. Simple.
>
> A few days ago I needed to convert an ISO for installing FreeBSD
> on a lot of 1U boxes without an optical drive. For many Linux
> distros you can find a PXE version of the installer ready to
> download, but for FreeBSD converting the ISO seemed to be the
> easiest way to get started, as these are my first BSD steps.
>
> After a lot of googling and forum browsing, the only information I
> could find which effectively got the job done was an e-mail by Shaun
> Reitan on this mailing list:
>     http://syslinux.zytor.com/archives/2005-October/006076.html
> And even then it's a little hard to swallow if you're only used to
> Linux.
>
> I thought it would be a good idea to rewrite Shauns command listing
> into something which slightly resembles a howto and post it to this
> list. See below.
> Maybe the SYSLINUX project home page isn't the right place for howtos
> like this, but I feel that it should at least contain a pointer to
> a few examples.
>
> Enthousiastic about this first success, I'm eager to try it another
> time, now with a different ISO namely the "Ultimate Boot CD" which is
> even using ISOLINUX.
> I'm stuck however. I create a file with dd, attach it to loop0 with
> losetup, partition it (W95 FAT16 LBA?), re-attach it with the right
> offset for the first partition, format it (mkdosfs/mkfs.vfat), mount
> it and copy all files. But then I'm stuck. I need to write an MBR
> without ruining the partition table but I don't know how, and I
> probably need to do something with the isolinux.cfg file as well. But
> what?
>
> Does a howto, similar to the one below, exist?
>
> Another problem I get is that pxelinux doesn't find the disk image
> file as soon as it's 94371840 bytes large. 94370816 bytes is fine. The
> amount of allocated memory in VMWare doesn't seem to affect this.
>
>
> Best regards,
>
> Pascal Vandeputte
>
>
>
>
> ***********************************************************************
>
> How to create a PXE-bootable disk image of the FreeBSD "bootonly" 
> install ISO
> =======================================================================
> Based on an e-mail by Shaun Reitan on the SYSLINUX mailing list in
> October 2005.
> http://syslinux.zytor.com/archives/2005-October/006076.html
>
>
> The general idea:
> -----------------
> - transform the small "bootonly" ISO (which is intended to fetch all OS
>   files over the network) into a PXE-bootable harddisk image
> - make the first installation CD available on the network e.g. through NFS
>
> This howto only explains how to create the PXE-bootable image.
>
>
> - Download the "bootonly" installation ISO (about 25MB for FreeBSD 6.2)
>   e.g. 
> ftp://ftp.freebsd.org/pub/FreeBSD/releases/i386/ISO-IMAGES/6.2/6.2-RELEASE-i386-bootonly.iso
>
> - If case you haven't got a FreeBSD system running already, install BSD
>   somewhere temporarily using the first installation ISO (e.g. in VMWare).
>
> - Copy the "bootonly" ISO to your BSD system, e.g. using scp or WinSCP.
>
> - Find out how large you need to create your disk image:
>
>     # ls -al *.iso
>     -rw-r--r--  1 root  wheel  25444352 Apr 16 15:44 
> 6.2-RELEASE-i386-bootonly.iso
>
> - Create a file of the appropriate size (make it a little larger to
>   account for differences in block size, file system overhead etc.):
>
>     # dd if=/dev/zero of=6.2-RELEASE-i386-bootonly.img bs=1k count=26000    
>     26000+0 records in
>     26000+0 records out
>     26624000 bytes transferred in 1.404435 secs (18957091 bytes/sec)
>
>     # ls -al *.iso *.img
>     -rw-r--r--  1 root  wheel  26624000 Apr 27 03:28 
> 6.2-RELEASE-i386-bootonly.img
>     -rw-r--r--  1 root  wheel  25444352 Apr 16 15:44 
> 6.2-RELEASE-i386-bootonly.iso
>
> - Attach this image file as a memory disk:
>
>     # mdconfig -a -t vnode -f 6.2-RELEASE-i386-bootonly.img -u 0
>
> - Write a BSD label with boot code to it:
>
>     # bsdlabel -w -B md0 auto
>
> - And create a filesystem on it (BSD uses ufs):
>
>     # newfs -m 0 md0a
>     Warning: changing optimization to space because minfree is less than 8%
>     /dev/md0a: 25.4MB (51984 sectors) block size 16384, fragment size 2048
>             using 4 cylinder groups of 6.36MB, 407 blks, 832 inodes.
>     super-block backups (for fsck -b #) at:
>      160, 13184, 26208, 39232
>
> - Create a mount point and mount this "memory disk" device (attached to the
>   image file):
>
>     # mkdir /tmp/img
>     # mount /dev/md0a /tmp/img
>     # df /tmp/img   
>     Filesystem 1K-blocks Used Avail Capacity  Mounted on
>     /dev/md0a      24950    4 24946     0%    /tmp/img
>
> - Create another mount point and mount the ISO file on it through another md
>   device:
>
>     # mkdir /tmp/iso
>     # mdconfig -a -t vnode -f 6.2-RELEASE-i386-bootonly.iso -u 1
>     # mount_cd9660 /dev/md1 /tmp/iso
>     # df /tmp/iso
>     Filesystem 1K-blocks  Used Avail Capacity  Mounted on
>     /dev/md1       24848 24848     0   100%    /tmp/iso
>
> - Copy the ISO contents to the new disk image file:
>
>     # cd /tmp/img/
>     # cp -r /tmp/iso/* .
>     # ls -al
>     total 12
>     drwxr-xr-x  4 root  wheel      512 Apr 27 03:40 .
>     drwxrwxrwt  8 root  wheel      512 Apr 27 03:36 ..
>     drwxrwxr-x  2 root  operator   512 Apr 27 03:35 .snap
>     dr-xr-xr-x  5 root  wheel      512 Apr 27 03:40 boot
>     -r--r--r--  1 root  wheel     2048 Apr 27 03:40 boot.catalog
>     -r--r--r--  1 root  wheel       25 Apr 27 03:40 cdrom.inf
>
> - Unmount and detach all md devices:
>
>     # cd
>     # umount /tmp/img /tmp/iso
>     # mdconfig -d -u 0
>     # mdconfig -d -u 1
>
> - We're done. Copy the .img file to your tftp server.
>
>     # ls -al *.img *.iso
>     -rw-r--r--  1 root  wheel  26624000 Apr 27 03:41 
>                                   6.2-RELEASE-i386-bootonly.img
>     -rw-r--r--  1 root  wheel  25444352 Apr 16 15:44 
>                                   6.2-RELEASE-i386-bootonly.iso
>
> - And add something similar to this to your pxelinux.cfg/default file:
>
>     label freebsd62
>         kernel memdisk
>         append initrd=images/freebsd/6.2-RELEASE-i386-bootonly.img harddisk
>
> _______________________________________________
> SYSLINUX mailing list
> Submissions to SYSLINUX at zytor.com
> Unsubscribe or set options at:
> http://www.zytor.com/mailman/listinfo/syslinux
> Please do not send private replies to mailing list traffic.




More information about the Syslinux mailing list