WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: usb mount  (Read 5678 times)

Offline jbbum

  • Newbie
  • *
  • Posts: 39
usb mount
« on: June 26, 2019, 12:08:40 PM »
Where and how does piCore update fstab when usb device is attached.  Would like to add a mount command to the fstab update function.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: usb mount
« Reply #1 on: June 26, 2019, 12:25:23 PM »
Hi jbbum
The update is initiated by  udev. I think it happens in  /etc/udev/rules.d/98-tc.rules.  Look for the lines containing  rebuildfstab.

Offline jbbum

  • Newbie
  • *
  • Posts: 39
Re: usb mount
« Reply #2 on: June 26, 2019, 01:07:01 PM »
Thanks Rich. 

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: usb mount
« Reply #3 on: June 26, 2019, 01:51:34 PM »
You can run 'updatefstab' command manually or in a script to update fstab.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline Greg Erskine

  • Sr. Member
  • ****
  • Posts: 404
Re: usb mount
« Reply #4 on: June 26, 2019, 04:47:36 PM »
Just a couple of points, I think...

/etc/fstab is dynamically created during the boot process by rebuildfstab, unless the nofstab bootcode is set .

Mounts have "noauto" option set automatically so $ mount -a isn't much use.

Offline jbbum

  • Newbie
  • *
  • Posts: 39
Re: usb mount
« Reply #5 on: June 26, 2019, 07:52:06 PM »
I added a mount command at approximate line #88 in rebuildfstab to mount $DEVNAME.  Added it in the if statement that checks if device is already mounted and right after the mkdir command.

mount /dev/$DEVNAME /mnt/$DEVNAME

This automounts usb devices for a photo frame controlled by python

Offline Greg Erskine

  • Sr. Member
  • ****
  • Posts: 404
Re: usb mount
« Reply #6 on: June 26, 2019, 09:36:03 PM »
hi jbbum,

It might be better if you add your mount command in /opt/bootsync.sh. This gets backed up and will be persistent. /opt/bootsync.sh and /opt/bootlocal.sh are there for adding commands that need to run at startup.

Usually, it's best not to modify TinyCore/piCore commands.

I haven't used piCore for a while, but there was a stage where USB drives did automatically mount, via udev I think.

rebuildfstab runs during the boot process and also when you hot plug USB disks.

The mount command can be just $ mount /dev/$DEVNAME as the command uses the mount point found in /etc/fstab.

regards
Greg

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: usb mount
« Reply #7 on: June 26, 2019, 10:27:22 PM »
Hi Greg Erskine
... I haven't used piCore for a while, but there was a stage where USB drives did automatically mount, via udev I think. ...
I think that's what he is looking to accomplish, auto mounting USB drives when they get plugged in.

Offline jbbum

  • Newbie
  • *
  • Posts: 39
Re: usb mount
« Reply #8 on: June 27, 2019, 12:46:12 PM »
Rich,  that is exactly the procedure I am trying to do.  My python script reads the dirs in /mnt and provides a button to open and display the images from that dir.  So when a usb drive is inserted the images are available to the photoframe.  This is all done on a touch screen, no keyboard.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: usb mount
« Reply #9 on: March 23, 2020, 11:30:22 AM »
Hi jbbum
If you are interested, there is an automount script I wrote posted here:
http://forum.tinycorelinux.net/index.php/topic,23337.0.html

I've been running it for about 5 months now and it works quite well.