Ubuntu 10.04 install from USB

In the process of developing tools for Linux systems, I built a new USB stick install for Ubuntu 10.04. The process of creating it is very simple and can be Googled. What surprised me is that when I installed a new version on a laptop, it booted to the USB pen drive in about 10 seconds and was installed within 15 minutes with very little interaction. One of the things that can be a problem is the USB single byte bug and I have not gotten enough information yet to see why that happens on some machines and makes the boot from USB very slow. It also provides a way to diagnose system problems with disks when the system goes awry.

I recently had a disk drive that was failing and the new utility "palimpsest" is incredible and can interact with the "SMART" features of drives to indicate potential failures or diagnose disk problems. It is a wonderful utility that has added lots of new functionality and ease of use recently.

I have gone away from the KDE desktop recently, but some of the utilities are better than Gnome, and ksnapshot is one of them. Kate is another and I am glad they allow some freedom on dependencies here. Kate editor requires "konsole" to do everything I normally do integrated in one place.


An example of another diagnostic is a boot USB with some assembly. I have done a million lines of assembly and can read it better than English. Also in this case it requires some knowledge of the BIOS as it is using the interface there. Int 10h is video and Int 16h is key. The example is the most simple printf :) possible. I would guess looking at the code that it would keep printing the message over and over without line feeds or CR and go back to the top of the screen and start again, doing this forever. So here is an example using nasm.

;nasm -f bin -o mbr.img ipl.nasm
;cat mbr.img > /dev/sdg1 ? USB?
        org 7C00h
        jmp short Start
Msg:    db "Hello Motey! 4567890" ;pad to get 20's
EndMsg:
Start:  mov bx, 000Fh
        mov cx, 1
        xor dx, dx
        mov ds, dx
        cld
Print:  mov si, Msg
Char:   mov ah, 2
        int 10h
        lodsb
        mov ah, 9
        int 10h
        inc dl
        cmp dl, 80
        jne Skip
        xor dl, dl
        inc dh
        cmp dh, 25
        jne Skip
        xor dh, dh
Skip:   cmp si, EndMsg
        jne Char
        jmp Print


times 0200h - 2 - ($ - $$)  db 0
        dw 0AA55h       ;Boot Sector signature

;OPTIONAL:
;To zerofill up to the size of
;1.44MB, 3.5" floppy disk
;times 1474560 - ($ - $$) db 0
$ od -t x1  mbr.img
0000000 eb 0d 48 65 6c 6c 6f 20 57 6f 72 6c 64 21 20 bb
0000020 0f 00 b9 01 00 31 d2 8e da fc be 02 7c b4 02 cd
0000040 10 ac b4 09 cd 10 fe c2 80 fa 50 75 0b 30 d2 fe
0000060 c6 80 fe 19 75 02 30 f6 81 fe 0f 7c 75 df e9 d9
0000100 ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0000120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*
0000760 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa
0001000

The bin dump doesn't look right to me and the 55 aa should be at 1fch01feh ( I was thinking 1feh and typed 1fch ) IIRC. Ahhh , here is the answer, od needs "-A x" to show address with base 16 radix, so ...

$ od -t x2 -A x mbr.img
$ od -t x2 -A x mbr2.img
000000 0deb 6548 6c6c 206f 6f4d 6574 2179 bb20
000010 000f 01b9 3100 8ed2 fcda 02be b47c cd02
000020 ac10 09b4 10cd c2fe fa80 7550 300b fed2
000030 80c6 19fe 0275 f630 fe81 7c0f df75 d9e9
000040 00ff 7c00 7c44 0046 01fe 01b4 0000 0000
000050 0000 0000 0000 0000 0000 0000 0000 0000
*
0001f0 0000 0000 0000 0000 0000 0000 0000 aa55
000200

Okay, that looks better! I think in hex more than decimal or octal, but I can think binary too, but that gets a bit cumbersome.

So I burned the boot sector and tried it on one machine and it would not run so I modified the code to be x86_64 x86_32 x86_16 agnostic and tried again and it failed. The machine said it could not find the USB drive, and so I considered if it was machine specific. I tried it on another machine and bingo, it executed the agnostic code. I re-burned it with the other code and it also worked. In the process I got x86dis from debian to look at the code, but could find no option for disassembly of bin with 16 bit mode. It only goofs up when absolute addresses are used so I can code around that if needed. The next step is to see what funky game the machine is playing with me and I am guessing it has an additional signature that it expects in order to boot.

I changed the name to .asm from .nasm so kate editor would do some highlighting. Now I am sure that it executes in 16 bit mode, which is what I would expect at boot. It has been a while for asmx86 and so the db 66h :) things are starting to come back. The original intent was to have code that could see what the machine looked like at the interface level before the boot. It allows me to look at disks or whatever and I have a complete x86-16-32 assembly language operating system that can now be installed on the drive. It has some rather extensive diagnostics built-in and so I won't have to code more, just burn it.

There is a flat real mode OS and a protected mode OS with all the bells and whistles that is perhaps more suited for the multi-cpu world as it is designed to operate in a parallel fashion at the atomic level I will see how well it works on a quad core machine.

0 comments:

Contributors

Automated Intelligence

Automated Intelligence
Auftrag der unendlichen LOL katzen