I'm trying to build a bootable disk image using GRUB, for a pet OS project. While there's many tutorials on how to do so, they all use the interactive "grub" command line interface. And for some reason, the Linux distro I'm using (crunchbang) does not have it. I have installed grub, and grub-install works fine, but "grub" reports command not found.
I've tried a lot. I've even tried to install some linux distros (such as CentOS) to work from there, but bochs just stops working after a while.
Before that I obviously tried the "normal" method. For example, I tried the following:
Code: Select all
# dd if=/dev/zero of=disk.img bs=512 count=2056320
# fdisk disk.img
128 cylinders
255 heads
63 sectors per track
I made a new partition, made it bootable, such that:
Code: Select all
# fdisk -ul disk.img
You must set cylinders.
You can do this from the extra functions menu.
Disk disk.img: 0 MB, 0 bytes
255 heads, 63 sectors/track, 0 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x7201d21a
Device Boot Start End Blocks Id System
disk.img1 * 63 2056319 1028128+ 83 Linux
Code: Select all
# losetup -o 32256 /dev/loop0 disk.img
# mkfs.ext2 /dev/loop0
Code: Select all
# mount /dev/loop0 /mnt
# grub-install --root-directory=/mnt --modules=ext2 /dev/loop0 --force
/usr/local/sbin/grub-setup: warn: Attempting to install GRUB to a partitionless disk. This is a BAD idea..
/usr/local/sbin/grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. However, blocklists are UNRELIABLE and its use is discouraged..
Installation finished. No error reported.
Code: Select all
megs: 1024
romimage: file=/usr/share/bochs/BIOS-bochs-latest
vgaromimage: file=/usr/share/bochs/VGABIOS-lgpl-latest
ata0-master: type=disk, path="disk.img", mode=flat, cylinders=128, heads=255, spt=63
cpu: count=1, ips=15000000
mouse: enabled=0
log: out.bochs
boot: disk
So, how do I install grub on there?
EDIT:
This helped a bit...
Code: Select all
# losetup /dev/loop0 disk.img
# losetup -o 32256 /dev/loop1 disk.img
# mount /dev/loop1 /mnt
# grub-install --root-directory=/mnt --modules=ext2 /dev/loop0
Installation finished. No error reported.
At ls it only outputs "(hd0)".
Thanks in advance,
evoex