3

I'm trying to setup my buildroot image with genimage. This is the default configuration file:

image boot.vfat {
  vfat {
    files = {
      "bcm2710-rpi-3-b.dtb",
      "rpi-firmware/bootcode.bin",
      "rpi-firmware/cmdline.txt",
      "rpi-firmware/config.txt",
      "rpi-firmware/fixup.dat",
      "rpi-firmware/start.elf",
      "kernel-marked/zImage"
    }
  }
  size = 32M
}

image sdcard.img {
  hdimage {
  }

  partition boot {
    partition-type = 0xC
    bootable = "true"
    image = "boot.vfat"
  }

  partition rootfs {
    partition-type = 0x83
    image = "rootfs.ext4"
  }
}

The nconfig > filesystem images fields are set to the default values. I don't need more freespace on rootfs.

Instead I want to create another ext4 partition, let's say of 100M. So this is the new genimage file I created:

image boot.vfat {
  vfat {
    files = {
      "bcm2710-rpi-3-b.dtb",
      "rpi-firmware/bootcode.bin",
      "rpi-firmware/cmdline.txt",
      "rpi-firmware/config.txt",
      "rpi-firmware/fixup.dat",
      "rpi-firmware/start.elf",
      "kernel-marked/zImage"
    }
  }
  size = 32M
}

image opt.ext4 {
  ext4 { }
  size = 100M
}

image sdcard.img {
  hdimage {
  }

  partition boot {
    partition-type = 0xC
    bootable = "true"
    image = "boot.vfat"
  }

  partition rootfs {
    partition-type = 0x83
    image = "rootfs.ext4"
  }

  partition opt {
    partition-type = 0x83
    image = "opt.ext4"
  }
}

But it returns this error:

genext2fs: couldn't allocate a block (no free space)
ext4(opt.ext4): failed to generate opt.ext4

Where's my mistake? I think I don't need to reserve more space in the buildroot settings because I'm creating a new partition, I'm not resizing the rootfs one!

Mark
  • 438

1 Answers1

3

I'm having a similar problem, make sure you have GENEXT2FS enabled in host tools.

R2_PACKAGE_HOST_GENEXT2FS=y

It seems like buildroot is placing all your rootfs files into every partition you define. If you increase the max file size and mount the partition, you can see the entire file system.

I figured out you shouldn't use genimage to create the partition, but refer to an already made file system. (and remove the image application.ext4 definition at the top)

genimage.cfg:

partition application {
   partition-type = 0x83
   image = "application.ext4"
 }

You create the application.ext4 file in your buildroot/output/images folder like this:

dd if=/dev/zero of=application.ext4 bs=1M count=20
mke2fs application.ext4

When you are done you can mount the partition and see you have a working empty partition! (On your physical device or in QEMU)

mkdir /mnt/test
mount -t ext4 /dev/vda3 /mnt/test

I know this question is old, but i wasted a lot of time on this, and seems like google isn't too full of resources for this problem.

Viter
  • 66