how to mount USB /dev/sda,/dev/sdb,/dev/sdc/ ... only mount one fixed mount point /run/media/sda1 ?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

how to mount USB /dev/sda,/dev/sdb,/dev/sdc/ ... only mount one fixed mount point /run/media/sda1 ?

跳至解决方案
3,143 次查看
gonewithwind-peter
Senior Contributor I

Hi all,

I am playing maaxboard yocto sumo and zeus branch.

as you know, a USB  disk after unplugging and plugging again, the device  should change  from /dev/sda to /dev/sdb , /dev/sdc ... and so on.

1. in zeus branch

if I add the line :/dev/sda1 /run/media/sda1 auto defaults,sync,rw,user 0 0    in /etc/fstab,

after unplugging and plugging once , it will auto mount it at /run/media/sdb1; unplugging and plugging ,it will auto mount it at /run/media/sdc1. but our app read/write only fix at /run/media/sda1

 

how can I do that mount USB /dev/sda,/dev/sdb,/dev/sdc/ ... only mount one mount point at /run/media/sda1 ? in zeus branch?

;;;;

2. but in sumo branch, I can do it well!

I add the below lines in /etc/fstab, it works!  Although after unplugging and plugging once, the device change to /dev/sdb, sdc,sdd ... but it can always mount at the fixed mount point: /run/media/sda1!

  I added in fstab that mean I force mount sdb,sdc,sdd at /run/media/sda1

/dev/sda1 /run/media/sda1 auto rw,user,noauto 0 0
/dev/sdb1 /run/media/sda1 auto rw,user,noauto 0 0
/dev/sdc1 /run/media/sda1 auto rw,user,noauto 0 0
/dev/sdd1 /run/media/sda1 auto rw,user,noauto 0 0
/dev/sde1 /run/media/sda1 auto rw,user,noauto 0 0
/dev/sdf1 /run/media/sda1 auto rw,user,noauto 0 0
/dev/sdg1 /run/media/sda1 auto rw,user,noauto 0 0

...

 

In zues, I added the same,  but it did not work. it worked as I described in 1.

 

How can I do?

 

any help?

 

Thank you very much.

 

 

 

 

 

0 项奖励
回复
1 解答
3,111 次查看
gonewithwind-peter
Senior Contributor I
I have found the solution  after modified the file  /etc/udev/rules.d/11-usb.rules  that  avnet technical supporter   gave to me
 
KERNEL=="sd[a-z]", NAME="%k", SYMLINK+="sda1", GROUP="users"
ACTION=="add", KERNEL=="sd[a-z][0-9]", SYMLINK+="usbhd-%k", GROUP="users", NAME="%k"
ACTION=="add", KERNEL=="sd[a-z][0-9]", RUN+="/bin/mkdir -p /run/media/sda1"
ACTION=="add", KERNEL=="sd[a-z][0-9]", RUN+="/bin/mount -t auto -o rw,noauto,sync,dirsync,noexec,nodev,noatime /dev/%k /run/media/sda1"
ACTION=="remove", KERNEL=="sd[a-z][0-9]", RUN+="/bin/umount -l /run/media/sda1"
ACTION=="remove", KERNEL=="sd[a-z][0-9]", RUN+="/bin/rm -rf /run/media/sda1"
 
and add lines the /etc/fstab
 
/dev/sda1 /run/media/sda1 auto rw,user,noauto 0 0
/dev/sdb1 /run/media/sda1 auto rw,user,noauto 0 0
/dev/sdc1 /run/media/sda1 auto rw,user,noauto 0 0
/dev/sdd1 /run/media/sda1 auto rw,user,noauto 0 0
/dev/sde1 /run/media/sda1 auto rw,user,noauto 0 0
/dev/sdf1 /run/media/sda1 auto rw,user,noauto 0 0
/dev/sdg1 /run/media/sda1 auto rw,user,noauto 0 0
...

在原帖中查看解决方案

3 回复数
3,112 次查看
gonewithwind-peter
Senior Contributor I
I have found the solution  after modified the file  /etc/udev/rules.d/11-usb.rules  that  avnet technical supporter   gave to me
 
KERNEL=="sd[a-z]", NAME="%k", SYMLINK+="sda1", GROUP="users"
ACTION=="add", KERNEL=="sd[a-z][0-9]", SYMLINK+="usbhd-%k", GROUP="users", NAME="%k"
ACTION=="add", KERNEL=="sd[a-z][0-9]", RUN+="/bin/mkdir -p /run/media/sda1"
ACTION=="add", KERNEL=="sd[a-z][0-9]", RUN+="/bin/mount -t auto -o rw,noauto,sync,dirsync,noexec,nodev,noatime /dev/%k /run/media/sda1"
ACTION=="remove", KERNEL=="sd[a-z][0-9]", RUN+="/bin/umount -l /run/media/sda1"
ACTION=="remove", KERNEL=="sd[a-z][0-9]", RUN+="/bin/rm -rf /run/media/sda1"
 
and add lines the /etc/fstab
 
/dev/sda1 /run/media/sda1 auto rw,user,noauto 0 0
/dev/sdb1 /run/media/sda1 auto rw,user,noauto 0 0
/dev/sdc1 /run/media/sda1 auto rw,user,noauto 0 0
/dev/sdd1 /run/media/sda1 auto rw,user,noauto 0 0
/dev/sde1 /run/media/sda1 auto rw,user,noauto 0 0
/dev/sdf1 /run/media/sda1 auto rw,user,noauto 0 0
/dev/sdg1 /run/media/sda1 auto rw,user,noauto 0 0
...
3,132 次查看
Rita_Wang
NXP TechSupport
NXP TechSupport

Could you tell us which board are you using?

0 项奖励
回复
3,124 次查看
gonewithwind-peter
Senior Contributor I
0 项奖励
回复