How to delete a previously created default user, in order to create the same default user again

Hi,

A bit of a background:

We are using Jetson Nano production modules (not the dev versions) for our projects.

We have custom-made carrier boards which do no support HDMI or USB (for keyboard input, etc.)

There was an issue which we faced earlier that after flashing these modules, it was not possible to log in via SSH. This was because the Nano was waiting for a default user to be created right after its first boot, which usually can be done if you have a monitor and keyboard and/or a mouse. This was not the case for us hence the Nano remained waiting for such a user to be created and could not be SSHed into. So, a solution was provided here:
https://devtalk.nvidia.com/default/topic/1054926/jetson-nano/jetson-nano-all-usb-ports-suddenly-stopped-working/post/5356153/#5356153
wherein basically the l4t_create_default_user.sh script was used before flashing to create the default user in the rootfs, and then the flash script (flash.sh) was run to flash the Nano.

We need to flash via the flash.sh script because we use a modified kernel with custom drivers.

Now, the current problem:

Whenever we make changes to the kernel and device tree to accommodate our requirements, we need to run this l4t_create_default_user.sh script, as otherwise, our previous changes w.r.t. default user are overwritten when we do a compile, apply_binaries, and update /lib/, replace kernel ‘Image’ and device tree files, etc. Therefore, even though the previously created default user exists, it no longer has the default status (as verified by the ‘unable to log in via SSH’ problem faced as described above already). We then need to run this l4t_create_default_user.sh script to create a new default user after each such change.

The question:
Is there a script (or mechanism) to delete a previously created default user, or somehow grant this previously created user a default status only, such that we don’t have to create new users each time and re-use the previously created one?

Thanks in advance!

I think you don’t need to delete previous user. You can update the kernel by copy the Image to /boot/Image to apply it and update the DTB only by below command

sudo ./flash -r -k DTB xxxx mmcblk0p1

Hi ShaneCCC,

Thanks for your reply. I will try this shortly.

