[syslinux] Bug in mkdiskimage of syslinux-2.06?

johnson johnson at feteco.com
Tue Nov 4 03:47:44 PST 2003


I am not sure if this is a bug in mkdiskimage in syslinux-2.06

[root at femto-server syslinux]# ls
copybs.com    isolinux-debug.bin  memdisk      pxelinux.0   syslinux.com
isolinux.bin  keytab-lilo.pl      mkdiskimage  sys2ansi.pl  syslinux.exe
[root at femto-server syslinux]# ./mkdiskimage tmp.img 64 4 63
[root at femto-server syslinux]# fdisk -l tmp.img
bash: fdisk: command not found
[root at femto-server syslinux]# /sbin/fdisk -l tmp.img
You must set cylinders.
You can do this from the extra functions menu.

Disk tmp.img: 5 heads, 63 sectors, 0 cylinders
Units = cylinders of 315 * 512 bytes

  Device Boot    Start       End    Blocks   Id  System
tmp.img1   *         1        52      8032+   4  FAT16 <32M                 -----------error? must to be 1 to 64
Partition 1 has different physical/logical endings:
     phys=(64, 4, 63) logical=(51, 0, 63)

[root at femto-server syslinux]# cat mkdiskimage

(begin)...........  
#////////////////////mkdiskimage orginal code here////////////////////////////////////////////////

$mbr .= "\0" x (446 - length($mbr));

print OUTPUT $mbr;

# Print partition table
$psize = $c*$h*$s-$s;
$bhead   = ($h > 1) ? 1 : 0;
$bsect   = 1;
$bcyl    = ($h > 1) ? 0 : 1;
$ehead   = $h;                             #--------------should be: $ehead=$h-1
$esect   = $s + (($c & 0x300) >> 2);    
$ecyl    = $c & 0xff;                      #--------------should be: $ecyl = ($c-1) & 0xff;
if ( $psize > 65536 ) {
    $fstype = 0x06;
} else {
    $fstype = 0x04;
}
print OUTPUT pack("CCCCCCCCVV", 0x80, $bhead, $bsect, $bcyl, $fstype,
                  $ehead, $esect, $ecyl, $s, $psize);
print OUTPUT "\0" x 48;
print OUTPUT "\x55\xaa";

.......(end)

///////////////////////////////code end////////////////////////////////////////////////////////

i think:
if your command line is "mkdiskimage tmp.img 64 4 63"
means that $c=64,$h=4,$s=63
means that there are 64 cylindars ,4 heads and 63 sectors per track.
so the cylindars number is from 0 to 63,and head from 0 to 3,but sector still from 1 to 63.

so i modify as following:

////////////////////////////////mkdiskimage code modified//////////////////////////////////////
(begin).......

# Print partition table
$psize = $c*$h*$s-$s;
$bhead   = ($h > 1) ? 1 : 0;
$bsect   = 1;
$bcyl    = ($h > 1) ? 0 : 1;
$ehead   = $h-1;
$esect   = $s + (($c & 0x300) >> 2);
$ecyl    = ($c-1)& 0xff;
if ( $psize > 65536 ) {
    $fstype = 0x06;
} else {
    $fstype = 0x04;
}
print OUTPUT pack("CCCCCCCCVV", 0x80, $bhead, $bsect, $bcyl, $fstype,
                  $ehead, $esect, $ecyl, $s, $psize);
print OUTPUT "\0" x 48;
print OUTPUT "\x55\xaa";

...............(end)


//////////////////////////////code end////////////////////////////////////////////////////////////

[root at femto-server syslinux]# mkdiskimage tmp.img -t 64 -h 4 -s 63
[root at femto-server syslinux]# /sbin/fdisk -l tmp.img
You must set cylinders.
You can do this from the extra functions menu.

Disk tmp.img: 4 heads, 63 sectors, 0 cylinders
Units = cylinders of 252 * 512 bytes

  Device Boot    Start       End    Blocks   Id  System
tmp.img1   *         1        64      8032+   4  FAT16 <32M

 




More information about the Syslinux mailing list