john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

Mount ntfs 3g windows network shares cifs fstab smbfs

Linux can connect to everything but it's not always simple

NTFS-3G (aka read/write access an NTFS formatted partition through linux)

CENTOS = You should follow the instructions on adding the rpmforge repo: http://wiki.centos.org/AdditionalResources/Repositories/RPMForge

yum install fuse yum install fuse-ntfs-3g

fdisk -l //list all attached and recognized storage devices

sudo mount -t ntfs-3g /dev/sdc1 /mnt/usb-ntfs-drive ls /mnt/usb-ntfs-drive

when finished it's nice to unmount the drive/partition sudo umount /mnt/usb-ntfs-drive

mount /dev/sda1 /mnt/usb //this trusts mount to detect the file system

ntfs-3g /dev/hda1 /mnt/windows //this uses the ntfs-3g directly


NOTE: To formally mount an FAT32 or FAT16 drive (without automounting or autofs) you should use: mount -t vfat /dev/sda1 /mnt/sda1



How to access a windows share from Centos (smbfs is deprecated in favor of cifs)

First Centos 5.3 aka Red Hat minimal installation needs some files:

yum install samba-client
//The samba-client.i386 : Samba (SMB) client programs has the drivers

sudo apt-get install cifs-utils

mount.cifs -V (version number) (apt-get install smbfs)

THE EXACT SYNTAX AND ORDER IS IMPORTANT! mount.cifs -o

mount.cifs //192.168.1.35/external /mnt/backup -o username=DOMAIN/username mount.cifs //10.10.10.245/shared /mnt/testdir -o guest (guest is for shares without credentials)

mount.cifs //10.10.10.245/shared /mnt/testdir # prompted for password, press enter if it's anonymous readable



sudo apt-get install samba-client = libtalloc2 libwbclient0 samba-common samba-common-bin smbclient sudo apt-get install smbfs = keyutils libtalloc2 libwbclient0 samba-common samba-common-bin smbfs

(why one over the other?!?!)

mkdir /mnt/winshare Manually test if the network share is available:

sudo mount -t cifs //winservername/sharename /mnt/temp -o username=domain/user (prompts for a password) mount -t cifs -o username=domain\user //192.168.1.9/share /mnt/temp sudo mount.cifs //10.10.10.235/winshare /mnt/winshare -o user=winshareuser,password=PASSWORD

Manually stop the network share mount: sudo umount /mnt/winshare

PERMANENT CONFIGURATION INCLUDING REBOOTS (LOCATION OF MOUNTS)

sudo nano /etc/fstab //10.10.10.235/winshare /mnt/winshare cifs uid=106,user,noexec,credentials=/etc/cifspassword 0 0

sudo nano /etc/cifspassword username=winshareuser password=PASSWORD

domain=value (DEPRECATED, INSTEAD IT SHOULD BE domain/username in the username= )

sudo mount -a (will use the fstab file to try and mount all)

NOTE: If using "special requirements" it requires a UID for an owner //10.10.10.235/winshare /mnt/winshare cifs uid=106,user,noexec,file_mode=0666,dir_mode=0777,credentials=/etc/cifspassword 0 0

CIFS access in the iptables firewall /sbin/iptables -A INPUT -p tcp -s 10.10.10.250 --sport 445 -d 0/0 -j ACCEPT /sbin/iptables -A OUTPUT -p tcp -s 0/0 --sport 1024:65535 -d 10.10.10.250 --dport 445 -m state --state NEW,ESTABLISHED -j ACCEPT

Alternatively, use the startup scripts at /etc/init.d with the manual mount commands


TROUBLESHOOTING the mount cifs of a windows share:

IF YOU DON'T INSTALL samba-client:

mount: wrong fs type, bad option, bad superblock on //192.168.1.9/CentOS-5.3-x86_64-bin-DVD

   missing codepage or other error
   In some cases useful info is found in syslog - try
   dmesg | tail  or so

yeah, that error doesn't say anything about samba-client... but that's what you get without the drivers (therefore CIFS depends on samba)