But I already have multiple users created in the rootfs on my host. How do I delete those before flashing? I mean I need to retain only one (default) user, but I created five users already due to the problem I mentioned before :(.

  1. You can have deluser command to delete others user after boot to tegra.
  2. If you want to delete others user from the rootfs I would suggest to regen the rootfs again.

This script is the basic logic from a python library I am writing that does something that may help you out. You can use it to enter the rootfs as if it were an actual nano and interactively and make edits as you choose.

Usage is like this:

$ sudo ./enter_rootfs.sh rootfs
+ cp /usr/bin/qemu-aarch64-static rootfs/usr/bin
+ mount -t sysfs -o ro none rootfs/sys
+ mount -t proc -o ro none rootfs/proc
+ mount -t tmpfs none rootfs/tmp
+ mount -o bind,ro /dev rootfs/dev
+ mount -t devpts none rootfs/dev/pts
+ mount -o bind,ro /etc/resolv.conf rootfs/run/resolvconf/resolv.conf
+ chroot rootfs
root@hostname:/# sudo apt install blender
Unknown host QEMU_IFLA type: 50
Unknown host QEMU_IFLA type: 51
Unknown host QEMU_IFLA type: 47
... this happens if you run something with sudo by reflex, which is not necessary since you
are already root, but the command still works as expected...
Unknown QEMU_IFLA_BRPORT type 31
Unknown QEMU_IFLA_BRPORT type 32
Unknown QEMU_IFLA_BRPORT type 33
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  blender-data fonts-dejavu fonts-dejavu-extra gdal-data libaec0 libarmadillo8 libarpack2 libavdevice57 libblas3 libboost-regex1.65.1 libcharls1
  libdap25 libdapclient6v5 libepsilon1 libfreexl1 libfyba0 libgdal20 libgdcm2.8 libgeos-3.6.2 libgeos-c1v5 libgeotiff2 libgfortran4 libgif7 libglew2.0
  libhdf4-0-alt libhdf5-100 libjemalloc1 libkmlbase1 libkmldom1 libkmlengine1 liblapack3 libminizip1 libnetcdf13 libodbc1 libogdi3.2 libopencolorio1v5
  libopencv-core3.2 libopencv-imgcodecs3.2 libopencv-imgproc3.2 libopencv-videoio3.2 libopenimageio1.7 libpq5 libproj12 libqhull7 libsdl2-2.0-0
  libsocket++1 libspatialite7 libspnav0 libsuperlu5 libsz2 libtbb2 libtinyxml2.6.2v5 liburiparser1 libxerces-c3.2 libyaml-cpp0.5v5 odbcinst
  odbcinst1debian2 proj-bin proj-data
Suggested packages:
  geotiff-bin gdal-bin libgeotiff-epsg glew-utils libhdf4-doc libhdf4-alt-dev hdf4-tools libmyodbc odbc-postgresql tdsodbc unixodbc-bin ogdi-bin
  spacenavd
The following NEW packages will be installed:
  blender blender-data fonts-dejavu fonts-dejavu-extra gdal-data libaec0 libarmadillo8 libarpack2 libavdevice57 libblas3 libboost-regex1.65.1
  libcharls1 libdap25 libdapclient6v5 libepsilon1 libfreexl1 libfyba0 libgdal20 libgdcm2.8 libgeos-3.6.2 libgeos-c1v5 libgeotiff2 libgfortran4 libgif7
  libglew2.0 libhdf4-0-alt libhdf5-100 libjemalloc1 libkmlbase1 libkmldom1 libkmlengine1 liblapack3 libminizip1 libnetcdf13 libodbc1 libogdi3.2
  libopencolorio1v5 libopencv-core3.2 libopencv-imgcodecs3.2 libopencv-imgproc3.2 libopencv-videoio3.2 libopenimageio1.7 libpq5 libproj12 libqhull7
  libsdl2-2.0-0 libsocket++1 libspatialite7 libspnav0 libsuperlu5 libsz2 libtbb2 libtinyxml2.6.2v5 liburiparser1 libxerces-c3.2 libyaml-cpp0.5v5
  odbcinst odbcinst1debian2 proj-bin proj-data
0 upgraded, 60 newly installed, 0 to remove and 0 not upgraded.
Need to get 59.4 MB of archives.
After this operation, 281 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://ports.ubuntu.com/ubuntu-ports bionic-updates/universe arm64 blender-data all 2.79.b+dfsg0-1ubuntu1.18.04.1 [12.2 MB]
Get:2 http://ports.ubuntu.com/ubuntu-ports bionic/main arm64 fonts-dejavu-extra all 2.37-1 [1,953 kB]
Get:3 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 fonts-dejavu all 2.37-1 [3,130 B]
Get:4 http://ports.ubuntu.com/ubuntu-ports bionic-updates/universe arm64 libsdl2-2.0-0 arm64 2.0.8+dfsg1-1ubuntu1.18.04.4 [307 kB]
... more apt stuff here ...
Get:58 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 libspnav0 arm64 0.2.3-1 [7,928 B]
Get:59 http://ports.ubuntu.com/ubuntu-ports bionic-updates/universe arm64 blender arm64 2.79.b+dfsg0-1ubuntu1.18.04.1 [22.3 MB]
Get:60 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 proj-bin arm64 4.9.3-2 [30.8 kB]
Fetched 59.4 MB in 6s (10.6 MB/s)      
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package blender-data.
(Reading database ... 121554 files and directories currently installed.)
Preparing to unpack .../00-blender-data_2.79.b+dfsg0-1ubuntu1.18.04.1_all.deb ...
Unpacking blender-data (2.79.b+dfsg0-1ubuntu1.18.04.1) ...
Selecting previously unselected package fonts-dejavu-extra.
... apt stuff here ...
Preparing to unpack .../58-blender_2.79.b+dfsg0-1ubuntu1.18.04.1_arm64.deb ...
Unpacking blender (2.79.b+dfsg0-1ubuntu1.18.04.1) ...
Selecting previously unselected package proj-bin.
Preparing to unpack .../59-proj-bin_4.9.3-2_arm64.deb ...
Unpacking proj-bin (4.9.3-2) ...
Setting up libminizip1:arm64 (1.1-8build1) ...
Setting up libaec0:arm64 (0.3.2-2) ...
Setting up libdap25:arm64 (3.19.1-2build1) ...
Setting up libqhull7:arm64 (2015.2-4) ...
... apt stuff here ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Processing triggers for fontconfig (2.12.6-0ubuntu2) ...
Processing triggers for mime-support (3.60ubuntu1) ...
Processing triggers for desktop-file-utils (0.23-1ubuntu3.18.04.2) ...
root@hostname:/# apt purge blender --autoremove
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  blender* blender-data* fonts-dejavu* fonts-dejavu-extra* gdal-data* libaec0* libarmadillo8* libarpack2* libavdevice57* libblas3*
  libboost-regex1.65.1* libcharls1* libdap25* libdapclient6v5* libepsilon1* libfreexl1* libfyba0* libgdal20* libgdcm2.8* libgeos-3.6.2* libgeos-c1v5*
  libgeotiff2* libgfortran4* libgif7* libglew2.0* libhdf4-0-alt* libhdf5-100* libjemalloc1* libkmlbase1* libkmldom1* libkmlengine1* liblapack3*
  libminizip1* libnetcdf13* libodbc1* libogdi3.2* libopencolorio1v5* libopencv-core3.2* libopencv-imgcodecs3.2* libopencv-imgproc3.2*
  libopencv-videoio3.2* libopenimageio1.7* libpq5* libproj12* libqhull7* libsdl2-2.0-0* libsocket++1* libspatialite7* libspnav0* libsuperlu5* libsz2*
  libtbb2* libtinyxml2.6.2v5* liburiparser1* libxerces-c3.2* libyaml-cpp0.5v5* odbcinst* odbcinst1debian2* proj-bin* proj-data*
0 upgraded, 0 newly installed, 60 to remove and 0 not upgraded.
After this operation, 281 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 123916 files and directories currently installed.)
Removing blender (2.79.b+dfsg0-1ubuntu1.18.04.1) ...
Removing blender-data (2.79.b+dfsg0-1ubuntu1.18.04.1) ...
Removing fonts-dejavu (2.37-1) ...
Removing fonts-dejavu-extra (2.37-1) ...
... apt stuff here ...
Processing triggers for mime-support (3.60ubuntu1) ...
(Reading database ... 121555 files and directories currently installed.)
Purging configuration files for libspnav0 (0.2.3-1) ...
Purging configuration files for odbcinst (2.3.4-1.1ubuntu3) ...
root@hostname:/# exit
exit
+ umount rootfs/sys
+ umount rootfs/proc
+ umount rootfs/tmp
+ umount rootfs/dev/pts
+ umount rootfs/dev
+ umount rootfs/run/resolvconf/resolv.conf
+ rm rootfs/usr/bin/qemu-aarch64-static

