14/6/2016
MountWindowsSharesPermanentlyUbuntuWiki
HalamanKekal
Info
Lampiran
LebihBanyakAksi:
UbuntuWiki
Login
Help
MountWindowsSharesPermanently
ThisdocumentdescribeshowtomountCIFSsharespermanently.Thesharesmightbe
hostedonaWindowscomputer/server,oronaLinux/UNIXserverrunningSamba.
ThisdocumentalsoappliestoSMBFSshares,whicharesimilartoCIFSbutare
deprecatedandshouldbeavoidedifpossible(link).
DaftarIsi
(Thisdocumentdoesnotdescribehowtohostthesharesyourself,onlyhowtoaccess
sharesthatarehostedsomewhereelse.Forhostingshares,useSamba.)
Prerequisites
We'reassumingthat:
Networkconnectionshavebeenconfiguredproperly.
Yourlocal(Ubuntu)usernameisubuntuusername.
ShareusernameonWindowscomputerismsusername.
1.Prerequisites
2.CIFSinstallation
3.Mountingunprotected(guest)networkfolders
4.Mountpasswordprotectednetworkfolders
1.Specialpermissions
2.Mountpasswordprotectedsharesusing
libpam_mount(Ubuntu9.04)
5.Troubleshooting
1.Loginerrors
2.Unprotectednetworkfolderwon'tautomount
3.Mountduringlogininsteadofboot
4.SlowshutdownduetoaCIFS/NetworkManager
bug
5.CIFSOptionsDeprecated
6.Useoftildeinpathnamessuchas
"credentials=~/.smbcredentials"
SharepasswordonWindowscomputerismspassword.
TheWindowscomputer'snameisservername(thiscanbeeitheranIPaddressoranassignedname).
Thenameoftheshareissharename.
Youwanttomountthesharein/media/windowsshare.
CIFSinstallation
sudoaptgetinstallcifsutils
Onoldersystems:
sudoaptgetinstallsmbfs
Mountingunprotected(guest)networkfolders
First,let'screatethemountdirectory.Youwillneedaseparatedirectoryforeachmount.
sudomkdir/media/windowsshare
Thenedityour/etc/fstabfile(withrootprivileges)toaddthisline:
//servername/sharename/media/windowssharecifsguest,uid=1000,iocharset=utf800
Where
guestindicatesyoudon'tneedapasswordtoaccesstheshare,
uid=1000makestheLinuxuserspecifiedbytheidtheownerofthemountedshare,allowingthemtorenamefiles,
iocharset=utf8allowsaccesstofileswithnamesinnonEnglishlanguages.Thisdoesn'tworkwithsharesofdevicesliketheBuffaloTera
Station,orWindowsmachinesthatexporttheirsharesusingISO889515.
Ifthereisanyspaceintheserverpath,youneedtoreplaceitby\040,forexample//servername/My\040Documents
Afteryouaddtheentryto/etc/fstabtype:
sudomounta
Thiswill(re)mountallentrieslistedin/etc/fstab.
Mountpasswordprotectednetworkfolders
Thequickestwaytoautomountingapasswordprotectedshareistoedit/etc/fstab(withrootprivileges),toaddthisline:
//servername/sharename/media/windowssharecifsusername=msusername,password=mspassword,iocharset=utf8,sec=ntlm00
Thisisnotagoodideahowever:/etc/fstabisreadablebyeveryoneandsoisyourWindowspasswordinit.Thewayaroundthisistouseacredentials
file.Thisisafilethatcontainsjusttheusernameandpassword.
https://wiki.ubuntu.com/MountWindowsSharesPermanently
1/3
14/6/2016
MountWindowsSharesPermanentlyUbuntuWiki
Usingatexteditor,createafileforyourremoteserverslogoncredential:
gedit~/.smbcredentials
EnteryourWindowsusernameandpasswordinthefile:
username=msusername
password=mspassword
Savethefile,exittheeditor.
Changethepermissionsofthefiletopreventunwantedaccesstoyourcredentials:
chmod600~/.smbcredentials
Thenedityour/etc/fstabfile(withrootprivileges)toaddthisline(replacingtheinsecurelineintheexampleabove,ifyouaddedit):
//servername/sharename/media/windowssharecifscredentials=/home/ubuntuusername/.smbcredentials,iocharset=utf8,sec=ntlm00
Savethefile,exittheeditor.
Finally,testthefstabentrybyissuing:
sudomounta
Iftherearenoerrors,youshouldtesthowitworksafterareboot.Yourremoteshareshouldmountautomatically.
Specialpermissions
Ifyouneedspecialpermission(likechmodetc.),you'llneedtoaddauid(shortfor'userid')orgid(for'groupid')parametertotheshare'smount
options.
//servername/sharename/media/windowssharecifsuid=ubuntuuser,credentials=/home/ubuntuuser/.smbcredentials,iocharset=utf8,sec=ntlm00
Mountpasswordprotectedsharesusinglibpam_mount(Ubuntu9.04)
Inadditiontotheinitialassumptions,we'reassumingthat
YourusernameandpasswordarethesameontheUbuntumachineandonthenetworkdrive.
Installlibpammount:
sudoaptgetinstalllibpammount
Edit/etc/security/pam_mount.conf.xmlusingyourpreferredtexteditor.
gksudogedit/etc/security/pam_mount.conf.xml
First,we'removingtheuserspecificconfigbitstoafilewhichuserscanactuallyeditthemselves:removethecommentingtags(<!and>)
surroundingthesectioncalled<luserconfname=".pam_mount.conf.xml"/>.Savethefilewhendone.Withthisinplace,userscancreatetheirown
~/.pam_mount.conf.xml.
gedit~/.pam_mount.conf.xml
Addthefollowing:
<?xmlversion="1.0"encoding="utf8"?>
<pam_mount>
<volumeoptions="uid=%(USER),gid=100,dmask=0700"user="*"mountpoint="/media/windowsshare"path="sharename"server="servername"fstype="cifs"/>
</pam_mount>
Troubleshooting
Loginerrors
Ifyougettheerror"mounterror(13)permissiondenied",thentheserverdeniedyouraccess.Herearethefirstthingstocheck:
Areyouusingavalidusernameandpassword?Doesthataccountreallyhaveaccesstothisfolder?
Doyouhavewhitespaceinyourcredentialsfile?Itshouldbepassword=mspassword,notpassword=mspassword.
Doyouneedadomain?Forexample,ifyouaretoldthatyourusernameisSALES\sally,thenactuallyyourusernameissallyandyour
domainisSALES.Thefstabentryshouldread:...username=sally,password=pass,domain=SALES,...Or:
...credentials=/path/to/file,domain=SALES,...
Isthesecuritysettingcorrect?Themostcommonissec=ntlm,butyoucanalsotrytheotheroptionslistedatthemount.cifsmanpage.The
manpagelistleavesouttheoptionsec=lanmanforsomereason,butyoushouldtrythatoneaswell(seediscussion).
Unprotectednetworkfolderwon'tautomount
I'vehadasituationwhereanunprotectednetworkfolderwouldn'tautomountduringbootup,butaftermanuallyentering"sudomounta"was
mountedcorrectly.Isolvedthisbyreplacingthe"guest"optionby"username=guest,password=".Ifanyonehasanexplanationforthis,pleaseleavea
comment.
//servername/sharename/media/windowssharesmbfsusername=guest,password=,uid=1000,iocharset=utf8,codepage=unicode,unicode00
https://wiki.ubuntu.com/MountWindowsSharesPermanently
2/3
14/6/2016
MountWindowsSharesPermanentlyUbuntuWiki
Mountduringlogininsteadofboot
Ifforsomereason/etc/rc0.d/S31umountnfs.sh(networkingproblemsforexample)theautomaticmountingduringbootdoesn'twork,youcanaddthe
"noauto"parametertoyoursmbfsfstabentryandthenhavethesharemountedatlogin.
In/etc/fstab:
//servername/sharename/media/windowssharecifsnoauto,credentials=/home/ubuntuusername/.smbpasswd00
In/etc/rc.local:
mount/media/windowsshare
exit0
SlowshutdownduetoaCIFS/NetworkManagerbug
IfyouuseNetworkManager,andaregettingreallyslowshutdowns,it'sprobablybecauseNMshutsdownbeforeunmountingthenetworkshares.
ThatwillcauseCIFStohangandwaitfor60secondsorso.Here'showtofixit:/etc/rc0.d/S31umountnfs.sh
sudolns/etc/init.d/umountnfs.sh/etc/rc0.d/K14umountnfs.sh
sudolns/etc/init.d/umountnfs.sh/etc/rc6.d/K14umountnfs.sh
Ubuntu12.04alreadyrunsumountnfs.shatrebootandshutdownbydefault(/etc/rc0.d/S31umountnfs.shand/etc/rc6.d/S31umountnfs.sh)sothisis
nolongernecessary.
CIFSOptionsDeprecated
20Feb2008TW
Usingdmaskorfmaskinthefstabfileproducesthefollowingwarnings:WARNING:CIFSmountoption'dmask'isdeprecated.Use'dir_mode'
instead.WARNING:CIFSmountoption'fmask'isdeprecated.Use'file_mode'instead.
Insteadusethisformat:file_mode=0777,dir_mode=0777.Orinsomecasesyoumightneedtousefile_mode=0777,dir_mode=0777,nounix(see
discussion)
Useoftildeinpathnamessuchas"credentials=~/.smbcredentials"
20Feb2008TW
Curiously,usingcredentials=~/.smbcredentialsinfstabdidn'twork.Ihadtousethefullpath,i.e./home/username/.smbcredentials
(Thisislikelybecausethetilde"~"isonlyashellshorthandaliasfor"$HOME"itisn'tsomethingrecognizedsystemwidebyallprograms,
especiallynotinasystemfiletablewheretheconceptof"HOME"doesn'treallyexist.Ian!)
CategoryDocumentation
MountWindowsSharesPermanently(terakhirdisunting2014060314:49:53olehsteve46223@140.247.87.67[140.247.87.67]:steve46223)
https://wiki.ubuntu.com/MountWindowsSharesPermanently
3/3