Mkfs.ext4 fails in lxc container when writing image produced by dd

(Jesse Beard) #1


I am stuck on a failure from mkfs.ext4 and am hoping someone can help point me in the right direction. The build runs great outside of the container, but I wanting to isolate the build using lxc to get better use of one of our TeamCity agent instances. This error is a bit out of my area of comfort, so looking for some possible guidance.

Please let me know what additional info I can provide.

(I have full access to the host VM and the containers.)

Host VM
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.4 LTS
Release:        16.04
Codename:       xenial
uname -msr
Linux 4.15.0-22-generic x86_64
During the Yocto build, the following code:
fakeroot do_create_resin_data_partition() {
    # Create the ext4 partition out of ${B}/resin-data
    dd if=/dev/zero of=${B}/resin-data.img bs=1M count=0 seek=${PARTITION_SIZE}
    chown -R root:root ${B}/resin-data
    mkfs.ext4 -E lazy_itable_init=0,lazy_journal_init=0 -i 8192 -d ${B}/resin-data -F ${B}/resin-data.img

is causing the following error:

mke2fs 1.43.5 (04-Aug-2017)
Discarding device blocks: done
Creating filesystem with 262144 4k blocks and 131072 inodes
Filesystem UUID: 6f033c3e-dc48-447e-bd6e-56953b88eae4
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376

Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Copying files into the device: __populate_fs: Could not allocate block in ext2 filesystem while writing file ""
mkfs.ext4: Could not allocate block in ext2 filesystem while populating file system
WARNING: exit code 1 from a shell command.

Full source code is here.

The container configuration is:

architecture: x86_64
  image.architecture: amd64
  image.description: ubuntu 16.04 LTS amd64 (release) (20180522)
  image.label: release
  image.os: ubuntu
  image.release: xenial
  image.serial: "20180522"
  image.version: "16.04"
  linux.kernel_modules: ip_tables
  raw.lxc: |-
  security.nesting: "true"
  security.privileged: "true"
  volatile.base_image: 08bbf441bb737097586e9f313b239cecbba96222e58457881b3718c45c17e074
  volatile.eth0.hwaddr: 00:16:3e:55:bf:68
  volatile.idmap.base: "0" '[]'
  volatile.last_state.idmap: '[]'
  volatile.last_state.power: RUNNING
    path: /var/lib/docker
    source: /lxc/boondocks-os/docker/
    type: disk
    name: eth0
    nictype: bridged
    parent: lxd-bridge
    type: nic
    path: /
    pool: lxd-pool
    type: disk
ephemeral: false
- boondocks-os
stateful: false
description: Boondocks OS Build Container

The storage pool:

  description: ""
  driver: zfs
  name: lxd-pool
  space used: 20.87GB
  total space: 123.48GB
  pool: lxd-pool
 state: ONLINE
  scan: none requested

        NAME        STATE     READ WRITE CKSUM
        lxd-pool    ONLINE       0     0     0
          sdc       ONLINE       0     0     0

errors: No known data errors

On the Host VM, I have applied the following:


fs.inotify.max_queued_events = 1048576
fs.inotify.max_user_instances = 1048576
fs.inotify.max_user_watches = 1048576
vm.max_map_count = 262144


*               soft    nofile          1048576
*               hard    nofile          1048576
root            soft    nofile          1048576
root            hard    nofile          1048576
*               soft    memlock         unlimited
*               hard    memlock         unlimited