I haven’t tried, but you can test with the following approach:

  1. Setup nopasswd sudo
  2. In you custom command, disable pseudo (export PSEUDO_UNLOAD=1)
  3. Run ‘sudo chroot …’
  4. You may also need to enable the ‘network’ flag for do_rootfs/do_image_xxx task (whichever task your command is run in) to avoid namespace messing things up. E.g., do_rootfs[‘network’] = 1

 

Anyway, if you can find a way to adjust syslinux class to add extra functionality to it, that would be best.

 

Regards,

Qi

 

From: poky@lists.yoctoproject.org <poky@lists.yoctoproject.org> On Behalf Of Nicolas Wirth via lists.yoctoproject.org
Sent: Wednesday, May 15, 2024 10:42 PM
To: poky@lists.yoctoproject.org
Subject: Re: [poky] Running chroot-like command in Yocto #yocto

 

That's not entirely true. The syslinux class does indeed a lot of this, I was able to experiment with this using the live hddimage. However, this mechanism ends up creating 2 different partitions, one containing the bootloader, and one containing the rootfs. I would like to have them in the same partition. I was able to find how to do it by scripting, but it's outside of the build environment. My script looks like this:

 

loop_dev=$(losetup --find --partscan --show "my-image-genericx86-64.wic")

 

if [[ -z "$loop_dev" ]]; then

 

    echo "Failed to set up loop device!"

 

    exit 1

 

fi

 



if [[ "$arch" == "amd64" ]]; then

 

    echo "Setting up Extlinux"

 

    mount_dir=$(mktemp --directory)

 

    mount ${loop_dev}p1 ${mount_dir}

 

    extlinux --install ${mount_dir}/boot/syslinux

 

    umount ${loop_dev}p1

 

fi