Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
You are mounting filesystems (partitions) like "/dev/sda1"
So "mount /dev/sda" is wrong
Next, in order to use your command "sudo mount /dev/sda1 /mount/point" you need an existing mount point.
/ is not an existing mount point. So "sudo mount /devsda1 /media/pi/" is wrong.
If you want to mount sda1, and do not want to create a mount point first, use the command "udisks --mount /dev/sda1"
(Or you can use an existing directory as a mount point - but you will not have any access to any files already in that directory until you unmount - in other words, it is best to use a directory that contains no files - like /mnt or /var/tmp.)
If you want to use the "mount" command, create a mount point like "/media/pi/BackupDrive". Then mount on that mount point > sudo mount /dev/sda1 /media/pi/BackupDrive"
Now, for "mounting the same way it is mounted if it is removed and re inserted." you might share where it is mounted under those circumstances...
I might add that it is unusual to see a USB drive listed as /dev/sda - usually you would expect /dev/sdb or /dev/sdc
Generally, if I remember correctly, you can edit /etc/fstab and enter a line mounting that USB drive. First create a mount point - mine is /media/sdc8gig
My line in fstab:
UUID=e78ef581-0e84-407c-8072-62def0239268 /media/sdc8gig ext3 rw,nosuid,noauto,nodev,relatime,errors=continue,user_xattr,acl,barrier=1,data=ordered 0 2
noauto = prevents the partition from being mounted when your system boots (if the USB is not connected). If it's applied to an external usb partition it will automatically mount it's partition when the device is inserted. If you unmount it, and want to mount it again without removing it, (or if it is not a removable drive) use the command "sudo mount -a"
I am not sure that "noauto" or "nofail" work on distros which use systemd - have to verify that...
But then, you didn't mention which distro you are using. ???
Last edited by TxLonghorn; 02-25-2016 at 06:34 AM.
On the Raspberry pi, if you insert a usb stick, it automatically comes up in /media/pi/ and it can be unmounted from there fine. What I want to do now is remount it to exactly the same place without having to physically remove the drive and put it back in. It doesn't seem to me too much to ask, but 3 months down the road and I still can't mount it on that point. If I start mounting it elsewhere, that is going to cause massive complications, as the people using this are in no way interested in Linux, command line, computer science whatsoever, so getting them to create a mountpoint etc is just not going to happen.
Logically if a drive is mounted at a certain place, to unmount it and then remount it in the same place should be a possibility. Is this not possible then?
Only if YOU are the one mounting it, and not using the udev rules to mount it...
The problem is that the udev rules include removing the mount point when it is unmounted/ejected. The rules don't get invoked UNLESS a controller event occurs - and that controller event only happens when it gets plugged in.
If you want to MANUALLY mount things, then disable the udev rule that mounts and dismounts. Don't remove the rule that creates the device though.
Of course, if you disable the mount part of the udev rule, no OTHER devices will be mounted either.
personally I'd take @TxLonghorn advice in post #2 or a variation thereof to gain FULL control over the situation at hand.
That way you are now in charge of the entire situation. Being so. You can then deal with it how ever you want to.
Now, if that was done, it too, aids you in honing your programming skills starting you down the road to becoming a knowledgeable BASH Scrpit Programmer. With advanced skills that can be carried into another field of Linux Programming.
When using the proper experimental tools (a usb stick that it does not matter if it gets screwed up) show no fear.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.