Newbie question, where is the directory of a newly mounted SD card?

After popping my camera SD card into Jetson TX2 slot, I nearly forgot about the card until it caused a system error due to colord.service failure. Then I took following steps to correct the problem.

Ran dmesg. It reported a FAT-fs on mmcblk1p1 which “was not properly unmounted”. Then I used GUI’s SD to reformat the card to EXT4 file system type. Interestingly, the SD icon disappeared from GUI.

Reboot TX2, and ran following two commands

sudo mkfs.ext4 /dev/mmcblk1p1
sudo mount -t ext4 /dev/mmcblk1p1 /mnt

The SD icon showed up after reboot a few times and meanwhile I popped the card in and out wondering if I inserted the card properly. Anyway, eventually got the SD icon back without really doing anything.

But I still puzzled about why the SD card GUI is empty no matter what I do in the /mnt directory. The change in /mnt would not be reflected in SD GUI window.

Then I checked the mmcblk by lsblk, here is the result:

nvidia@tegra-ubuntu:~$ lsblk
NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
mmcblk0rpmb  179:24   0     4M  0 disk 
mmcblk0boot0 179:8    0     4M  1 disk 
mmcblk0boot1 179:16   0     4M  1 disk 
mmcblk0      179:0    0  29.1G  0 disk 
├─mmcblk0p1  179:1    0    28G  0 part /
├─mmcblk0p2  179:2    0     4M  0 part 
├─mmcblk0p3  179:3    0   256K  0 part 
├─mmcblk0p4  179:4    0   512K  0 part 
├─mmcblk0p5  179:5    0     3M  0 part 
├─mmcblk0p6  179:6    0     2K  0 part 
├─mmcblk0p7  179:7    0   604K  0 part 
├─mmcblk0p8  259:0    0   500K  0 part 
├─mmcblk0p9  259:1    0     2M  0 part 
├─mmcblk0p10 259:2    0     6M  0 part 
├─mmcblk0p11 259:3    0     2M  0 part 
├─mmcblk0p12 259:4    0   128M  0 part 
├─mmcblk0p13 259:5    0    32M  0 part 
├─mmcblk0p14 259:6    0    64M  0 part 
├─mmcblk0p15 259:7    0   512K  0 part 
├─mmcblk0p16 259:8    0   256M  0 part 
└─mmcblk0p17 259:9    0 646.7M  0 part 
mmcblk1      179:32   0  29.5G  0 disk 
└─mmcblk1p1  179:33   0  29.5G  0 part /media/nvidia/a83fb6f4-d15e-4c17-9a19-e700f2d87ca6

Apparently the SD card physical address turns out to be

/media/nvidia/a83fb6f4-d15e-4c17-9a19-e700f2d87ca6

I wonder what happens to /mnt directory though.

Besides, in order to unmount later, should I do
$ sudo umount /mnt
or
$ sudo umount /media/nvidia/a83fb6f4-d15e-4c17-9a19-e700f2d87ca6 ?

Not sure if I mounted the SD card properly, please share your insight.

This is the automounter picking the directory. To change the current mount location you would have to first umount it, e.g., “sudo umount /dev/mmcblk1p1”. Then mount to a new location is possible. I’m not sure where the automount config is from, but you should be able to add a specific exception for that SD card in “/etc/fstab”.

To see the UUID which can be used to name that exact partition on that exact SD card run this command while the SD card is plugged in:

blkid /dev/mmcblk1p1

The UUID itself can be used in “/etc/fstab” with various options to force a mount point. For example, you might want to make a directory just for this:

sudo -s
mkdir /mnt/custom
chmod ugo+rwx /mnt/custom
exit

I’ll use a pretend UUID of “1234-1234-1234-1234”. fstab might get this:

UUID=1234-1234-1234-1234  /mnt/custom  ext4  noauto,user  0 0

There are a lot of details which can be altered, see “man fstab”. In the above, if this exact partition is available, will cause “mount /dev/mmcblk1p1” to always mount at “/mnt/custom”. Be careful to not set options to automount if you simultaneously make it mandatory to have the partition…this is a removable device and you don’t want to make it mandatory for normal boot.

Thanks, linuxdev.

Yea, for some reason, the command below didn’t mount the directory /mnt to the device.

sudo mount -t ext4 /dev/mmcblk1p1 /mnt

I decided to redo the operation following your concept. Here are the steps I have taken:

Leave the SD card where it is. Check out it’s UUID

root@tegra-ubuntu:~# blkid /dev/mmcblk1p1
/dev/mmcblk1p1: UUID="a83fb6f4-d15e-4c17-9a19-e700f2d87ca6" TYPE="ext4"

In addition, create a temp file in the media directory, just to have something to veryfy

root@tegra-ubuntu:~# ls /media/nvidia/a83fb6f4-d15e-4c17-9a19-e700f2d87ca6
lost+found  temp

Create a subdirectory for SD card under /mnt

root@tegra-ubuntu:~# cd /mnt
root@tegra-ubuntu:/mnt# mkdir sdcard1
root@tegra-ubuntu:/mnt# chmod ugo+rwx sdcard1

Unmount the current mount for the SD card

root@tegra-ubuntu:/mnt# umount /dev/mmcblk1p1

Check the blk still exist and unmount again. The unmount should fail as the device has been unmounted already.

root@tegra-ubuntu:/mnt# blkid /dev/mmcblk1p1
/dev/mmcblk1p1: UUID="a83fb6f4-d15e-4c17-9a19-e700f2d87ca6" TYPE="ext4"
root@tegra-ubuntu:/mnt# sudo umount /dev/mmcblk1p1
umount: /dev/mmcblk1p1: not mounted

Then check the target directory, which should be empty. Then mount the SD card device to the directory. The directory should have the same content as in the media directory.

root@tegra-ubuntu:~# ls /mnt/sdcard1
root@tegra-ubuntu:~# sudo mount /dev/mmcblk1p1 /mnt/sdcard1
root@tegra-ubuntu:~# ls /mnt/sdcard1
lost+found  temp

The “temp” file is now visible under the /mnt/sdcard1 directory.

That looks correct. “lost+found” is visible on any ext2/3/4 file system at the mount point (and journals tend to make this directory rare to see as anything but empty). The reason for the UUID is for use in “/etc/fstab” so you can identify not just the fact that this is an SD card, but additionally guarantee the entry works only for that exact SD card (other SD cards would mount as usual via automount).