轉貼來源一:http://indeepnight.blogspot.com/2007/05/mount.html

轉貼來源二:http://iammic.pixnet.net/blog/post/9440652-centos-5-samba-%E5%AE%89%E8%A3%9D%E8%A8%AD%E5%AE%9A

一.Linux掛載

做法如下:

1.新增資料夾:(注意權限修正)
#cd /home (切換)
#mkdir /home/old(新增old資料夾)
#chown root.test old (更改資料夾的擁有者為root,群組為test)
#chmod 770 (更改資料夾權限,root和群組test都可完全控制資料夾)

2.指令掛載

掛windows的硬碟:mount -t cifs //192.168.1.2/movie /home/willlu/testmount/ -o username=test,password=test,codepage=cp950,iocharset=utf8
掛linux的硬碟:mount //192.168.0.1/linux /media/sharename/ -o username=myusername,password=mypassword


說明:
   -t cifs:在fc6中已將cifs和smbfs這兩種格式合併為一個cifs
   //192.168.1.2/test:遠端分享資料夾
   /home/test:本機載掛資料夾
   -o username=xx,password=xx:能存取Windows的使用者與密碼
   codepage=cp950:Windows所使用的編碼格式(cp950是繁體中文)
   iocharset=utf8:Linux的編碼格式(utf8是萬國碼)

3.檢查方式:
 (1)顯示系統掛載的Partition:
  #df -h
  --------------------------------
  檔案系統      容量  已用  可用 已用% 掛載點
  //192.168.1.2/test 40G  22G  18G 56%  /home/old
  --------------------------------
 (2)檢查是否可以針對該資料夾做存取刪除:
  #mkdir aaa(建資料夾aaa)
  #touch a(建一個名稱為a的空檔案)
  #rm a(刪除a檔案)
  如果以上動作都可正常操作,代表已經載掛完成
4.寫入系統開機自動載掛:
  #vi /etc/fstab
  加入://192.168.1.2/test /home/old cifs defaults,user=test,password=testpw,codepage=cp950,iocharset=utf8 0 0

5.卸除遠端硬碟
umount /home/willlu/testmount/


完成以上的步驟之後,您就可以利用Windows中的網路芳鄰,找到Linux利用SAMBA所分享出來的資料夾(/home/test),就能同時存取在Windows中的舊資料以及放新資料在Linux中,不需要兩個連線磁碟機之間把檔案傳來傳去,這也是便民的措施之一

二.windows掛載

1.遠端已共享movie資料夾

2.使用cmd.exe
net use h: \\192.168.0.1\share /user:(帳號) (密碼)
//掛載遠端「\\192.168.0.1\share」到本地端「h:」 

net use * /delete /YES 
//卸載全部裝置

net use h: /delete
//卸載 

三.Linux設定共享

轉貼來源:http://maxubuntu.blogspot.com/2009/03/samba.html

linux設定共享資料夾

1. 安裝samba
yum install samba

2. 設定samba
vi /etc/samba/smb.conf

3. 增加分享資料夾

若無則新增資料夾 
mkdir /home/samba
chown .users /home/samba
chmod 777 /home/samba 

在檔案內加上

[global]
unix charset = utf-8 //設定linux編碼
dos charset = cp950 //設定windows編碼

[CsShare]
comment = for CS System   //註解
path = /home/willlu/CsShare //分享路徑 
public = yes//公開
writable = yes //可寫入
valid users = +users
printable = no
write list = +staff
browseable = yes //未登入亦可瀏覽

4. 重新啟動 samba 服務
service smb restart

5. 建立samba帳號密碼
smbpasswd -a <帳號>

6. 檢視設定
testparm

7. 執行\\ip


※不需帳號密碼的設定
修改 smb.conf
於分享的資料夾設定中
增加security = share

mount //192.168.1.2/share /home/willlu/testmount/ -o username=test,password=test

三.Linux 開機自動掛載

 1. vi /etc/fstab 
========================================================#

# /etc/fstab
# Created by anaconda on Mon Oct 3 23:31:26 2011
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/vg_cullinuxcexpr-lv_root / ext4 defaults 1 1
UUID=b8f3efa5-332a-4b6a-9cca-ceaef06fd08b /boot ext4 defaults 1 2
/dev/mapper/vg_cullinuxcexpr-lv_swap swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0

=========================================================

2.在此文件最後加上mount指令

//192.168.0.1/mount /home/mount cifs defaults,credentials=/home/smbpasswd 0 0

3.設定帳號密碼

vi /home/smbpasswd
=============================
username=admin
password=admin
==============================

4.重新檢查mount

mount -a

 

 

arrow
arrow
    全站熱搜

    Will(小威) 發表在 痞客邦 留言(0) 人氣()