LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 10-23-2015, 02:53 PM   #1
Entropy1024
Member
 
Registered: Dec 2012
Location: UK
Distribution: Ubuntu 16 & 17
Posts: 131

Rep: Reputation: Disabled
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

Last edited by Entropy1024; 10-23-2015 at 03:02 PM.
 
Old 10-23-2015, 03:39 PM   #2
/dev/random
Member
 
Registered: Aug 2012
Location: Ontario, Canada
Distribution: Slackware 14.2, LFS-current, NetBSD 6.1.3, OpenIndiana
Posts: 319

Rep: Reputation: 112Reputation: 112
Quote:
Originally Posted by Entropy1024 View Post
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>
 
Old 10-23-2015, 03:49 PM   #3
xamaco
Member
 
Registered: Sep 2009
Location: Bastelicaccia, Corsica
Distribution: Crux
Posts: 48

Rep: Reputation: 7
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.
 
Old 10-24-2015, 05:20 AM   #4
Entropy1024
Member
 
Registered: Dec 2012
Location: UK
Distribution: Ubuntu 16 & 17
Posts: 131

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by /dev/random View Post
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
 
Old 10-24-2015, 05:43 AM   #5
Entropy1024
Member
 
Registered: Dec 2012
Location: UK
Distribution: Ubuntu 16 & 17
Posts: 131

Original Poster
Rep: Reputation: Disabled
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
 
Old 10-25-2015, 03:21 AM   #6
xamaco
Member
 
Registered: Sep 2009
Location: Bastelicaccia, Corsica
Distribution: Crux
Posts: 48

Rep: Reputation: 7
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
 
Old 10-25-2015, 05:57 AM   #7
Entropy1024
Member
 
Registered: Dec 2012
Location: UK
Distribution: Ubuntu 16 & 17
Posts: 131

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by xamaco View Post
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
 
Old 10-25-2015, 12:53 PM   #8
Entropy1024
Member
 
Registered: Dec 2012
Location: UK
Distribution: Ubuntu 16 & 17
Posts: 131

Original Poster
Rep: Reputation: Disabled
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?
 
Old 10-26-2015, 02:42 AM   #9
xamaco
Member
 
Registered: Sep 2009
Location: Bastelicaccia, Corsica
Distribution: Crux
Posts: 48

Rep: Reputation: 7
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]

Last edited by xamaco; 10-26-2015 at 02:50 AM. Reason: Addition
 
1 members found this post helpful.
Old 10-26-2015, 04:59 AM   #10
Entropy1024
Member
 
Registered: Dec 2012
Location: UK
Distribution: Ubuntu 16 & 17
Posts: 131

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by xamaco View Post
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Want to access NAS using Volumio mjock3 Linux - Newbie 2 02-27-2014 05:40 PM
Command Line Access to USB NAS Drive mattz40 Linux - Newbie 9 02-27-2013 01:42 PM
Can't access NAS device from nookatee Linux - Newbie 6 01-03-2011 01:31 PM
[SOLVED] Dell 705n NAS Access SqdnGuns Slackware 4 07-04-2009 08:45 PM
How to access a NAS from the command line? xpucto Linux - Server 7 10-10-2007 08:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration