How to shutdown jetson nano without corruping USB flash drive

Hello,

Here is the issue:
On my Jetson Nano I have services writing logs and pictures on a USB flash drive for hours without interruption.

Every thing if going fine most of the time but for some of my USB flash drive I can’t write anything on the flash drive for something like 10s every 2s to 10min. Sometimes it’s getting pretty bad and the device is shown as disconnected (not there in /dev, and lsblk).

I found out that the moments were the flash drive is not accessible correspond to the following message in /var/log/kern.log:

Jul  8 16:34:42 nc-ass-vip kernel: [20043.471867] usb 2-1.2: reset SuperSpeed USB device number 3 using tegra-xusb
Jul  8 16:35:07 nc-ass-vip kernel: [20069.072184] usb 2-1.2: reset SuperSpeed USB device number 3 using tegra-xusb
Jul  8 16:35:23 nc-ass-vip kernel: [20084.432177] usb 2-1.2: reset SuperSpeed USB device number 3 using tegra-xusb
Jul  8 16:39:55 nc-ass-vip kernel: [20356.563201] usb 2-1.2: reset SuperSpeed USB device number 3 using tegra-xusb
Jul  8 16:40:15 nc-ass-vip kernel: [20377.043089] usb 2-1.2: reset SuperSpeed USB device number 3 using tegra-xusb
Jul  8 16:40:46 nc-ass-vip kernel: [20407.754825] usb 2-1.2: reset SuperSpeed USB device number 3 using tegra-xusb
Jul  8 16:40:56 nc-ass-vip kernel: [20417.994788] usb 2-1.2: reset SuperSpeed USB device number 3 using tegra-xusb
Jul  8 16:41:01 nc-ass-vip kernel: [20423.118702] usb 2-1.2: reset SuperSpeed USB device number 3 using tegra-xusb
Jul  8 16:46:09 nc-ass-vip kernel: [20730.314984] usb 2-1.2: reset SuperSpeed USB device number 3 using tegra-xusb
Jul  8 16:46:14 nc-ass-vip kernel: [20735.694792] usb 2-1.2: reset SuperSpeed USB device number 3 using tegra-xusb
Jul  8 16:50:25 nc-ass-vip kernel: [20986.313611] usb 2-1.2: reset SuperSpeed USB device number 3 using tegra-xusb
Jul  8 16:50:30 nc-ass-vip kernel: [20991.686728] usb 2-1.2: reset SuperSpeed USB device number 3 using tegra-xusb
Jul  8 16:51:31 nc-ass-vip kernel: [21052.869476] usb 2-1.2: reset SuperSpeed USB device number 3 using tegra-xusb
Jul  8 16:51:47 nc-ass-vip kernel: [21068.225470] usb 2-1.2: reset SuperSpeed USB device number 3 using tegra-xusb
Jul  8 16:51:52 nc-ass-vip kernel: [21073.349197] usb 2-1.2: reset SuperSpeed USB device number 3 using tegra-xusb
Jul  8 16:57:19 nc-ass-vip kernel: [21401.022820] usb 2-1.2: reset SuperSpeed USB device number 3 using tegra-xusb
Jul  8 16:57:40 nc-ass-vip kernel: [21421.498433] usb 2-1.2: reset SuperSpeed USB device number 3 using tegra-xusb
Jul  8 16:59:17 nc-ass-vip kernel: [21518.776386] usb 2-1.2: reset SuperSpeed USB device number 3 using tegra-xusb
Jul  8 16:59:33 nc-ass-vip kernel: [21534.139908] usb 2-1.2: reset SuperSpeed USB device number 3 using tegra-xusb
Jul  8 17:00:24 nc-ass-vip kernel: [21586.101802] usb 2-1.2: reset SuperSpeed USB device number 3 using tegra-xusb
Jul  8 17:00:30 nc-ass-vip kernel: [21591.225602] usb 2-1.2: reset SuperSpeed USB device number 3 using tegra-xusb
Jul  8 17:01:11 nc-ass-vip kernel: [21632.184142] usb 2-1.2: reset SuperSpeed USB device number 3 using tegra-xusb
Jul  8 17:02:02 nc-ass-vip kernel: [21683.378487] usb 2-1.2: reset SuperSpeed USB device number 3 using tegra-xusb
Jul  8 17:07:50 nc-ass-vip kernel: [22031.531224] usb 2-1.2: reset SuperSpeed USB device number 3 using tegra-xusb
Jul  8 17:08:10 nc-ass-vip kernel: [22052.006684] usb 2-1.2: reset SuperSpeed USB device number 3 using tegra-xusb

