Omitting l4t name after connecting via USB to a host machine

Dear Friends,
Can anybody answer my question?
Jetson is a part of our production and occasionally we must connect to it to maintenance or monitoring. Since I want that the customer has no idea about the system components, I want either this folder not to be sent to the remote machine after connection or its name can be changed to a desired title. Is there any solution?

Are you talking about wired network connection name? Are you seeing the name from the command “cat /etc/hostname” or “hostnamectl”?

No. hostnamectl in my Jetson is the name set during installing firmware.

As you know when we connect to Jetson via a USB connection, an auto-play drive titled “L4T-README” is accessible in the host machine. I want to change the name and contents of this folder or no folder is accessible.

The USB device mode content is controlled in “/opt/nvidia/l4t-usb-device-mode”. It runs as a service, and so you’ll see separate files for service specification (which you can leave alone), plus start/stop and configuration files. You can “stop” all L4T USB device mode gadgets quite easily by disabling the service, but that will also disable the network availability at the address. If you are ok with that:

sudo systemctl stop nv-l4t-usb-device-mode.service
sudo systemctl disable nv-l4t-usb-device-mode.service
# To later enable:
sudo systemctl enable nv-l4t-usb-device-mode.service
# Then either reboot or:
sudo systemctl start nv-l4t-usb-device-mode.service

If you want to disable or alter the services surrounding individual devices on that USB port, then you can examine the files in that directory. The most relevant file is “”. Some other files are related, e.g., the MAC address is taken from the mac-addresses file, and the actual content of the L4T-README is inside the loopback mountable filesystem of filesystem.img.

One can temporarily disable the USB devices and loopback mount that image and view it or edit it; or copy it to a host PC and view and edit there. To temporarily stop and start the service:

sudo systemctl stop nv-l4t-usb-device-mode.service
# Reboot or do this to start the service:
sudo systemctl start nv-l4t-usb-device-mode.service

If the image file is not in use, then you can do this to loopback mount (mount point is “/mnt”, which is arbitrary):

sudo mount -o loop filesystem.img /mnt
df -H -T /mnt
ls -l /mnt/*
# You could edit files there, remove files, rename files, so on.
# cd out of that directory before umount:
sudo umount /mnt
sudo systemctl start nv-l4t-usb-device-mode.service
1 Like

Thank you very much. My problem was partially solved. I could edit the L4T-README contents with mount and umount the filesystem.img. But I have a problem yet. After detecting the SSH connection in the host machine, the folder name is L4T_README. and I could not find anywhere to edit it.

I added a correction to the previous post where I missed putting the file name in the loopback mount command:

sudo mount -o loop filesystem.img /mnt

Provided that the file filesystem.img is not already in use, you can also mount it on the Jetson itself. For example, if you momentarily stop nv-l4t-usb-device-mode.service, you could run that command on the Jetson itself. When the L4t device mode services run, it is set as read-only, and so that loopback mount is the only way to edit the file unless you’ve modified the arguments of the device mode setup script.

You should probably know that the gadget API is making available a partition, and is setting it to read-only. The partition in question is not a real partition, but is instead the file filesystem.img after being covered by loopback to pretend it is a partition. The script is mounting the loop device as a read-only partition, and this is what USB is making available.

If filesystem.img is itself made read-write for whichever user owns the mount, then this clears one constraint against read-write behavior. Within the loopback mounted system, if the contained L4T-README is writable by that user, then another constraint to read-write is lifted. If the argument to the loopback mount has read-only removed, then yet another constraint is lifted (note that in the manual loopback mount command I listed earlier it does not have a read-only constraint, plus the mount and other commands are sudo, and thus has full root authority). I think that would get the job done.

Note: Examine Take a close look at this line:
/sbin/losetup -f -r "${fs_img}"
(the command “mount -o loop” is a macro which first runs losetup to create a loop device, and then to mount the loop device rather than the file)

Also, if you have an actual partition, and not a loopback mounted file, then you could substitute that partition and all of its content instead of the file pretending to be a partition.

Dear Linuxdev
Thankyou for your help.
My question has two parts:
1- I needed to change the name of autoplay drive after usb connected to host machine.
2- I needed to change the contents inn the generated folder.
About the second part, your answer was comprehensive.
But, I found the answer about the first one:
The filesystem.img has a property titled ‘label’. This label with the limit of 11 characters can be changed to a desired value as follows:
$ sudo mount -o loop filesystem.img /mnt
$ sudo blkid /dev/loop<x>
$ sudo umount /mnt
$sudo dosfslabel filesystem.img <mylabel>

I’m going to add this since others might be interested in details. Note that dosfslabel is a symbolic link to fatlabel. The two are interchangeable.

Some of the drive name is determined by the partition, and sometimes by the host using it. However, if you examine this command’s output on the running Jetson, then you’ll see the partition labels (not all have a label):
lsblk -f

Note that the loopback partition is a loop device, usually loop0 (the first loop device; the number increments after first use if a new loop device is added prior to the old one being recycled). One one TX2 I see this:

NAME         FSTYPE LABEL      UUID                                 MOUNTPOINT
loop0        vfat   L4T-README 3D81-AAFA              

For the label on the host using the device, do you see its label as “L4T-README”? If so, then this is part of the partition itself (following the rules for a VFAT partition type; sometimes you’ll see it as FAT32).

There is a tool called “fatlabel” for VFAT partition label manipulation. Check “which fatlabel”. If you don’t have this, then:
sudo apt-get install dosfstools

I’m not actually changing the label on my system, but most likely you cannot change the label when the partition is mounted or in use. So first:
sudo systemctl stop nv-l4t-usb-device-mode.service

You’ll see the loop0 device disappear. Now you’ll cover it with a loopback device again:
sudo losetup -f --show /opt/nvidia/l4t-usb-device-mode/filesystem.img

You’ll see it is now “loop0” (it could be loop1, doesn’t matter, but use whatever it shows up as).

Verify the device exists again with “lsblk -f”. You should see it as “loop0”, and no mount point. Since it is no longer in use by the USB device mode, and not mounted, ordinary partition tools should work on “/dev/loop0”.

You can query the current label without changing it:
sudo fatlabel /dev/loop0

I didn’t actually change mine, but you could give it a new label within the bounds of VFAT label conventions, e.g.:
sudo fatlabel /dev/loop0 JETSON
(then verify it with just “sudo fatlabel /devloop0”)

Once done you can either reboot, or detach the loopback device and restart the service:

sudo losetup -d /dev/loop0
sudo systemctl start nv-l4t-usb-device-mode.service

Thanks very much. Your answer was quite comprehensive.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.