Manually create root file system for Xavier AGX

Im having trouble getting the script nv_build_samplefs.sh to run inside docker while following the recipe Root File System — Jetson Linux<br/>Developer Guide 34.1 documentation.

root@b70c4a17169a:/l4t/tools/samplefs# ./nv_build_samplefs.sh --abi aarch64 --distro ubuntu --flavor minimal --version focal
********************************************
     Create ubuntu sample filesystem     
********************************************
nv_build_samplefs.sh - download_samplefs
nv_build_samplefs.sh - extract_samplefs
nv_build_samplefs.sh - create_samplefs
chroot: failed to run command 'apt-get': Exec format error
nv_build_samplefs.sh - cleanup


There seems to be somthing wrong with using qemu to run apt-get inside the target file system, however I can’t figure out what is going wrong. Have anyone experienced this before and could point me in the right direction? ( I have run the apt-get to install qemu :) )

Any help is deeply appreciated :)

hello user150328,

may I know what’s the error messages?

BTW,
which Jetpack release you’re using? please moving to JetPack 5.0.2/ L4T 35.1 since it’s production release version.

Hi, thanks for the quick response.
My version is L4T 35.1.
The error message is written in the first post:

chroot: failed to run command ‘apt-get’: Exec format error

The error message originates from
nvubuntu_samplefs.sh line 117: “sudo LC_ALL=C chroot . apt-get update”

If I understand this line correctly it is trying to run apt-get inside the target fs. However the apt-get in the target fs is compiled for aarch64 but my host machine is x86_64.

Br user 150328

Hi user150328,

We can’t reproduce your issue.
Run below steps on our Ubuntu-18.04 host:

$ sudo apt-get install docker.io
$ sudo docker run --privileged -it --rm -v <your_L4T_root>/Linux_for_Tegra:/l4t ubuntu:20.04

(inside of container) # apt-get update
(inside of container) # apt-get install -y qemu-user-static wget sudo
(inside of container) # cd /l4t/tools/samplefs
(inside of container) # sudo ./nv_build_samplefs.sh --abi aarch64 --distro ubuntu --flavor minimal --version focal

The sample_fs.tbz2 can be generated success.

When running the ARMv8-a tools on the host PC during install it uses QEMU (without this it would try to use a tool of the wrong architecture for the PC, which is what the “Exec format error” relates to, though it does not say why QEMU did not do its job). What do you see (on the host PC) from:
dpkg -l | grep -i qemu

First make sure package “qemu-user-static” is installed on the host. Then copy the file /usr/bin/qemu-aarch64-static from the host to the rootfs/usr/bin/
‘Exec format error’ error should then go away.

Hi, and thanks for helping me :)

running dpkg-l | grep -i qemu on host yields no response. However running it inside the docker container yields:
**ii qemu-user-static 1:4.2-3ubuntu6.23 amd64 QEMU user mode emulation binaries (static version)
**

Installing qemu-user-static on host seems to be working, I had to manually create the usr/bin folder inside the rootfs folder before copying qemu-aarch-static there.

Thank you so much for helping me solving this issue :) especially user100090 :)

Br User 150328