命令格式:
mount [-t vfstype] [-o options] device dir
其中:
1.-t vfstype 指定文件系統的類型,通常不必指定。mount 會自動選擇正確的類型。常用類型有:
光盤或光盤鏡像:iso9660
DOS fat16文件系統:msdos
Windows 9x fat32文件系統:vfat
Windows NT ntfs文件系統:ntfs
Mount Windows文件網絡共享:smbfs
UNIX(LINUX) 文件網絡共享:nfs
2.-o options 主要用來描述設備或檔案的掛接方式。常用的參數有:
loop:用來把一個文件當成硬盤分區掛接上系統
ro:采用只讀方式掛接設備
rw:采用讀寫方式掛接設備
iocharset:指定訪問文件系統所用字符集
3.device 要掛接(mount)的設備。
4.dir設備在系統上的掛接點(mount point)。
1、光盤掛載
標注:光盤自動掛載到默認路徑 /media 目錄下
假如想制作光盤掛載點進行下面操作:
將當前光驅里的光盤制作成光盤鏡像文件/home/mydisk.iso
#cp /media /home/mydisk.iso
建立一個目錄用來作掛載點,一般默認掛載點在/mnt 目錄下建立
#mkdir /mnt/dvd
制作的mydisk.iso進行掛載
#mount -o loop -t iso9660 /home/mydisk.iso /mnt/dvd
取消掛載
#umount /mnt/dvd
2、掛載U盤(U盤有兩種文件格式NTFS和FAT32)
使用 fdisk -l 查看系統硬盤和U盤分區情況 (會對U盤FAT32掛載)
[root at pldyrouter root]# fdisk -l
Disk /dev/sda: 73 dot 4 GB, 73407820800 bytes
255 heads, 63 sectors/track, 8924 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 4 32098+ de Dell Utility
/dev/sda2 * 5 2554 20482875 7 HPFS/NTFS
/dev/sda3 2555 7904 42973875 83 Linux
/dev/sda4 7905 8924 8193150 f Win95 Ext'd (LBA)
/dev/sda5 7905 8924 8193118+ 82 Linux swap
Disk /dev/sdd: 131 MB, 131072000 bytes
9 heads, 32 sectors/track, 888 cylinders
Units = cylinders of 288 * 512 = 147456 bytes
Device Boot Start End Blocks Id System
/dev/sdd1 * 1 889 127983+ b Win95 FAT32
Partition 1 has different physical/logical endings:
phys=(1000, 8, 32) logical=(888, 7, 31)
建立一個目錄用來作掛載點,一般默認掛載點在/mnt 目錄下建立
#mkdir /mnt/usb
使用mount進行U盤掛載
#mount -t vfat /dev/sdd1 /mnt/usb
若漢字文件名顯示為亂碼或不顯示,可以使用下面的命令
#mount -t vfat -o iocharset=cp936 /dev/sdd1 /mnt/usb
取消掛載
#umount /mnt/usb
使用 fdisk -l 查看系統硬盤和U盤分區情況 (會對U盤NTFS掛載)
[root@sstisystem ~]# fdisk -l
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x09cb47e4
Device Boot Start End Blocks Id System
/dev/sda1 * 1 128 1024000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 128 25625 204800000 83 Linux
/dev/sda3 25625 38373 102400000 83 Linux
/dev/sda4 38373 60802 180161536 5 Extended
/dev/sda5 38373 44747 51200000 83 Linux
/dev/sda6 44747 45321 4608000 82 Linux swap / Solaris
Disk /dev/sdb: 8053 MB, 8053063680 bytes
255 heads, 63 sectors/track, 979 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xcad4ebea
Device Boot Start End Blocks Id System
/dev/sdb4 * 1 980 7864192 7 HPFS/NTFS
Partition 4 has different physical/logical endings:
phys=(978, 254, 63) logical=(979, 15, 60)
執行掛載命令提示如下錯誤:
[root@sstisystem ~]# mount -t ntfs /dev/sdb4 /mnt/usb
mount: unknown filesystem type 'ntfs'
需要通過第三方軟件ntfs-3g軟件來實現,能過yum在線安裝:
[root@sstisystem ~]# yum -y install ntfs-3g*
執行命令進行掛載:
[root@sstisystem ~]# mount -t ntfs-3g /dev/sdb4 /mnt/usb
3、掛載windows文件共享
標注:首先在windows下設置一個共享文件夾backup,建立一個用戶abc,密碼設置成123,把backup文件夾訪問權限分配給abc用戶
建立一個目錄用來作掛載點,一般默認掛載點在/mnt 目錄下建立
#mkdir /mnt/file
使用mount把windows共享文件夾掛載到linux目錄下/mnt/file
mount -t cifs -o username=abc,password="123" //192.168.1.10/backup /mnt/file
取消掛載
#umount /mnt/dvd
強制取消掛載
#umount -f /mnt/dvd
問題1:
如果運行umount取消掛載提示如下: (掛載目錄正在使用中)
[root@cloucentos6 ~]# umount /mnt/file/
umount: /mnt/file: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
問題1解決辦法:
[root@cloucentos6 ~]# lsof /mnt/file/
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
bash 2807 root cwd DIR 0,20 4096 562949953421362 /mnt/file
[root@cloucentos6 ~]# kill -9 2807
[root@cloucentos6 ~]# umount /mnt/file/
問題2:
linux 運行掛載目錄共享提示如下錯誤:
[root@ssticentos ~]# mount -t cifs -o username=abc,password="123" //192.168.1.10/backup /mnt/file
mount error(12): Cannot allocate memory
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
問題2解決辦法:
重啟windows 系統掛載共享的系統Server服務即可。