Where is the default configuration location for USB plug and unplug detection, mounting, and processing in the Ubuntu system?

Which system do you use? Android, Ubuntu, OOWOW or others?

Ubuntu

Which version of system do you use? Khadas official images, self built images, or others?

self built images

Please describe your issue below:

I want to configure and modify the name of the file mounted on the USB drive:
May I ask,
Where is the default configuration location for USB plug and unplug detection, mounting, and processing in the Ubuntu system?

If you are on minimal/server version, you need to mount it manually using mount command and the storage device will be on /dev/sda typically, so you can mount it like

$ mkdir 1
$ mount /dev/sda1 1
$ cd 1

you can check what devices are there through
$ ls /dev/ | grep sda

If you are on desktop, just check /run/media/khadas, it will be another subdirectory which is the disk name. again you can check devices as
$ ls /run/media/khadas

Thank you for your answer,!but no, you didn’t understand my intention.

I want to know, how can I configure the default insertion and removal of USB drives to automatically mount the directory name I defined, and where can I modify it?

I directly added/dev/sda1/media/usb0 ntfs defaults 0 0in/etc/fstab,but there was a problem where I didn’t insert a USB drive to start the system, and I saw that the log would start slowly

@Lexus

1.This method only works on fixed storage devices.
2.Try udev rules to automatically mount the USB disk.

sudo vim /etc/udev/rules.d/99-usbstick.rules
KERNEL=="sd[b-z][0-9]", SUBSYSTEMS=="usb", ACTION=="add", RUN+="/sbin/mount UUID=YOUR-UUID /media/xxx"
YOUR-UUID Obtain:
lsblk -f
blkid /dev/xxx
sudo systemctl restart udev
1 Like

@ivan.li hi,
How to restrict static fixed uuids?
For example, if I create an IMG format image and want to mount it using a pre known UUID, how can I restrict the UUID from being fixed and unchanging

Burn the firmware to the storage device, the uuid value should not change.

@ivan.li hello,
I tested here and found that it changed. I made a userdata.img package and burned it in, and the uuid changed:

One. I have finished making it, and the uuid for it is:
userdata.img: UUID="89591460-c976-4a53-b530-0d0f66d12ccf" TYPE="ext2"
Two. I burned the system to view:
UUID="fe168cdc-0732-4e3d-84ff-f79524046fba"

So it’s different, how to restrict fixed uuids

If you format or partition the storage device, the uuid value will change.