LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Access NAS drive (https://www.linuxquestions.org/questions/linux-newbie-8/access-nas-drive-4175556986/)

Entropy1024 10-23-2015 02:53 PM

Access NAS drive
 
I have a NAS that I can access fine with the Ubuntu GUI. However I want to access it via the CLI, unfortunately I can't figure out how.

If I look at the directory in the GUI it reads as smb://readynas.local/myfolder/

So I thought in the CLI I could access it using
Code:

ls smb://readynas.local/myfolder/
however it returns the following error:
Code:

ls: cannot access smb://readynas.local/myfolder/: No such file or directory
Why did this not work? What is the correct way to access the NAS drive?

Many thanks
Tim

/dev/random 10-23-2015 03:39 PM

Quote:

Originally Posted by Entropy1024 (Post 5439208)
I have a NAS that I can access fine with the Ubuntu GUI. However I want to access it via the CLI, unfortunately I can't figure out how.

If I look at the directory in the GUI it reads as smb://readynas.local/myfolder/

So I thought in the CLI I could access it using
Code:

ls smb://readynas.local/myfolder/
however it returns the following error:
Code:

ls: cannot access smb://readynas.local/myfolder/: No such file or directory
Why did this not work? What is the correct way to access the NAS drive?

Many thanks
Tim

Assuming it's already mounted, type mount to see where it' mounted

Code:

mount
cd to the directory of were your network attacked storage is and then do and ls.

if you need to mount it,
Code:

mount -t cifs //<ipaddress>/share /media/<some mount point>

xamaco 10-23-2015 03:49 PM

You need to mount the samba share in order for ls to access it. The 'GUI' does several things behind the scenes. If you have your file manager opened somewhere on the NAS, have a look at the /media directory. It probably contains a mount point. If you ls on it, you should see something...

To do it entirely using the CLI, you will need to do something as /dev/random suggested.

Entropy1024 10-24-2015 05:20 AM

Quote:

Originally Posted by /dev/random (Post 5439224)
Assuming it's already mounted, type mount to see where it' mounted

Code:

mount
cd to the directory of were your network attacked storage is and then do and ls.

if you need to mount it,
Code:

mount -t cifs //<ipaddress>/share /media/<some mount point>

If I do a mout command it returns the following:

Code:

sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,relatime,size=4023052k,nr_inodes=1005763,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=807876k,mode=755)
/dev/sda4 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
efivarfs on /sys/firmware/efi/efivars type efivarfs (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset,clone_children)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=21,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
mqueue on /dev/mqueue type mqueue (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
/dev/sda1 on /boot/efi type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,relatime)
tmpfs on /run/user/1001 type tmpfs (rw,nosuid,nodev,relatime,size=807876k,mode=700,uid=1001,gid=1001)
gvfsd-fuse on /run/user/1001/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1001,group_id=1001)


I'm guessing /dev/sda1 is the internal HD with the OS on it. I don't have any other drives so I'm assuming /dev/sda4 is the NAS. Would this be correct? Or is it some swap partition?

Does this then mean it is mounted? I would have thought that if the device is accessable via the GUI then it's mounted, is this not necessarily true?

If it is mounted I still am unsure how to navigate to it.

Cheers
Tim

Entropy1024 10-24-2015 05:43 AM

OK I think i'm getting closer to it working.

I created a folder called nas in /media/nas then tried:
sudo mount -t cifs //192.168.0.95/Tim /media/nas


It asked for a root password, so it was connecting to the NAS, which is a good sign.
I don't have a root password however so I gave it my admin password and it returned:
mount error(13): Permission denied

Fair enough I thought. I was thinking it will work fine if I could change the user from root to admin.

So I did a bit of research and found the username command and tried:
sudo mount -t username=admin cifs //192.168.0.95/share /media/nas

And it returned a load of help information, none of which was of help in my username problem. But I feel I am learning and am almost there. What might I try next please?

Cheers
Tim

xamaco 10-25-2015 03:21 AM

Quote:

I don't have a root password ...
With sudo, you have to give your password. In Ubuntu, there is no 'root' user.
Asssuming the NAS IP is 192.168.0.95 and it has a share named 'Tim' he command should really be :
Code:

sudo mount -t cifs //192.168.0.95/Tim /media/nas
When asked for a password, give your user password.

