格式:mount [-參數(shù)] [設(shè)備名稱] [掛載點(diǎn)]
其中常用的參數(shù)有
-t<文件系統(tǒng)類型> 指定設(shè)備的文件系統(tǒng)類型,常見的有:
minix linux最早使用的文件系統(tǒng)
ext2 linux目前常用的文件系統(tǒng)
msdos MS-DOS的fat,就是fat16
vfat windows98常用的fat32
nfs 網(wǎng)絡(luò)文件系統(tǒng)
iso9660 CD-ROM光盤標(biāo)準(zhǔn)文件系統(tǒng)
ntfs windows NT 2000的文件系統(tǒng)
hpfs OS/2文件系統(tǒng)
auto 自動(dòng)檢測(cè)文件系統(tǒng)
-o<選項(xiàng)> 指定掛載文件系統(tǒng)時(shí)的選項(xiàng)。有些也可用在/etc/fstab中。常用的有
codepage=XXX 代碼頁
iocharset=XXX 字符集
ro 以只讀方式掛載
rw 以讀寫方式掛載
nouser 使一般用戶無法掛載
user 可以讓一般用戶掛載設(shè)備
-o 參數(shù)里的codepage iocharset選項(xiàng)。codepage指定文件系統(tǒng)的代碼頁,簡體中文中文代碼是936;iocharset指定字符集,簡體中文一般用cp936或 gb2312。
mount舉例:
1. 加掛 fat 文件系統(tǒng)
mount /dev/hda6 /mnt/d -o codepage=936,iocharset=cp936
mount -t vfat /dev/hda6 /mnt/d -o codepage=936,iocharset=cp936
注意:cp936是指簡體中文,cp950是指繁體中文。
2. 加掛NTFS文件系統(tǒng)
Install NTFS driver
If you need access to NT file systems you'll probably want to download the Linux ntfs driver. There is a site that maintains pre-built modules for all released Fedora kernels at http://linux-ntfs.sourceforge.net/rpm/fedora3.html. A pre-built ntfs module usually appears just a few days after a new Fedora kernel gets released. Be sure to match your kernel version and processor type. If you're not sure what version you're running do this:
# uname -r -p
For example if you're using the latest kernel (as of this writing) which is 2.6.9-1.667 and the i686 (even if it's an AMD) processor then you will want to download it to a local directory and install it as such:
# rpm -ihv kernel-module-ntfs-2.6.9-1.667-2.1.20-0.fc.1.2.i686.rpm
More detailed instructions on determining which RPM you need can be found at http://linux-ntfs.sourceforge.net/rpm/instructions.html. Once installed the ntfs driver will be a dynamically loadable module and you can mount NT file systems with mount -t ntfs -o nls=utf8 /dev/hdXX /mnt .
3. 加掛usb 優(yōu)盤
Linux對(duì)USB設(shè)備有很好的支持,在你插入U(xiǎn)盤后,U盤被識(shí)別為一個(gè)SCSI盤,通常您用以下命令就能加掛U盤上的文件系統(tǒng)
mount /dev/sda1 /usb
同樣對(duì)于中文的文件名和目錄名會(huì)出現(xiàn)亂碼的問題可以指定字符集,命令類似于上面對(duì)FAT32介紹的:
mount /dev/sda1 /usb -o pagecode=936,iocharset=cp936
4. 加掛Linux系統(tǒng)通過samba共享出來的目錄
利用samba共享出來的目錄其實(shí)很難說其原來是哪種文件系統(tǒng),不過這一點(diǎn)不重要,只要它對(duì)用戶是透明的就好啦。加掛時(shí),我們指定類型為smbfs,在加掛samba共享的分區(qū)時(shí),也會(huì)出現(xiàn)中文的文件名和目錄名亂碼情況,可以用以下命令加掛:
mount -t smbfs -o
username=terry,password=terry,codepage=936,iocharset=cp936
//terry-linux/terry /mp3/
mount -t smbfs -o
username=terry,password=terry,codepage=936,iocharset=cp936
//192.168.100.228/terry /mp3/
注意:你可以不直接寫password=terry這個(gè)參數(shù),系統(tǒng)界時(shí)會(huì)要你輸入密碼,這樣就可以防止有人直接看到你的密碼。視具體情況而定,-o后面的參數(shù)可以對(duì)應(yīng)增減。
5. 加掛Window系統(tǒng)共享出來的目錄
在局域網(wǎng)中,常常需要去訪問其它Windows系統(tǒng)共享出來的目錄,在Linux下,安裝了samba后就可以使用samba中帶的命令來訪問Windows機(jī)器的共享資源。
用smbclient來列出Windows機(jī)器的共享資源
smbclient -L 192.168.100.111
根據(jù)上面所列出Windows的共享資源后,可以選擇需要加掛到本地Linux中去的Windows的共享資源,然后使用smbmount或mount來加掛,請(qǐng)參照下面幾條命令:
smbmount //192.168.100.111/public /public/
mount //192.168.100.111/d /mnt/cdrom -o username=terry (這樣要在命令行輸入密碼的)
mount //192.168.100.111/d /mnt/cdrom -o username=terry$1234 (這樣則不必在命令行輸入密碼)
注:除了上面介紹的命令行方法之外,這時(shí)最好的方法就是使用其它的客戶端,如LinNeighborhood、networkneighbours、ksmbshare等,請(qǐng)參考其它文章。
mount自動(dòng)掛在文件系統(tǒng):
通常有2種方法:
方法1.
把加掛的命令放在/etc/rc.d/rc.local中。
方法2.
修改分區(qū)配置文件/etc/fstab,在啟動(dòng)時(shí)加掛文件系統(tǒng)。
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=325179
showmount 命令
用途
顯示遠(yuǎn)程已安裝文件系統(tǒng)的所有客戶機(jī)的列表。
語法
/usr/bin/showmount [ -a ] [ -d ] [ -e ] [ Host ]
描述
showmount 命令顯示 Host 參數(shù)指定的機(jī)器上已遠(yuǎn)程安裝文件系統(tǒng)的所有客戶機(jī)的列表。Host 參數(shù)上的 mountd 守護(hù)程序維護(hù)這些信息。/etc/rmtab 文件保存這些信息以防服務(wù)器崩潰。Host 參數(shù)的缺省值是由 hostname 命令返回的值。
標(biāo)志
-a | 以 HostName :Directory 格式顯示所有遠(yuǎn)程客戶機(jī)安裝,其中 HostName 是客戶機(jī)的名稱,Directory 是遠(yuǎn)程安裝的目錄路徑名。 |
-d | 僅列出客戶機(jī)遠(yuǎn)程安裝的目錄。 |
-e | 顯示導(dǎo)出目錄的列表。 |
示例
- 要顯示主機(jī)安裝的所有遠(yuǎn)程目錄的列表,請(qǐng)輸入:
/usr/bin/showmount -a zeus在本示例中,showmount 命令產(chǎn)生名為 zeus 的主機(jī)上客戶機(jī)安裝的所有遠(yuǎn)程目錄的列表。
- 要顯示主機(jī)上的客戶機(jī)安裝的目錄列表,請(qǐng)輸入:
/usr/bin/showmount -d athena在本示例中,showmount 命令產(chǎn)生名為 athena 的主機(jī)上客戶機(jī)安裝的所有遠(yuǎn)程目錄的列表。
- 要顯示機(jī)器上導(dǎo)出的所有目錄列表,請(qǐng)輸入:
/usr/bin/showmount -e zeus在本示例中,showmount 命令產(chǎn)生名為 zeus 的主機(jī)導(dǎo)出的所有遠(yuǎn)程目錄的列表。
文件
/etc/rmtab | 包含關(guān)于所有導(dǎo)出目錄的當(dāng)前狀態(tài)的信息。 |
/etc/xtab | 列出當(dāng)前導(dǎo)出目錄。 |
相關(guān)信息
mountd 守護(hù)程序。
NFS 命令列表。
-------------------------其他
mount / umount
NO1. 掛載光驅(qū)
[root@rehat root]# mount -t iso9660 /dev/cdrom /mnt/cdrom
NO2. 掛載光驅(qū),支持中文
[root@rehat root]# mount -t iso9660 -o codepage=936,iocharset=cp936 /dev/cdrom /mnt/cdrom
NO3. 掛載 Windows 分區(qū),F(xiàn)AT文件系統(tǒng)
[root@rehat root]# mount -t vfat /dev/hda3 /mnt/cdrom
NO4. 掛載 Windows 分區(qū),NTFS文件系統(tǒng)
[root@rehat root]# mount -t ntfs -o iocharset=cp936 /dev/hda7 /mnt/had7
No5. 掛載 ISO 文件
[root@rehat root]# mount -o loop /abc.iso /mnt/cdrom
NO6. 掛載 軟驅(qū)
[root@rehat root]# mount /dev/fd0 /mnt/floppy
NO7. 掛載閃盤
[root@rehat root]# mount /dev/sda1 /mnt/cdrom
NO8. 掛載 Windows 操作系統(tǒng)共享的文件夾
[root@rehat root]# mount -t smbfs -o username=guest,password=guest //machine/path /mnt/cdrom
NO9. 顯示掛載的文件系統(tǒng)
[root@rehat root]# mount
[root@rehat root]# cat /etc/fstab 顯示系統(tǒng)啟動(dòng)自動(dòng)加載的文件系統(tǒng)
[root@rehat root]# cat /etc/mtab 顯示當(dāng)前加載的文件系統(tǒng)
轉(zhuǎn)載自:http://www.cnitblog.com/forrest/archive/2007/01/30/22458.aspx