LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Mount drive (https://www.linuxquestions.org/questions/linux-newbie-8/mount-drive-4175573189/)

iFunction 02-25-2016 04:50 AM

Mount drive
 
Hi there,

I've been struggling with this now for months, but I can't seem to mount a drive successfully unless it is removed and then re inserted again, doing:
Code:

sudo mount /dev/sda /media/pi/
appears to mount the drive, yet running:
Code:

ls /media/pi/
returns nothing.

I've also tried:
Code:

sudo mount /dev/sda1 /media/pi/
returns
Code:

mount: special device /dev/sda1 does not exist
What's going on, how can I mount this from the command line the same way it is mounted if it is removed and re inserted.

Kind regards
iFunc

TxLonghorn 02-25-2016 05:38 AM

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. ???

iFunction 02-25-2016 05:50 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?

jpollard 02-25-2016 06:02 AM

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.

iFunction 02-25-2016 06:21 AM

Ok, thank you, that's very clear now, I can come up with another option.

BW-userx 02-25-2016 06:52 AM

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.


All times are GMT -5. The time now is 09:47 AM.