This being said, are you sure about the 'Tim' part of your command ?
To see the share name(s) available on your NAS, type in a console:
Code:

smbtree
You will have to give your user password and the command will display a tree-like view of all the servers and shares available...

All of this assumes your nas share is not password protected. If it's password protected, you have to give a user name and password in options following the mount command. For example:
Code:

sudo mount -t cifs //192.168.0.95/Tim /media/nas -o user=blabla,password=xyz

Entropy1024 10-25-2015 05:57 AM

Quote:

Originally Posted by xamaco (Post 5439877)
With sudo, you have to give your password. In Ubuntu, there is no 'root' user.
Asssuming the NAS IP is 192.168.0.95 and it has a share named 'Tim' he command should really be :
Code:

sudo mount -t cifs //192.168.0.95/Tim /media/nas
When asked for a password, give your user password.

This being said, are you sure about the 'Tim' part of your command ?
To see the share name(s) available on your NAS, type in a console:
Code:

smbtree
You will have to give your user password and the command will display a tree-like view of all the servers and shares available...

All of this assumes your nas share is not password protected. If it's password protected, you have to give a user name and password in options following the mount command. For example:
Code:

sudo mount -t cifs //192.168.0.95/Tim /media/nas -o user=blabla,password=xyz

Thanks for the reply. That last bit of code worked a treat.

Sorry, I must have not been clear enough with the root password bit. What I meant was that I do not have a user called root for the NAS I was trying to access, therefore I did not have a root password for the NAS I was trying to access. I do have an admin username and password. As I said I could possibly have created a root username and password and this would have worked. However I wanted to figure out what the syntax was for manually entering a user and not having it default to root, which turned out to be that 'user=xxx' which I had figured out, but I had placed it near the start of the mount command and not at the end, which evidently makes all the difference.

Cheers
Tim

Entropy1024 10-25-2015 12:53 PM

Just found out that I can view the contents of the NAS when mounted but can't write anything to it. The user/pass I used to mount the drive is read/write access. I read up about it and as far as I can make out if I add -o rw to the mount command it should load with read/write permissions. So I have unmounted the drive and tried again using:

sudo mount -t cifs //192.168.0.95/Tim ~/nastim -o rw -o user=admin,password=password

It mounts fine but just with read access only. Where am I going wrong please?

xamaco 10-26-2015 02:42 AM

You probably need to set additional options to your mount command. If you do a ls -l ~/nastim user and group columns will show 'root' or a number...
Assuming your user id is Tim and your primary group is Tim as well try to add to your options uid=Tim,gid=Tim
Code:

sudo mount -t cifs //192.168.0.95/Tim ~/nastim -o rw -o user=admin,password=password,uid=Tim,gid=Tim
All of this assume you're using a consumer NAS which generally have a very low security level. By the way, for user=xxx,password=zzz you can probably put anything you wish

You might have also to specify iocharset=utf8 in your options if you happen to use non standard characters (accented letters, etc..). Do a man mount.cifs to have access to all the bewilderingly numerous options :).

Another thing: Having the NAS mounted might slow down considerably a shutdown or reboot of your computer. Do an umount before shutdown/reboot.

There are cleaner ways to do all of this but it's partly distribution dependent...
[Edit]As you're using some kind of ubuntu you should find additional information in their Wiki and forums[/Edit]

Entropy1024 10-26-2015 04:59 AM

Quote:

Originally Posted by xamaco (Post 5440280)
You probably need to set additional options to your mount command. If you do a ls -l ~/nastim user and group columns will show 'root' or a number...
Assuming your user id is Tim and your primary group is Tim as well try to add to your options uid=Tim,gid=Tim
Code:

sudo mount -t cifs //192.168.0.95/Tim ~/nastim -o rw -o user=admin,password=password,uid=Tim,gid=Tim

Thank you so much. Adding the uid & gid it worked a treat. Finally I'm off to the races and learning lots on the way. :)

I know the command to unmount and will try and do so before shutdown. Is there a way to automatically mount on boot & unmount on shutdown, there has to be right? I'm guessing there exists a startup script on the computer somewhere that I can add the mount too, and a shutdown script for the unmount.

Many thanks again for all your help
Tim


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