That script is old, from approximately a year and half back. Unless you are using L4T from that date I’d suggest using the additions made since then which have new scripts. If you are using that older release, then I’d suggest upgrading before you continue.
Which release are you using? See “head -n 1 /etc/nv_tegra_release”.
Do beware that if you run out of disk space on the main root partition you will have trouble logging in. When you create a file for use as a file system (a file pretending to be a partition via loopback), then you can fill up that file without risk so long as the file itself does not fill up the system. Before you start, check this:
df -H /
…note what is available.
Do you have directory “/opt/nvidia/l4t-usb-device-mode/”? If you have a more recent release, then this should exist. In that case see the content of this file instead of the older script:
/opt/nvidia/l4t-usb-device-mode/nv-l4t-usb-device-mode.sh
Within that file there are a couple of different OTG port additions, one being an example ethernet device…you probably don’t want or need that and you could comment out anything ethernet (though you might want it…basically a USB port can become multiple devices on a single wire…ethernet is just one device). A simple way to disable some service would be to set one of these lines (depending on the service) to “=0” instead of “=1”:
enable_rndis=1
enable_acm=1
enable_ecm=1
enable_ums=1
This is for bulk storage, and you would keep this running, but I recommend setting all of the others to “0” unless you know you are using them:
enable_rndis=0
enable_acm=0
enable_ecm=0
# This is bulk storage:
enable_ums=<b>1</b>
If you look at the block of code under this you will see everything done for the OTG port fake disk drive:
if [ ${enable_ums} -eq 1 ]; then
In particular, if you start or stop this emulation of a hard drive via this script, and if you comment out this line, then it will become read-write:
...
# Prevent users from corrupting the disk image; make it read-only
<b>#</b> echo 1 > "${func}/lun.0/ro"
The final line of that block of code names the file used to back the fake hard drive:
/opt/nvidia/l4t-usb-device-mode/filesystem.img
This is a raw size, so actual content after formatting will be less, but you can see the size the sample uses:
ls -l /opt/nvidia/l4t-usb-device-mode/filesystem.img
As an example, if the size is “16777216”, then it will be evenly divisible by the block size of 512 a certain number of times. If you put this in terms of KiB (16384KiB), instead divide once by 1024…or MiB (16MiB), divide twice by 1024. It’s convenient that 1024 (or any multiple of 1024) is just two 512 byte blocks. Device space is divided into block sizes.
This file is the one you should adjust after commenting out the read-only line mentioned above:
/opt/nvidia/l4t-usb-device-mode/filesystem.img
…just follow comment #40 and enlarge the file to the size you desire after stopping the service and covering that file with loopback (and be careful to not fill your root partition).
A good way to manually stop or start this service:
# stop:
sudo /opt/nvidia/l4t-usb-device-mode/nv-l4t-usb-device-mode-<b>stop</b>.sh
# start:
sudo /opt/nvidia/l4t-usb-device-mode/nv-l4t-usb-device-mode.sh
When set up as a service the standard “systemctl” stop/start works. This is why the file “nv-l4t-usb-device-mode.service” is there.