Tiny Core Linux
General TC => General TC Talk => Topic started by: MadCat on May 15, 2011, 11:15:26 AM
-
Hello. I am currently trying to automatically have USB Devices automounted using rules under the rules.d folder. I have currently tried making a automount.rules (Which I read from another website) and adding the following below to it. But, I take this wont work because Tiny Core does not come with pmount?
# automounting usb flash drives
# umask is used to allow every user to write on the stick
# we use --sync in order to enable physical removing of mounted memory sticks -- this is OK for fat-based sticks
# I don't automount sda since in my system this is the internal hard drive
# depending on your hardware config, usb sticks might be other devices than sdb*
ACTION=="add",KERNEL=="sdb*", RUN+="/usr/bin/pmount --sync --umask 000 %k"
ACTION=="remove", KERNEL=="sdb*", RUN+="/usr/bin/pumount %k"
ACTION=="add",KERNEL=="sdc*", RUN+="/usr/bin/pmount --sync --umask 000 %k"
ACTION=="remove", KERNEL=="sdc*", RUN+="/usr/bin/pumount %k"
-
Anybody out there?
-
I am not completely sure what you are trying to do, but
To mount usb drives at startup, add mount commands to /opt/bootlocal.sh.
-
Hi MadCat
I'm not versed in writing udev rules but if the rules you have listed are correct then changing
pmount and pumount to mount and umount should make it work.
-
I am not completely sure what you are trying to do, but
To mount usb drives at startup, add mount commands to /opt/bootlocal.sh.
Im trying to get it that when you plug in a USB Device it automounts the device without having to restart Tiny Core, or am I totally on the wrong track here? :/
-
Hi MadCat
I got what you are trying to do, if my previous suggestion does not work, here is a post that goes
into some details of udev rules.
http://forum.tinycorelinux.net/index.php?topic=9037.msg49115#msg49115
-
Unfortunately that is only for startup "Which works btw". But I need to figure out how to get it to mount WITHOUT having to restart the terminal first. Any ideas?
-
*Bump*
-
Did you try substituting mount for pmount and umount for pumount in this?
ACTION=="add",KERNEL=="sdb*", RUN+="/usr/bin/pmount --sync --umask 000 %k"
ACTION=="remove", KERNEL=="sdb*", RUN+="/usr/bin/pumount %k"
ACTION=="add",KERNEL=="sdc*", RUN+="/usr/bin/pmount --sync --umask 000 %k"
ACTION=="remove", KERNEL=="sdc*", RUN+="/usr/bin/pumount %k"
-
Did you try substituting mount for pmount and umount for pumount in this?
ACTION=="add",KERNEL=="sdb*", RUN+="/usr/bin/pmount --sync --umask 000 %k"
ACTION=="remove", KERNEL=="sdb*", RUN+="/usr/bin/pumount %k"
ACTION=="add",KERNEL=="sdc*", RUN+="/usr/bin/pmount --sync --umask 000 %k"
ACTION=="remove", KERNEL=="sdc*", RUN+="/usr/bin/pumount %k"
Unfortunately doing it THAT way does not work. And mount/umount is sitting under /bin/mount and /bin/umount I believe. Not /usr/bin/mount and /usr/bin/umount. Eitherway, that only works if u plug in a Flash Drive and startup the terminal. Im needing a solution so that when I plug in Flash Drives while the terminal is on it auto mounts them without me having to mount /mnt/bla bla
-
Hi MadCat
As I said, I'm not versed in udev rules, but try this.
ACTION=="add",KERNEL=="sd[b-z][0-9]", RUN+="sudo /bin/mount --sync /dev/%k mnt/%k"
ACTION=="remove", KERNEL=="sd*", RUN+="bin/umount -l %k"
Then open a terminal and enter this udevadm control --reload-rules
Plug in a memory stick and see if it is accessible under /mnt
This presumes that you have an internal drive labeled sda and wish to exclude it from hot plugging.
If that's not the case then sd[b-z][0-9] should be sd[a-z][0-9]
-
Check 98-tc.rules in /etc/udev/rules.d
KERNEL=="ram*", SUBSYSTEM=="block", GOTO="tc.rules_end"
KERNEL=="loop*", SUBSYSTEM=="block", GOTO="tc.rules_end"
ACTION=="add", SUBSYSTEM=="block", RUN+="/bin/sh -c '/usr/sbin/rebuildfstab'"
ACTION=="remove", SUBSYSTEM=="block", RUN+="/bin/sh -c '/usr/sbin/rebuildfstab'"
LABEL="tc.rules_end"
This rule handles block device add and remove executing rebuildfstab. Look like a good starting point.
Replace it with a new rule set:
KERNEL=="ram*", SUBSYSTEM=="block", GOTO="tc.rules_end"
KERNEL=="loop*", SUBSYSTEM=="block", GOTO="tc.rules_end"
ACTION=="add", SUBSYSTEM=="block", RUN+="/bin/sh -c '/usr/local/sbin/xxx %k'"
ACTION=="remove", SUBSYSTEM=="block", RUN+="/bin/sh -c '/usr/local/sbin/yyy %k'"
LABEL="tc.rules_end"
Here we are calling two shell scripts. Do not forget to reload rules with
sudo udevadm control --reload-rules
Now, the related scripts.
xxx is mounting partition after rebuildfstab:
#!/bin/sh
rebuildfstab
sleep 3
mount /dev/$1 /mnt/$1
yyy is executing umount and removes the mounting directory in /mnt:
#!/bin/sh
umount /mnt/$1
sleep 1
rmdir /mnt/$1
rebuildfstab
sleep commands are for safety, maybe it can be removed or delay changed-
Try, it works. Simple, isn't it ?
-
And mount/umount is sitting under /bin/mount and /bin/umount I believe. Not /usr/bin/mount and /usr/bin/umount.
Have you considered symlinking?
-
When you plan to automount USB flash drives, have you also planned for the case of filesystems being unclean?
Which filesystem types do you plan to automount?
-
KERNEL=="ram*", SUBSYSTEM=="block", GOTO="tc.rules_end"
KERNEL=="loop*", SUBSYSTEM=="block", GOTO="tc.rules_end"
ACTION=="add", SUBSYSTEM=="block", RUN+="/bin/sh -c '/usr/local/sbin/xxx %k'"
ACTION=="remove", SUBSYSTEM=="block", RUN+="/bin/sh -c '/usr/local/sbin/yyy %k'"
LABEL="tc.rules_end"
Done so. Created 2 files called xxx.sh and yyy.sh in /usr/local/sbin as it was required. So now my 98-tc.rules basically looks like the following below.
KERNEL=="ram*", SUBSYSTEM=="block", GOTO="tc.rules_end"
KERNEL=="loop*", SUBSYSTEM=="block", GOTO="tc.rules_end"
ACTION=="add", SUBSYSTEM=="block", RUN+="/bin/sh -c '/usr/local/sbin/xxx.sh %k'"
ACTION=="remove", SUBSYSTEM=="block", RUN+="/bin/sh -c '/usr/local/sbin/yyy.sh %k'"
LABEL="tc.rules_end"
sudo udevadm control --reload-rules
Then added the following to the 2 files
xxx.sh
#!/bin/sh
rebuildfstab
sleep 3
mount /dev/$1 /mnt/$1
yyy.sh
#!/bin/sh
umount /mnt/$1
sleep 1
rmdir /mnt/$1
rebuildfstab
Result. It doesn't work... It doesn't even seem to get as far as rebuildfstab since no drives are even recognized when you insert a USB... What a mission to get USB to automount :S
-
After trying for a few days I have come to the conclusion its time for me to move onto another Distro. Tiny Core seems great but Ive already spent a few days just trying to get USB to Automount. Ive decided to move on and try Thin Station, and to my relief comes in @ 8MB ISO, USB Automounting and RDesktop which I am able to redirect USB Devices. And to my amazement I got it all working in under 10minutes... So no offense to Tiny Core, but if anybody else gets stuck trying to get a Thin Client going, there you go.
-
why not using hal and dbus (extensions in repos) instead with a backup, which should give you what you want within a minute?
-
why not using hal and dbus (extensions in repos) instead with a backup, which should give you what you want within a minute?
Doesant work on Tiny Core...
-
?? did you try them ? and did you do a backup for the extension and related files to be loaded on boot ? i must confess that i used them once on 2.x versions of TC and can not speak for 3.x, but they did work.
maybe a question/suggestion: every usb should be mounted as sda, sdb, sdc etc. did you try a script loaded on boot with a command like: sudo mount -a /dev/sd*
how many usb should you mount on boot? if it is always the same ones, you can customize it with a script loaded on boot. i think that microcore with such a (backed up) script should be not go beyond 8 MB.
-
With udev you do not need to deal with device name. It is provided by udev as %k variable, see my demo script above. For testing you can write it to a file for example to see what happens inserting an usb. Also, use udevadm's monitor function to see what is going on.
It is a 5 minutes lesson.
-
?? did you try them ? and did you do a backup for the extension and related files to be loaded on boot ? i must confess that i used them once on 2.x versions of TC and can not speak for 3.x, but they did work.
maybe a question/suggestion: every usb should be mounted as sda, sdb, sdc etc. did you try a script loaded on boot with a command like: sudo mount -a /dev/sd*
how many usb should you mount on boot? if it is always the same ones, you can customize it with a script loaded on boot. i think that microcore with such a (backed up) script should be not go beyond 8 MB.
Yea, myself and another guy tried to get it working. Refused to mount USB when the terminal was on... Best we could get was Mounting USB @ Start which basically defeated the point of wanting to turn Tiny Core into a Thin Client OS. Eitherway it seem ThinStation is the way to go...
-
With udev you do not need to deal with device name. It is provided by udev as %k variable, see my demo script above. For testing you can write it to a file for example to see what happens inserting an usb. Also, use udevadm's monitor function to see what is going on.
It is a 5 minutes lesson.
You fail to realize your script refused to get to the rebuildfstab command, go test it and see...
-
With udev you do not need to deal with device name. It is provided by udev as %k variable, see my demo script above. For testing you can write it to a file for example to see what happens inserting an usb. Also, use udevadm's monitor function to see what is going on.
It is a 5 minutes lesson.
You fail to realize your script refused to get to the rebuildfstab command, go test it and see...
Well, it was tested becuse submitted. Also, you are missing to relize that working with linux requires self education, testing, etc. An investment. Seems a specialized system like TC is not for you. That's fine, but if you are not willing to do so, better to use something else instead of being negative.
-
With udev you do not need to deal with device name. It is provided by udev as %k variable, see my demo script above. For testing you can write it to a file for example to see what happens inserting an usb. Also, use udevadm's monitor function to see what is going on.
It is a 5 minutes lesson.
You fail to realize your script refused to get to the rebuildfstab command, go test it and see...
Well, it was tested becuse submitted. Also, you are missing to relize that working with linux requires self education, testing, etc. An investment. Seems a specialized system like TC is not for you. That's fine, but if you are not willing to do so, better to use something else instead of being negative.
No, It does not work... And I am not being negative. Anyways, I am going to refrain from posting since this I have already achieved my goal. Goodbye
-
As the questions of Reply #13 have been ignored I am not that unhappy that indiscriminate automounting doesn't work easily.
Coping with the potential consequences might take more than just some quick scripting...
-
let's be positive, you should try a bit with linux and tc/mc is not often that easy, the learning curve can be a bit demanding, but it pays off. i have had similar problems with automount on several tiny client, and it was easy to set them up with bela's similar proposal or one of others like mines. feel free to get another try just in order to train, and tc/mc is good a that.
-
Hi Guys,
I have also been wanting to automount usb sticks on tinycore and came across this thread. I have to add that the info from "bmarkus" DOES work. Initially the scripts wouldn't work and i was having the same issue as MadCat but i found the solution was file permissions.
Once i had applied executable permisions to the 2 script files with the chmod command it works!
I know this is an old thread but it helped me and may help someone else.
Thanks for the great forum and keep up the good work. :)
-
BigBas,
thanks for the confirmation it works. I will add it to WiKi.
-
Hi,
For whatever it's worth, this worked fine for me and is exactly what I was looking for.
Thanks Béla et al!
Cheers,
-
Thanks bmarkus,
10 years later and this information is still useful, thanks for the help.
Regards
Johann