2
votes

Firs, please excuse me - those are my first steps in building OS and using Buildroot.

I've managed to create my first custom os (nothing special, just a first test with patched 4.6.3 kernel with grsec).

I have this files in /output/images dir:

$ ls -lh
total 304M
-rw-r--r-- 1 fugitive fugitive  512 Apr 13 01:01 boot.img
-rw-r--r-- 1 fugitive fugitive 4.1M Apr 13 00:57 bzImage
-rw-r--r-- 1 fugitive fugitive  79M Apr 13 01:01 disk.img
-rw-r--r-- 1 fugitive fugitive 137K Apr 13 00:57 grub-eltorito.img
-rw-r--r-- 1 fugitive fugitive 137K Apr 13 00:57 grub.img
-rw-r--r-- 1 fugitive fugitive  69M Apr 13 01:01 rootfs.cpio
-rw-r--r-- 1 fugitive fugitive  79M Apr 13 02:10 rootfs.ext2
lrwxrwxrwx 1 fugitive fugitive   11 Apr 13 01:01 rootfs.ext4 -> rootfs.ext2
-rw-r--r-- 1 fugitive fugitive  74M Apr 13 01:01 rootfs.iso9660

What my goal is - to create a bootabile iso image, but I don't know how.

I am able to emulate it with qemu, like you can see on the screenshot:

enter image description here

I've tried to burn rootfs.iso9660 to USB drive, but not able to boot.

Tried to rename rootfs.iso9660 to rootfs.iso9660.iso and try with VirtualBox, but then I got a grub terminal.

Appreciate the help and instructions!

EDIT:

.config file:

-bash-4.2$ grep  BR2_TARGET_ROOTFS_ .config | grep -v ^#
BR2_TARGET_ROOTFS_CPIO=y
BR2_TARGET_ROOTFS_CPIO_NONE=y
BR2_TARGET_ROOTFS_EXT2=y
BR2_TARGET_ROOTFS_EXT2_4=y
BR2_TARGET_ROOTFS_EXT2_GEN=4
BR2_TARGET_ROOTFS_EXT2_REV=1
BR2_TARGET_ROOTFS_EXT2_LABEL=""
BR2_TARGET_ROOTFS_EXT2_BLOCKS=0
BR2_TARGET_ROOTFS_EXT2_INODES=0
BR2_TARGET_ROOTFS_EXT2_EXTRA_BLOCKS=0
BR2_TARGET_ROOTFS_EXT2_EXTRA_INODES=0
BR2_TARGET_ROOTFS_EXT2_RESBLKS=0
BR2_TARGET_ROOTFS_EXT2_NONE=y
BR2_TARGET_ROOTFS_ISO9660=y
BR2_TARGET_ROOTFS_ISO9660_GRUB2=y
BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="fs/iso9660/grub.cfg"
BR2_TARGET_ROOTFS_ISO9660_INITRD=y

-bash-4.2$ grep -r BR2_TARGET_ROOTFS_ISO9660_HYBRID *
fs/iso9660/Config.in:config BR2_TARGET_ROOTFS_ISO9660_HYBRID
fs/iso9660/iso9660.mk:ifeq ($(BR2_TARGET_ROOTFS_ISO9660_HYBRID),y)
3

3 Answers

3
votes

Have you enabled BR2_TARGET_ROOTFS_ISO9660_HYBRID ? This is needed if you want your ISO image to also work from a USB device.

2
votes

A bootable ISO image (old school ISO just for CDROMs) with Grub2 - I made it work.

The main hints:

  • Grub: add builtin modules biosdisk iso9660
  • Grub: boot partition set to cd
  • After changing Grub options you need to recompile it (read how to rebuild package in official manual)
  • If you do changes in kernel config, make sure that CDROM devices and ISO9660 filesystem are supported
  • If you are in grub rescue console (which is not a good sign), try to execute commands step by step (like in this answer) to figure out the issue.

Extract from .config

I saved my changes as defconfig (make savedefconfig, read here) and here is what you should have in yours:

BR2_ROOTFS_POST_BUILD_SCRIPT="board/pc/post-build.sh"
BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh"
BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/pc/genimage-bios.cfg"
BR2_TARGET_ROOTFS_EXT2=y
BR2_TARGET_ROOTFS_EXT2_4=y
BR2_TARGET_ROOTFS_EXT2_SIZE="120M"
BR2_TARGET_ROOTFS_ISO9660=y
BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="fs/iso9660/grub.cfg"
BR2_TARGET_GRUB2=y
BR2_TARGET_GRUB2_BOOT_PARTITION="cd"
BR2_TARGET_GRUB2_BUILTIN_MODULES="boot linux ext2 fat squash4 part_msdos part_gpt normal biosdisk iso9660"
BR2_PACKAGE_HOST_GENIMAGE=y

Side note: I started my trials with building a default configuration for PC make pc_x86_64_defconfig && make

Test

Test your ISO in QEMU:

qemu-system-x86_64 -m 512 -cdrom output/images/rootfs.iso9660

It also works in Virtual Box.

0
votes

Try :

sudo dd if=/path/to/output/images/disk.img of=/path/to/usb/drive bs=1M

To know the path to your usb drive do :

lsblk 

and find your usb drive.