All this is happening before the first boot. If you want to delete a user, you can use the deluser command but the suggestion to regenerate the rootfs at that point is a better one, espeically if you ran the other first boot scripts. Starting from a fresh rootfs in the Linux_for_tegra folder, run the script with “./script.sh rootfs”

You can then do whatever you want interactively, like add system users and (hopefully strong password protected) keys so you can ssh in. You could also copy a script to do it into the rootfs and run it from within the chroot. You can also run apt-get update, upgrade, install, purge, and so as shown on to add and remove packages. You can of course also use dpkg to install packages from .deb files you copy to the rootfs. In theory, this could save you a lot off the first boot time (not to mention network traffic).

If you configure the system the way you want and want to disable nvidia’s first boot scripts, you can find their .system unit files in /etc/systemd/system
You may wish to edit or replace their scripts instead since many things they do are important to any first boot (like generation of ssh host keys).

Please report any bugs you encounter here.

Hi mdegans,

The tool that you developed was really helpful. I could indeed delete the previously created users on host, which saves a lot of time as I now do not have to do it for every flashed unit.

There is a warning I observed however, when trying to do an apt-get update and apt-get upgrade, which kept appearing:
qemu: Unsupported syscall: 278

I do not know if this is a bug, so I am unsure if I should report it on your github page.

But when I modified the rootfs with some other changes that we need, and flashed the Nano, the unit did not show up on the network so I couldn’t SSH. I’ll have to debug further what might have gone wrong, but guess there are limitations as to what all can be done using chroot as opposed to a live system, and somehow some permissions got tampered with. Basically I was trying to do this: https://devtalk.nvidia.com/default/topic/1067412/cloning-an-existing-rootfs-on-the-internal-flash-memory-of-nano-production-modules/?offset=1#5406712
as rsync did not work for me, something clearly went wrong with sudo permissions.

The unsupported syscall error is likely not related, but you can report it and I will investigate further.

How did you generate your rootfs folder? Did you copy it from an actual Nano? If that’s the vase, that may be the cause of network issues.

I would recommend starting from a stock rootfs then using Nvidia’s apply_binaries script to add the kernel, modules, and Nvidia specific binaries to the rootfs (if necessary). Then start my script to do the rest, like add a service user, or run apt to update the system.

From start to finish, can you describe what you need to do with the Nano? Most things should be possible before first boot. The rest can be accomplished with first boot scripts.