It seems for me that this my USB flash drive are badly corrupted. I can’t get them back to work correctly sudo dosfsck -t -r -v -w /dev/sda1''' don't find any bad sectors. I think it comes from the way my jetson Nano are shutting down as it is done by cutting the power or doing sudo shutdown now```. I don’t have this issue on a new flash drive.

Is there a system protecting mounted devices on shutdown? Maybe I disrupted the protection doing this:

I changed fstab to automatically mount the flash drive on /media/DEVICE as by default it is mounted on /media/UUID:

cat /etc/fstab
#
#  This fstab is in RAM, the real one can be found at /mnt/root-ro/etc/fstab
#  The original entry for '/' and all swap files have been removed.  The new
#  entry for the read-only the real root fs follows. Write access can be
#  enabled using:
#    sudo mount -o remount,rw /mnt/root-ro
#  re-mounting it read-only is done using:
#    sudo mount -o remount,ro /mnt/root-ro
#

/dev/mmcblk0p1 /mnt/root-ro ext4 ro,relatime,data=ordered 0 0

#
#  remaining entries from the original /mnt/root-ro/etc/fstab follow.
#
# /etc/fstab: static file system information.
#
# These are the filesystems that are always mounted on boot, you can
# override any of these by copying the appropriate line from this file into
# /etc/fstab and tweaking it as you see fit.  See fstab(5).
#
# <file system> <mount point>             <type>          <options>                               <dump> <pass>
/dev/sda1            /media/DEVICE         vfat           defaults,nofail                              0 2
cat /mnt/root-ro/etc/fstab
# /etc/fstab: static file system information.
#
# These are the filesystems that are always mounted on boot, you can
# override any of these by copying the appropriate line from this file into
# /etc/fstab and tweaking it as you see fit.  See fstab(5).
#
# <file system> <mount point>             <type>          <options>                               <dump> <pass>
/dev/root            /                     ext4           defaults                                     0 1
/dev/sda1            /media/DEVICE         vfat           defaults,nofail                              0 2

I also changed /etc/udev/rules.d/99-nv-ufs-mount.rules to avoid any conflict changing “sd[a-z][0-9]” to “sd[b-z][0-9]”:

cat /etc/udev/rules.d/99-nv-ufs-mount.rules
#
# Copyright (c) 2019, NVIDIA CORPORATION.  All rights reserved.
#

# Mount UFS card when detected.
ACTION=="add", KERNEL=="sd[b-z][0-9]", SUBSYSTEM=="block", RUN{program}+="/usr/bin/systemd-mount --no-block --automount=yes --collect $devnode /media/%E{ID_FS_UUID}"

# Unmount UFS card when removed.
ACTION=="remove", KERNEL=="sd[b-z][0-9]", SUBSYSTEM=="block", RUN{program}+="/usr/bin/systemd-umount /media/%E{ID_FS_UUID}"

I never retrieve usb flash drive without unmouting it or being sure it is shut down.
Could you give me a clue on what’s going on? Maybe a better was to automount the first flash drive were I want?

The error shown is a USB error, and not the storage attached by USB. Thus, it isn’t a corruption issue except perhaps to the extent that corruption occurred due to USB issues. Does the USB content work on another Linux computer? Some USB errors are temporary and related to signal quality, and others are actual USB hardware failure…I don’t know from the above which it is.

Also, note that when USB is trying to run at a higher speed it may fail even though lower speed operations succeed.

Cutting power for shutdown would of course cause corruption and shouldn’t be done any more than shutting down your PC by yanking the power cable from the wall socket. However, evidence shows USB failure, not storage corruption (storage could be corrupted, but until you get past USB issues you won’t be able to distinguish cause).

If you go to a host PC running Linux, and monitor “dmesg --follow”, and then insert the USB drive, what shows up? Errors?

If this drive goes through a HUB, try direct without a HUB (including on the host PC as a comparison). If not using a HUB, then try with a HUB (it changes the signal quality issues).

You were right, it was an hardware problem, I just bought another USB flash drive and it goes fine for a couple of weeks now. Never buy an SanDisk UltraFit.

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