GRUB on USB-Stick
GRUB on USB-Stick
Hello Peoples
Long times ago i coded PIRAT: http://www.domae.ch
Now, i will try to code it from scratch new.
Actually i'll make it Grub compatible and i'll put it on my usb stick.
Did anybody know how i can install grub on a usb stick?
thx a lot.
and sorry for my english.
greez
Long times ago i coded PIRAT: http://www.domae.ch
Now, i will try to code it from scratch new.
Actually i'll make it Grub compatible and i'll put it on my usb stick.
Did anybody know how i can install grub on a usb stick?
thx a lot.
and sorry for my english.
greez
Re:GRUB on USB-Stick
if i try the command on my debian linux "grub-install /dev/sda" this error message apears:
/dev/sda does not have any corresponding BIOS drive?
what this means?
thx
/dev/sda does not have any corresponding BIOS drive?
what this means?
thx
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:GRUB on USB-Stick
during its setup, GRUB only has access to BIOS interrupts to load files. That means even if you ask it to run on CDROM, it doesn't do ATAPI stuff directly: it uses INT13h with the device number that corresponds to the floppy-emulation of the CDROM.
You need a similar number to use your USB stick as a boot device for GRUB. Now, maybe later release of GRUB do include OCHI/UHCI driver and USB-storage support, but quite frankly i doubt of it. My guess would be that you'll have to check first that your BIOS can offer INT13h on USB devices before you try to install GRUB on it.
You need a similar number to use your USB stick as a boot device for GRUB. Now, maybe later release of GRUB do include OCHI/UHCI driver and USB-storage support, but quite frankly i doubt of it. My guess would be that you'll have to check first that your BIOS can offer INT13h on USB devices before you try to install GRUB on it.
Re:GRUB on USB-Stick
thx.
i found a tutorial:
i first must partitionate it and set the bootflag. then i copied all *stage* files from /boot/grub to /mnt/usb/boot/grub then i made i device.map with "(hd0) /dev/sda" and the grub-install works.
do you actually know a good tutorial for a multiboot grub kernel. ?
thx alot
i found a tutorial:
i first must partitionate it and set the bootflag. then i copied all *stage* files from /boot/grub to /mnt/usb/boot/grub then i made i device.map with "(hd0) /dev/sda" and the grub-install works.
do you actually know a good tutorial for a multiboot grub kernel. ?
thx alot
-
- Member
- Posts: 1600
- Joined: Wed Oct 18, 2006 11:59 am
- Location: Vienna/Austria
- Contact:
Re:GRUB on USB-Stick
There's a multiboot kernel example in our OSFAQ iirc.
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
BlueillusionOS iso image
Re:GRUB on USB-Stick
well, i wrote now a little test "kernel":
when i compile it with:
and try to boot it, it doesent works. grub says:
and when i try it together with a linkscript:
and a nothing-doing-c-file the error doesn't appear and it works sometimes... but sometimes it don't works. why this?
ps: grub works good. the splashscreen works.
thx
Code: Select all
[bits 32]
[global entry]
entry:
MULTIBOOT_PAGE_ALIGN equ 1<<0
MULTIBOOT_MEMORY_INFO equ 1<<1
MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO
CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
align 4
mboot:
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd CHECKSUM
dd MULTIBOOT_HEADER_MAGIC
dd entry
dd 0
dd 0
dd start
start:
mov ax, 0x08
mov ds, ax
mov byte [ds:0B8000h], 'P'
mov byte [ds:0B8001h], 8Fh
mov byte [ds:0B8002h], 'I'
mov byte [ds:0B8003h], 8Fh
mov byte [ds:0B8004h], 'R'
mov byte [ds:0B8005h], 8Fh
mov byte [ds:0B8006h], 'A'
mov byte [ds:0B8007h], 8Fh
mov byte [ds:0B8008h], 'T'
mov byte [ds:0B8009h], 8Fh
.stop:
jmp .stop
Code: Select all
nasm -f elf -o pkernel pkernel.asm
Code: Select all
Invalid or unsupported executable format.
Code: Select all
OUTPUT_FORMAT("elf32-i386")
ENTRY(entry)
virt = 0xC0000000; /* 3 gig */
phys = 0x100000; /* 1 meg */
SECTIONS
{ .text virt : AT(phys)
{ code = .;
*(.text)
. = ALIGN(4096); }
.data : AT(phys + (data - code))
{ data = .;
*(.data)
. = ALIGN(4096); }
.bss : AT(phys + (bss - code))
{ bss = .;
*(.bss)
*(COMMON)
. = ALIGN(4096); }
end = .; }
ps: grub works good. the splashscreen works.
thx
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:GRUB on USB-Stick
See higher-half BareBones, it might help.
You also have a common trouble and their solution in the "BareBones" page of the FAQ.
You also have a common trouble and their solution in the "BareBones" page of the FAQ.
Re:GRUB on USB-Stick
i solved this by copying the kernel at 1 mb.
however all works except when i try to put out e string.
i think the linkscript or the makescript is wrong. what could it be?
Linkscript:
Makescript:
however all works except when i try to put out e string.
i think the linkscript or the makescript is wrong. what could it be?
Linkscript:
Code: Select all
OUTPUT_FORMAT("elf32-i386")
ENTRY(start)
phys = 0x00100000;
SECTIONS
{
.text 0x00100000 : {
. = ALIGN(4096);
code = .;
*(.text)
}
.data : {
. = ALIGN(4096);
data = .;
*(.data)
}
.bss : {
. = ALIGN(4096);
bss = .;
*(.bss)
}
.rodata : {
. = ALIGN(4096);
rodata = .;
*(.rodata)
}
end = .;
}
Code: Select all
SRC = pkernel.c
OBJ = pkernelasm.o pkernel.o
LD_OPTIONS=-T linksrc.ld -Map Mapfile.txt -o pkernel
all: as c link clean
as:
nasm -f aout -o pkernelasm.o pkernel.asm
c:
gcc -std=c99 -ffreestanding -fno-builtin -nostdinc -nostdlib -nostartfiles -nodefaultlibs -c $(SRC) -I ../include
link:
ld $(LD_OPTIONS) $(OBJ)
clean:
rm *.o
-
- Member
- Posts: 1600
- Joined: Wed Oct 18, 2006 11:59 am
- Location: Vienna/Austria
- Contact:
Re:GRUB on USB-Stick
shouldn't rodata be inside the declaration for data? (in the linker script)
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
BlueillusionOS iso image
Re:GRUB on USB-Stick
tried it...
resulted linkscript:
now the grub says again:
Invalid or unsupported executable format... hm
thx
resulted linkscript:
Code: Select all
OUTPUT_FORMAT("elf32-i386")
ENTRY(start)
phys = 0x00100000;
SECTIONS
{
.text 0x00100000 : {
. = ALIGN(4096);
code = .;
*(.text)
}
.data : {
. = ALIGN(4096);
data = .;
*(.data)
*(.rodata)
}
.bss : {
. = ALIGN(4096);
bss = .;
*(.bss)
}
end = .;
}
Invalid or unsupported executable format... hm
thx
Re:GRUB on USB-Stick
Check the BareBones tutorials Pype linked a couple of posts above. Those are "known good" implementations which you can build upon. (I'm not sure if it makes a difference, but they put .rodata into .text.)
Every good solution is obvious once you've found it.
-
- Member
- Posts: 1600
- Joined: Wed Oct 18, 2006 11:59 am
- Location: Vienna/Austria
- Contact:
Re:GRUB on USB-Stick
Ah, that's maybe the way it's to be done. I just didn't remember correctly. Well ... should rather look up stuff ere posting something fallible in a hurry between two tasks.
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
BlueillusionOS iso image
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:GRUB on USB-Stick
You've been through the BareBones page, right? so you've read
Well ...
1. placing any section _after_ .bss is a bad idea in general, and it might not please GRUB.
2. if you're placing .data and .rodata together, make sure the .data section is still writable in your final .o
3. there's not .rodata alone! gcc loves to put small strings in a separate section from large strings and you might e.g. have .rodata.str32 ... you can be covered against that using *(.rodata*) in your script.
So please, _do_ read the "BareBones" even if you don't intend to use it, and _do_ use "objdump" tool to scrutinize your object files. That's the only way you can actually understand what the linker does ... and why it might not please GRUB.
and you're pretty sure you're not experiencing anything described there.I still get Error 13: Invalid or unsupported executable format from GRUB. What's going on ?
Chances are the multiboot header is missing from the final executable.
If you are using some other format than ELF (such as PE), you should specify the AOUT kludge in the multiboot header. The mbchk program (coming with GRUB) and "objdump -h" should give you more hints about what is going on.
It may also happen if you use an ELF object file instead of an executable (e.g. you have an ELF file with unresolved symbols or unfixable relocations). Try to link your ELF file to a binary executable to get more accurate error messages.
Well ...
1. placing any section _after_ .bss is a bad idea in general, and it might not please GRUB.
2. if you're placing .data and .rodata together, make sure the .data section is still writable in your final .o
3. there's not .rodata alone! gcc loves to put small strings in a separate section from large strings and you might e.g. have .rodata.str32 ... you can be covered against that using *(.rodata*) in your script.
So please, _do_ read the "BareBones" even if you don't intend to use it, and _do_ use "objdump" tool to scrutinize your object files. That's the only way you can actually understand what the linker does ... and why it might not please GRUB.