Are you connecting to the "root" of your share? (e.g. the network share is /external, so mount it, don't try to mount /external/subfolder)

Did you include the DOMAIN?

Try the ip address instead of the netbios name.

A windows share can have SHARE permissions (everyone read only at least!) AND NTFS security permissions (your specific user with at least read!) (everyone read only too?)


TO SHARE FILES from Linux for Windows USING SAMBA:

pam_smb.i386 : A Pluggable Authentication Module (PAM) for use with SMB servers. samba.i386 : The Samba SMB server.

samba-swat.i386 : The Samba SMB server configuration program.

mount -t smbfs -o username=winntuser,password=mypassword //windowsserver/sharename /mnt/win

if you leave out the password you will be prompted



smbfs is deprecated in favor of cifs ( Ubuntu)

apt-get install smbfs //required as a metapackage for netw mounts sudo aptitude install winbind

sudo mount -t cifs //netbiosname/sharename /media/sharename -o username=winusername,password=winpassword,iocharset=utf8,file_mode=0777,dir_mode=0777

4th column options

auto and noauto = bootup mounted or not

user and nouser = normal users or only root can

exec and noexec = allow executable binaries to run on the mount (or not)

ro = read only rw = read write

sync and aysnc = forces the file system to commit writes immediately

defaults: rw, suid, dev, exec, auto, nouser, and async.

5th & 6th = dump backup utility and filesystem check utility

But FUSE does not allow unprivileged users to mount NTFS?



2007-11-08 INSTALL SAMBA ON LINUX AND SHARE FILES FOR WINDOWS CLIENTS

Samba //http://us1.samba.org/samba/

apt-get install samba //installed samba 3.0.28a

smbclient -L localhost //shows what your sharing currently with samba (promts for root pass)

/etc/init.d/samba reload //or 'status'

/etc/samba/smb.conf //configuration file for samba

workgroup & hostname can probably be the default, ensure that you have a static ip or that dns is going to map to your hostname properly...

hosts.allow //also /etc/hosts.allow can tighten up security if required also note that "invalid users = root"

You can have samba use Domain authentication but in our case we want to just use a linux user & pass to control access to our folder

security = user

I have commented out usershare allow guests //I don't want users to share things for anon!

Printer sharing & Cups is also available (if your linux box is going to be a print server)

[projects] path = /folder/projects valid users = user1, user2 read only = No //capital N... public = no writable = yes printable = no //important so that windows doesn't treat it as a printer! write list = user1, user2 //not sure if this important but it worked

Then exit & save the smb.conf file... and set the following permsissions

chmod -R ug+rwx,g+s,o-rwx /folder/projects //ensure projects is rwx for owner & group

In this case I also had to add user1 to the group that was the owner of the /path directory e.g. sudo usermod -aG www-data user1

Then... /etc/init.d/samba restart


To Test your /etc/samba/smb.conf file you can use "testparm" at the command line.

To see the current status, type, "smbstatus" at the command prompt.


//is this necessary? create mask = 0760 ?


TO ACCESS A SHARED FOLDER ON A WINDOWS COMPUTER FROM A LINUX CLIENT USING MOUNT AND SMBFS

mkdir -p /mnt/win // -p, --parents no error if existing, make parent directories as needed

mount -t smbfs -o username=winntuser,password=mypassword //windowsserver/sharename /mnt/win

cd /mnt/win

ls -l

chmod -R 777 /mnt/win/public //perhaps unnecessary step

The normal place to mount file systems is /etc/fstab (connects/mounts them on boot up) Modify it to read

//anders-crm/linux-backups /mnt/linux-backups smbfs username=backup,password=4a$ 0 0

Rerun the fstab configuration commands (without rebooting) by using: mount -a

Alternatively, the catch all start up place for linux scripts is /etc/init.d where you can type in something similar to the manual mount instructions above


  • « Mount cdrom drive apple file system afp
  • Openssl ca authority ubuntu trust ca chromium nginx chain »

Published

Oct 8, 2013

Category

linux

~1028 words

Tags

  • 3g 2
  • cifs 2
  • fstab 3
  • linux 249
  • mount 7
  • network 20
  • ntfs 4
  • shares 1
  • smbfs 1
  • windows 72