#!/bin/bash # a small shell script to: # 1) make a simple asm program # 2) compile that program with `nasm' # 3) convert resulting .bin to a .img with `dd' # 4) boot the reulting "hello.img" with qemu/kvm # I think this qualifies as a bootloader, sort of # sincerely hope it helps address Mr. Guilmette curiousity # -chris graff printf ' BITS 16 jmp main nop main: mov ax, 07C0h add ax, 288 mov ss, ax mov sp, 4096 mov ax, 07C0h mov ds, ax call PrintHelloWorld jmp .InfiniteLoop .InfiniteLoop: jmp .InfiniteLoop HelloWorld db "Hello World Bootloader !!", 0x0d, 0x0a, 0x00 PrintHelloWorld: mov si, HelloWorld call PrintStr ret PrintStr: push ax mov ah, 0Eh .loop: lodsb cmp al, 0x00 je .done int 10h jmp .loop .done: pop ax ret times 510-($-$$) db 0 dw 0xAA55 ' > hello.asm nasm -f bin -o hello.bin hello.asm dd status=noxfer conv=notrunc if=hello.bin of=hello.img kvm hello.img On Sun, Jan 19, 2014 at 5:29 PM, Ronald F. Guilmette <rfg at tristatelogic.com>wrote:> > In message <BLU0-SMTP48EE10402F4B5AE9EC1E078BBB0 at phx.gbl>, Ady wrote: > > >After dd'ing my test.img to the USB drive, you would have one FAT32 > >partition of about 700MB. So: > > Someone in this thread said something about erasing or eliminating > stuff from the USB stick first, so just to be on the safe side, before > I dd'd your test.img file to my test stick (i.e. one of my 2GB > Sandisk Cruzer Blades that was failing to boot Clonezilla even > before I started this thread), I first dd'd /dev/zero to the stick > until dd hit physical EOF on the stick. > > >1_ Expand the content of the Clonezilla Live zip archive in some > >temporal directory. > > > >2_ Move *almost* all the resulting expanded content from the temporal > >directory to the FAT32 partition in the USB drive; with the > >*exception* of the following directories (and their contents, of > >course): > >2a_ './isolinux/' > >2b_ './syslinux/' > > Note: I mis-spoke earlier when I made reference to using ntfs-3g to > access the stick. (Duh!) As you say, once the stick has your test.img > file on it, it contains a FAT32 filesystem, not NTFS. So I can access > it from FreeBSD simply by mounting it with "-t msdosfs". > > Fdisk on FreeBSD appears to confirm that the stick is how you wished > and expected it to be: > > ===================================================================> ******* Working on device /dev/da2 ******* > parameters extracted from in-core disklabel are: > cylinders=243 heads=255 sectors/track=63 (16065 blks/cyl) > > parameters to be used for BIOS calculations are: > cylinders=243 heads=255 sectors/track=63 (16065 blks/cyl) > > Media sector size is 512 > Warning: BIOS sector numbering starts with sector 1 > Information from DOS bootblock is: > The data for partition 1 is: > sysid 12 (0x0c),(DOS or Windows 95 with 32 bit FAT (LBA)) > start 2048, size 1431552 (699 Meg), flag 0 > beg: cyl 0/ head 32/ sector 33; > end: cyl 89/ head 60/ sector 35 > The data for partition 2 is: > <UNUSED> > The data for partition 3 is: > <UNUSED> > The data for partition 4 is: > <UNUSED> > ===================================================================> > >Note that my test.img already contains a './syslinux/' directory with > >some files in it. > > Yes, and at the top level it apparently contains _only_ that. > > >3_ Move (part of) the content of Clonezilla's temporal './syslinux/' > >directory to the equivalent './syslinux/' directory located in the > >FAT32 partition in the USB drive, with two *caveats*: > > > >3a_ If the filename already exists in the destination directory, > >*keep it*, do > >*NOT* replace it with the one from Clonezilla. This is specially > >important for > >'./syslinux/ldlinux.sys'. > > > >3b_ The only file from Clonezilla's temporal directory that indeed > >should > >replace the one already placed in the USB drive is > >'./syslinux/syslinux.cfg'. > > Below are directory listings of (a) /syslinux/ on the test stick after > your test.img file has been copied to it and (b) /syslinux/ as it > exists within the (unziped) clonezilla-live-2.2.1-22-amd64.zip file: > > (a) > =========================================================================> -rwxr-xr-x 1 root wheel 1652 Dec 11 02:08 cat.c32 > -rwxr-xr-x 1 root wheel 24040 Dec 11 02:08 chain.c32 > -rwxr-xr-x 1 root wheel 1256 Dec 11 02:08 cmd.c32 > -rwxr-xr-x 1 root wheel 1500 Dec 11 02:07 config.c32 > -rwxr-xr-x 1 root wheel 1592 Dec 11 02:08 debug.c32 > -rwxr-xr-x 1 root wheel 1996 Dec 11 02:07 disk.c32 > -rwxr-xr-x 1 root wheel 173060 Dec 11 02:08 hdt.c32 > -rwxr-xr-x 1 root wheel 1524 Dec 11 02:08 hello.c32 > -rwxr-xr-x 1 root wheel 3692 Dec 11 02:08 hexdump.c32 > -r-xr-xr-x 1 root wheel 122080 Jan 16 14:40 ldlinux.c32 > -r-xr-xr-x 1 root wheel 67072 Jan 16 14:40 ldlinux.sys > -rwxr-xr-x 1 root wheel 186452 Dec 11 02:07 libcom32.c32 > -rwxr-xr-x 1 root wheel 66548 Dec 11 02:07 libgpl.c32 > -rwxr-xr-x 1 root wheel 112908 Dec 11 02:08 liblua.c32 > -rwxr-xr-x 1 root wheel 24056 Dec 11 02:08 libmenu.c32 > -rwxr-xr-x 1 root wheel 24156 Dec 11 02:07 libutil.c32 > -rwxr-xr-x 1 root wheel 4660 Dec 11 02:08 linux.c32 > -rwxr-xr-x 1 root wheel 2948 Dec 11 02:08 ls.c32 > -rwxr-xr-x 1 root wheel 2432 Dec 11 02:08 meminfo.c32 > -rwxr-xr-x 1 root wheel 26568 Dec 11 02:08 menu.c32 > -rwxr-xr-x 1 root wheel 1504 Dec 11 02:08 pwd.c32 > -rwxr-xr-x 1 root wheel 13768 Dec 11 02:08 rosh.c32 > -rwxr-xr-x 1 root wheel 56 Jan 16 14:27 syslinux.cfg > -rwxr-xr-x 1 root wheel 27076 Dec 11 02:08 vesamenu.c32 > -rwxr-xr-x 1 root wheel 2460 Dec 11 02:08 whichsys.c32 > =========================================================================> > (b) > =========================================================================> -rw-r--r-- 1 rfg rfg 24040 Dec 11 02:08 chain.c32 > -rw-r--r-- 1 rfg rfg 43283 Aug 12 2012 drblwp.png > -rw-r--r-- 1 rfg rfg 122080 Dec 11 02:07 ldlinux.c32 > -rw-r--r-- 1 rfg rfg 186452 Dec 11 02:07 libcom32.c32 > -rw-r--r-- 1 rfg rfg 24156 Dec 11 02:07 libutil.c32 > -rw-r--r-- 1 rfg rfg 26140 Dec 26 03:25 memdisk > -rw-r--r-- 1 rfg rfg 26568 Dec 11 02:08 menu.c32 > -rw-r--r-- 1 rfg rfg 46464 Aug 12 2012 ocswp.png > -rw-r--r-- 1 rfg rfg 6503 Jan 6 05:52 syslinux.cfg > -rw-r--r-- 1 rfg rfg 27076 Dec 11 02:08 vesamenu.c32 > =========================================================================> > I elected to accomplish your step 3a by first cd'ing into the /syslinux/ > directory of the unzipped Clonezilla and then executing the command: > > find * -print | cpio -pvm /mnt/syslinux > > where /mnt/syslinux is/was the /syslinux/ directory on the test stick. > The results of doing this were as follows, which I hope is what you > wanted: > > ========================================================================> /mnt/syslinux/chain.c32cpio: chain.c32: File on disk is not older; > skipping. > /mnt/syslinux/drblwp.png > /mnt/syslinux/ldlinux.c32cpio: ldlinux.c32: File on disk is not older; > skipping. > /mnt/syslinux/libcom32.c32cpio: libcom32.c32: File on disk is not older; > skipping. > /mnt/syslinux/libutil.c32cpio: libutil.c32: File on disk is not older; > skipping. > /mnt/syslinux/memdisk > /mnt/syslinux/menu.c32cpio: menu.c32: File on disk is not older; skipping. > /mnt/syslinux/ocswp.png > /mnt/syslinux/syslinux.cfgcpio: syslinux.cfg: File on disk is not older; > skipping. > /mnt/syslinux/vesamenu.c32cpio: vesamenu.c32: File on disk is not older; > skipping. > ========================================================================> > I elected to carry out your step 3b via the following command: > > find * -name syslinux.cfg -print | cpio -pvmu /mnt/syslinux > > Following these steps, the /syslinux/ directory on the stick is as follows: > > > ============================================================================> -rwxr-xr-x 1 root wheel 1652 Dec 11 02:08 cat.c32 > -rwxr-xr-x 1 root wheel 24040 Dec 11 02:08 chain.c32 > -rwxr-xr-x 1 root wheel 1256 Dec 11 02:08 cmd.c32 > -rwxr-xr-x 1 root wheel 1500 Dec 11 02:07 config.c32 > -rwxr-xr-x 1 root wheel 1592 Dec 11 02:08 debug.c32 > -rwxr-xr-x 1 root wheel 1996 Dec 11 02:07 disk.c32 > -rwxr-xr-x 1 root wheel 43283 Aug 12 2012 drblwp.png > -rwxr-xr-x 1 root wheel 173060 Dec 11 02:08 hdt.c32 > -rwxr-xr-x 1 root wheel 1524 Dec 11 02:08 hello.c32 > -rwxr-xr-x 1 root wheel 3692 Dec 11 02:08 hexdump.c32 > -r-xr-xr-x 1 root wheel 122080 Jan 16 14:40 ldlinux.c32 > -r-xr-xr-x 1 root wheel 67072 Jan 16 14:40 ldlinux.sys > -rwxr-xr-x 1 root wheel 186452 Dec 11 02:07 libcom32.c32 > -rwxr-xr-x 1 root wheel 66548 Dec 11 02:07 libgpl.c32 > -rwxr-xr-x 1 root wheel 112908 Dec 11 02:08 liblua.c32 > -rwxr-xr-x 1 root wheel 24056 Dec 11 02:08 libmenu.c32 > -rwxr-xr-x 1 root wheel 24156 Dec 11 02:07 libutil.c32 > -rwxr-xr-x 1 root wheel 4660 Dec 11 02:08 linux.c32 > -rwxr-xr-x 1 root wheel 2948 Dec 11 02:08 ls.c32 > -rwxr-xr-x 1 root wheel 26140 Dec 26 03:25 memdisk > -rwxr-xr-x 1 root wheel 2432 Dec 11 02:08 meminfo.c32 > -rwxr-xr-x 1 root wheel 26568 Dec 11 02:08 menu.c32 > -rwxr-xr-x 1 root wheel 46464 Aug 12 2012 ocswp.png > -rwxr-xr-x 1 root wheel 1504 Dec 11 02:08 pwd.c32 > -rwxr-xr-x 1 root wheel 13768 Dec 11 02:08 rosh.c32 > -rwxr-xr-x 1 root wheel 6503 Jan 6 05:52 syslinux.cfg > -rwxr-xr-x 1 root wheel 27076 Dec 11 02:08 vesamenu.c32 > -rwxr-xr-x 1 root wheel 2460 Dec 11 02:08 whichsys.c32 > > ============================================================================> > >Then boot the USB drive (using F12 during POST as before). I would > >expect at least the initial Clonezilla boot menu to show up. > > I umounted /mnt, removed the test stick and stuck it into one of the rear > USB 2.0 ports on the GA-M55Plus-S3G, then powered that on. (No other mass > storage devices were attached.) > > I forgot (the first time) to use F12 as you requested, so the system just > booted normally. > > The Clonezilla boot menu *did* show up. > > I then went back and used F12 as you requested. > > In this case also, the Clonezilla boot menu *did* show up. > > I assume this all represents success. > > Are we done now? > > > Regards, > rfg > > > P.S. It is my sincere hope that we did not go through all of this just so > that you could tell me "Hey Ron! This is the (convoluted) procedure you > must > use if you want to boot Clonezilla, ever, on that motherboard." > > All these experiments will result in improvements to Syslinux that will, in > due course, make it out to the developers of Clonezilla and UBCD and > OpenELEC, > yes? > _______________________________________________ > 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. > >
Ronald F. Guilmette
2014-Jan-20 00:33 UTC
[syslinux] USB boot problems on Gigabyte GA-M55Plus-S3G
In message <CAL9Ac2TasS6RfoC5i-oeOh32r+h0QBpVCSNhQMG1MN_KmAr6mw at mail.gmail.com> Dean Graff <graff97 at gmail.com> wrote:># I think this qualifies as a bootloader, sort of ># sincerely hope it helps address Mr. Guilmette curiousityYes. Thank you. It had not occurred to me that ye good olde BIOS is/was still there, and that it could actually be relied upon to do useful things, you know, after boot time. (So many OSes make it a point to get up and running and to _avoid_, as much as possible, any & all use of BIOS I/O routines that it is easy for forget that in limited contexts they are, nontheless, actually still useful.) Regards, rfg
#!/bin/sh # Make a simple linux installation from scratch, # which boots to login, on a "hard disk image" # Maybe Mr.Alvin or Gene could show how to boot it # with asm. thanks, -chris graff y="$(pwd)" # set absolute path x="${y}/build" # set absolute path to "build" dir mkdir -p "${x}" # make that "build" dir JOBZ="-j$(grep -c ^processor /proc/cpuinfo)" # set ideal num of jobs dd if=/dev/zero of=binary.img bs=1M count=150 mkfs.ext4 -F binary.img sudo mount binary.img "${x}" mkdir -p "${x}"/dev "${x}"/proc "${x}"/boot "${x}"/etc "${x}"/root git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git make -C linux menuconfig make -C linux $JOBZ make -C linux INSTALL_MOD_PATH="${x}" modules_install make -C linux install INSTALL_PATH="${x}/boot" 2>/dev/null ln "${x}"/boot/vmlinuz* "${x}"/boot/vmlinuz git clone git://git.kernel.org/pub/scm/boot/syslinux/syslinux.git make -C syslinux $JOBZ git clone git://busybox.net/busybox.git make -C busybox defconfig sed -i 's|# CONFIG_STATIC is not set|CONFIG_STATIC=y|g' busybox/.config make -C busybox $JOBZ make -C busybox CONFIG_PREFIX="${x}" install cat > "${x}"/etc/inittab << EOF null::sysinit:/bin/mount -t proc proc /proc null::sysinit:/bin/mount -o remount,rw / null::sysinit:/bin/mkdir -p /dev/pts null::sysinit:/bin/mkdir -p /dev/shm null::sysinit:/bin/mount -a null::sysinit:/bin/hostname -F /etc/hostname tty1::respawn:/sbin/getty -L tty1 115200 vt100 null::shutdown:/bin/umount -a -r null::shutdown:/bin/swapoff -a EOF cat > "${x}"/etc/fstab << EOF proc /proc proc defaults 0 0 EOF cat > "${x}"/etc/hostname << EOF blank EOF cat > "${x}"/etc/passwd << EOF root::0:0:root:/root:/bin/ash EOF sudo ./syslinux/extlinux/extlinux --install "${x}" cat > "${x}"/extlinux.conf << EOF default linux label linux kernel /boot/vmlinuz append init=/sbin/init root=/dev/sda rw EOF sudo umount "${x}" kvm binary.img # boot the resulting image