Saturday, February 05, 2005

Creating a bootable DOS partition from Linux

(or "how to flash the BIOS on your Debian box without a floppy drive, or CD-ROM drive or Windows partition or USB boot or anything like that...")

This can be done!!! :o)

I have a PC with no floppy & no CD-ROM, it is running Sarge and has a second (empty) hard disk.

I needed to boot in DOS so I could flash the BIOS.

Add this to grub's config ( /boot/grub/menu.lst - I instinctively type vi etc because it's a config file, then realise it's in /boot/grub because it's for booting and needs to be in the boot partition (if that's partitioned)) :

title FreeDOS Image
root (hd1,0)
kernel /memdisk
initrd (hd1,0)/fdos1440.img

Download: Memdisk:

  • http://syslinux.zytor.com/memdisk.php


    I got the newest one out of the SysLinux 3.07 download

  • http://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-3.07.tar.gz


    although if you apt-get install syslinux you get one too ( /usr/lib/syslinux/memdisk ) which you could use, but that's currently 2.11-0.1 or so.

    DOS floppy image:

  • http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/beta9sr1/fdos1440.img

    In Linux use fdisk (or cfdisk as I did) to create a small partition at the start of the empty disk (I did 8MB)


    Device Boot Start End Blocks Id System
    /dev/hdc1 * 1 1 8001 b W95 FAT32


    Use dosfstools mkfs.vfat to format the new partition:

    apt-get install dosfstools
    mkfs.vfat /dev/hdc1

    mount it:

    mkdir /mnt/hdc1
    mount /dev/hdc1 /mnt/hdc1

    copy memdisk and fdos1440.img and the flash program which you download from your hardware vendor into it:

    boot, choose FreeDOS Image, Choose 1:

    1->FreeDOS (speedup, 386+)

    Then choose 1:

    1) FreeDOS Beta9 ServiceRelease1 [2004-November-30]

    Then choose 2:

    2. FreeDOS Safe Mode (skip driver loading)

    ...and you should now find yourself at a nice little A:\>_ prompt :o)

    c:
    dir

    then there you are :o) You can now flash your BIOS because you are in native DOS.

    I'm wondering if you can use a loopback file within Linux as the root filesystem too, so you don't need a disk partition, now THAT would be scarey!!! :o)

    This guy needed a CD-ROM:

  • http://www.linuxsa.org.au/pipermail/linuxsa/2004-November/075117.html


    (wimp!)
  • Friday, February 04, 2005

    Power off on shutdown (with grub instead of LILO)

    To power off on shutdown in Linux you need to do two things...

    Firstly the kernel needs to know to do it, and secondly the apm module needs to be loaded.

    You load the module by adding the line:

    apm

    to /etc/modules

    (or by doing "modprobe apm" for a one-off)

    I'm used to doing it with LILO, but with grub telling the kernel to use it is a matter of addding "apm=on" to the end of the "kernel" line in /boot/grub/menu.lst, after all the other stuff.

    Thursday, February 03, 2005

    Upgrading from LILO to grub...

    After all these years of staying away from grub (for various reasons ... mainly because the one time I'd been confronted with it there was a box which wouldn't boot in a computer room, there wasn't time to research, I didn't know anything about it, I didn't like the name, and I didn't know where to start...) I tried upgrading a box after installing a new Sarge box which installs grub by default so I hade something to compare with as a working example...

    Installing it was as simple as doing:

    As simple as running:


    grub-install /dev/hda


    (mine was: grub-install --no-floppy /dev/hda )

    (You can also use (hd0) instead of /dev/hda I believe.)

    Then making /boot/grub/menu.lst

    I have:

    default 0

    timeout 3

    color cyan/blue white/blue

    title Debian GNU/Linux, kernel 2.4.27-2-686
    root (hd0,0)
    kernel /boot/vmlinuz-2.4.27-2-686 root=/dev/hda1 ro
    initrd /boot/initrd.img-2.4.27-2-686

    savedefault
    boot

    title Debian GNU/Linux, kernel 2.4.27-2-686 (recovery mode)
    root (hd0,0)
    kernel /boot/vmlinuz-2.4.27-2-686 root=/dev/hda1 ro single
    initrd /boot/initrd.img-2.4.27-2-686
    savedefault
    boot

    You can do this automatically on Debian with:


    update-grub

    Wednesday, December 29, 2004

    Burning an ISO image under Linux

    On my laptop with an internal CDROM:


    cdrecord -v -pad -tao -eject speed=8 dev=/dev/hdc sarge-i386-netinst.iso


    BTW:
    The image came from here: http://www.debian.org/devel/debian-installer/

    Or even just:


    cdrecord dev=/dev/cdrom sarge-i386-netinst.iso


    And this time I went for:

    http://cdimage.debian.org/pub/cdimage-testing/daily/i386/

    which fixed some problems I was having with the 2.6 kernel not wanting to mount the root image on my old 233MHz machine... (turning off things in the BIOS and managing to boot Knoppix under 2.6 let me know it was possible)

    Thursday, December 23, 2004

    Sea Pearl

    It's funny how I know quite a lot about the history of the C Language, but don't write very much C, and know comparatively little about the history of Perl and write a LOT in it...!!!

    I would love to be able to rattle off C programs the way I churn things out in Perl, but somehow I don't think that C really lends itself to that kind of development.

    There certainly are times I wish I could write something in C to get better performance out of it, but when I try I often get muddled with where I am at and am not sure if I'm going about things the right way.

    One day Conrad, I'll do the C course that you recommended I do (*cower* 10 years ago now!!!) which I still haven't done! :o(

    I sometimes wonder if Casey is still using C as much as he did back then, and if so, what kinds of things he's using it for...

    Thursday, December 16, 2004

    Xsession error: open: Permission denied


    Xsession: X session started for USER at Day Mon DD HH:MM:SS Zone YYYY
    open: Permission denied


    try:


    chmod 1777 /tmp



    Thursday, September 16, 2004

    Vim bits...

    Today I learned that if I want to run the current line as a command and get
    the output, all I have to do is:

    <Esc>yy!!<Ctrl-R>"<BS><Enter>

    :-) happy now!?

    Careful if you've got a % in the line...

    Vim documentation: cmdline

    I needed \% for the %20 in the URL I was passing out.

    The <BackSpace> was because it put a ^M on the end of the line.
    I could have just gone 0y$ instead of yy

    I just KNOW I'm going to use this one a lot!!!

    So you know, the secret engrdient here is ^R which puts the content of the
    un-named register on the command line.

    the other (unrelated) thing that I looked up and clarified was the :a (short for *:append*) command (and discovered that there's also :i (short for *:insert*) which can be read about with :he :a and :he :i :o) I discovered :a quite by accident a long time ago and use it when I want to paste in text and don't want it to be auto-indented (if it has tabs or indents in it - e.g. when pasting code)