2

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)
fugitive
  • 357
  • 2
  • 8
  • 26

3 Answers3

3

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

Thomas Petazzoni
  • 5,636
  • 17
  • 25
  • Please see the updated question, I've enabled in `make menuconfig` step ISO target as well. Let me know if you need something else! – fugitive Apr 13 '17 at 13:36
  • Thomas : Seems not.. I am not sure how to enable it, as I don't see it in something similar in menuconfig, and not sure about dependencies for it.. – fugitive Apr 13 '17 at 13:51
  • 1
    @fugitive: you have to choose isolinux instead of grub2, then the isohybrid option appears. It's not very transparent, I know, but it's hard to change due to limitations of Kconfig. – Arnout Apr 13 '17 at 20:33
  • @Arnout Found it. I'll try a let you guys know. Thank you for tips! – fugitive Apr 13 '17 at 21:54
  • @fugitive Can you post your solution here (as an answer to your own question)? – Arnout Apr 21 '17 at 10:41
  • @Arnout Sorry, I simply didn't manage to get it work. Even with switching to isolinux. Unable to boot, only could run via qemu. So I gave up. But, I've created a tons of different images for Raspberry so far, different kernels, different compilers etc, and they all worked out of the box – fugitive Apr 21 '17 at 17:57
  • Uh, are you building for Raspberry? Raspberry cannot boot from CD or isohybrid USB... – Arnout Apr 22 '17 at 21:49
2

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.

Mikolasan
  • 626
  • 10
  • 19
0

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.

gerrard2461
  • 305
  • 1
  • 6
  • 21