1) $cmd .= " skip=".($_GET['n']-1); } echo `$cmd 2> /dev/null`; exit; } ?> SliTaz Boot Floppies

Boot floppies builder

Shell builder Generic boot floppy
strtotime("-1 hour")) continue; system("rm -rf /tmp/$name"); } closedir($dir); function get_long($file, $offset) { $value = 0; if ($fp = fopen($file,"r")) { fseek($fp,$offset,SEEK_SET); for ($i = 0; $i < 32; $i += 8) { $value += ord(fgetc($fp)) << $i; } fclose($fp); } return $value; } function error($string, $title="Error") { echo <<
$title

$string

EOT; } $size = 0; $initrd_size = 0; $info_size = 0; // Upload kernel foreach($_FILES as $data) { $msg="The file ".$data['name']." "; switch ($data["error"]) { case UPLOAD_ERR_INI_SIZE : error($msg."exceeds upload_max_filesize."); break; case UPLOAD_ERR_FORM_SIZE : error($msg."exceeds max_post_size."); break; case UPLOAD_ERR_PARTIAL : error($msg."was only partially uploaded."); break; case UPLOAD_ERR_NO_TMP_DIR : error("Missing a temporary folder."); break; case UPLOAD_ERR_CANT_WRITE : error("Failed to write file to disk."); break; } } if (isset($_FILES["kernel"]['tmp_name']) && is_uploaded_file($_FILES["kernel"]['tmp_name'])) { $tmp_dir = tempnam('','fdbuild'); if (file_exists($tmp_dir)) unlink($tmp_dir); mkdir($tmp_dir); $tmp_dir .= '/'; move_uploaded_file($_FILES["kernel"]['tmp_name'], $tmp_dir."kernel"); $kernel = $tmp_dir."kernel"; $boot_version = get_long($kernel,0x206) & 255; if (get_long($kernel,0x202) != 0x53726448) // 'HdrS' magic $boot_version = 0; $size = get_long($kernel,0x1F4); // syssize paragraphs if ($boot_version < 4) $size &= 0xFFFF; // 16 bits before 2.4 $size = ($size + 0xFFF) & 0xFFFF000; // round up to 64K $size <<= 4; // paragraphs -> bytes $msg = "The size of the file ".$_FILES["kernel"]['name']; } if ($size && isset($_FILES["info"]['tmp_name']) && is_uploaded_file($_FILES["info"]['tmp_name'])) { move_uploaded_file($_FILES["info"]['tmp_name'], $tmp_dir."info"); $info_size = $_FILES["info"]['size']; } // Upload initrd if ($size) for ($i = 0; $i < count($_FILES["initrd"]['name']); $i++) if (isset($_FILES["initrd"]['tmp_name'][$i]) && is_uploaded_file($_FILES["initrd"]['tmp_name'][$i])) { move_uploaded_file($_FILES["initrd"]['tmp_name'][$i], $tmp_dir."initrd.".$i); $initrd_cmd .= " --initrd ".$tmp_dir."initrd.".$i; $initrd_size = $_FILES["initrd"]['size'][$i]; $size += $initrd_size; if ($i == 0) $msg = "The total size of the files ".$_FILES["kernel"]['name']. " and ".$_FILES["initrd"]['name'][$i]; else $msg .= ", ".$FILE["initrd"]['name'][$i]; } if ($initrd_size) for ($i = 0; $i < count($_FILES["initrd2"]['name']); $i++) if (isset($_FILES["initrd2"]['tmp_name'][$i]) && is_uploaded_file($_FILES["initrd2"]['tmp_name'][$i])) { move_uploaded_file($_FILES["initrd2"]['tmp_name'][$i], $tmp_dir."initrd2.".$i); $initrd2_cmd .= " --initrd ".$tmp_dir."initrd2.".$i; $initrd2_size = $_FILES["initrd2"]['size'][$i]; $size += $initrd2_size; $msg .= ", ".$FILE["initrd2"]['name'][$i]; } if ($size == 0) { if (isset($tmp_dir)) system("rm -f $tmp_dir"); } else { $cmd = "./bootloader ".$tmp_dir."kernel --prefix " . $tmp_dir."fd --format 0 --flags ".$_POST['flags'] . " --video ".$_POST['video']." --mem ".$_POST['ram']; if ($_POST['edit'] == "") $cmd .= " --dont-edit-cmdline"; if ($_POST['cmdline']) $cmd .= " --cmdline '".$_POST['cmdline']."'"; if ($info_size) $cmd .= " --info ".$tmp_dir."info"; if (file_exists($_POST['rdev'])) $cmd .= " --rdev ".$_POST['rdev']; if ($initrd_size) $cmd .= $initrd_cmd; if ($initrd2_size) $cmd .= $initrd2_cmd; switch ($_POST['size']) { case 1763328 : case 2015232 : case 3526656 : case 4030464 : $cmd .= " --tracks 82"; break; case 1784832 : $cmd .= " --tracks 83"; break; } shell_exec($cmd); $count = 1; if ($_POST['size'] != 0) { $count += (filesize($tmp_dir."fd") -1) / $_POST['size']; $padding = $_POST['size'] - (filesize($tmp_dir."fd") % $_POST['size']); } } $sizes = array( "368640" => "360 KB", "737280" => "720 KB", "1228800" => "1.20 MB", "1474560" => "1.44 MB", "1638400" => "1.60 MB", "1720320" => "1.68 MB", "1763328" => "1.72 MB", "1784832" => "1.74 MB", "1802240" => "1.76 MB", "1884160" => "1.84 MB", "1966080" => "1.92 MB", "2015232" => "1.96 MB", "2949120" => "2.88 MB", "3440640" => "3.36 MB", "3526656" => "3.44 MB", "3932160" => "3.84 MB", "4030464" => "3.92 MB", "0" => "no limit" ); function show_size($size) { global $sizes; if ($size != 0) return " ".$sizes[$size]; } ?>

Floppy image set builder

">
Linux kernel: required
Initramfs / Initrd: optional
Extra initramfs: optional
Boot message: optional
Default cmdline: /> edit optional
Root device: " />   Flags:   VESA:
Floppy size:   RAM used  
Note 1: $msg of files (kernel and initramfs) in memory.

Note 2: the extra initramfs may be useful to add your own configuration files.

Note 3: the keyboard is read for ESC or ENTER on every form feed (ASCII 12) in the boot message.

EOT; } else { ?>

Download image= 2) echo "s"; ?>

\n".floor($padding/1024)."KB padding.\n"; ?>

You can write floppies with SliTaz bootfloppybox, Windows rawrite or simply dd:

# dd if=fd001.img of=/dev/fd0

Start your computer with fd001.img. It will show the kernel version string and the kernel cmdline line. You can edit the cmdline. Most users can just press Enter.

= 2) { ?>

The floppy is then loaded into memory (one dot each 64K) and you will be prompted to insert the next floppy, fd002.img. And so on.

The floppy set detects disk swaps and can be used without a keyboard.

Good luck.

How does it work?

This tool updates the boot sector of your kernel with this code. You may add a default cmdline and an initramfs. The cmdline can be edited at boot time but the keyboard is not mandatory. A standalone version is available to break the web server upload limit.

Each part (boot, setup, boot message, cmdline, kernel, initramfs) is aligned to 512 bytes. The result is split to fit the floppy size. The last floppy image is padded with zeros.

You can extract the kernel, cmdline and rootfs files with this tool from the floppy images.