mount [-lhV]
mount –a [-fFnrsvw] [-t vfstype] [-O optlist]
mount [-fnrsvw] [-o option[,option]…] device|dir
mount [-fnrsvw] [-t vfstype] [-o options] device dir
-t vfstype指定文件系統的類型,通常不必指定,mount會自動選擇正確的類型
光盤或光盤鏡像iso9660 DOS fat16文件系統msdos Windows 9x fat32文件系統vfat Windows NT ntfs文件系統ntfs Mount Windows文件網絡共享smbfs UNIX(LINUX)文件網絡共享nfs
-o option主要用來描述設備或文件的掛載方式
device要掛載的設備
dir目錄,設備在系統上的掛載點
(1)常用選項
沒錯,就是什么都不跟,作用是列出所有被掛載的文件系統(還有type+類型) -l 列出所有被掛載的文件系統,包括卷標 -h 打印幫助 -V 打印版本信息 -a 將/etc/fstab中定義的所有文件系統掛載 -f 模擬掛載動作,但並不執行。通常用在除錯。通常和-v一起使用 -F 通常和-a一起使用,為每一個掛載動作產生一個行程負責執行。在系統需要掛載大量NFS文件系統時加快掛載動作 -n 一般而言,掛載后會在/etc/mtab中寫入一筆資料。但系統中沒有可寫入文件系統存在的情況下可以用這個選項取消動作 -s-r 等於-o ro -v 詳細模式 -w 等於-o rw
-o option單獨拿出來,因為光這一項就蠻多的
defaults 使用預設的選項rw,suid,dev,exec,auto,nouser,async(把默認的都用上) async(defaults),sync 異步模式,同步模式 同步模式下,內存的任何修改都是實時的同步到硬盤中,這種模式的安全性基本屬於最高,但應為內存的數據基本一直在變化,所以這種模式會使的程序運行變得緩慢,影響效率。而異步模式雖然沒有實時同步,但考慮日志文件系統的存在,所以安全性基本不用考慮,一步的效率會更高,所以普遍使用異步模式為默認。 atime(defaults),noatime 是否在訪問時更新atime 當atime打開時,系統會在每次讀取文件時更新文件的上次調用時間 diratime(defaults),nodiratime 是否在目錄訪問時更新時間戳 auto,noauto 打開/關閉自動掛載模式(是否在mount –a時被掛載) suid(defaults),nosuid 允許執行檔在root權限下執行 dev(defaults),nodev/exec(defaults),noexec允許執行擋被執行 user,nouser(defaults) 使用者可以執行掛載/卸載動作 ro/rw 只讀模式/讀寫模式 loop把一個文件當作硬盤分區掛載上系統 remount把已掛載的文件系統重新用不同的方式掛載 iocharset指定訪問文件系統所用字符集
注意:此選項對應/etc/fstab中的第四項
(2).實例
1)掛載U 盤或移動硬盤
[root@CentOS6 桌面]# fdisk -l Disk /dev/sda: 107.4 GB, 107374182400 bytes 255 heads, 63 sectors/track, 13054 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: 0x00079700 Device Boot Start End Blocks Id System /dev/sda1 * 1 64 512000 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 64 13055 104344576 8e Linux LVM Disk /dev/sdb: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 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: 0x00000000 Disk /dev/mapper/vg_centos6-lv_root: 53.7 GB, 53687091200 bytes 255 heads, 63 sectors/track, 6527 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: 0x00000000 Disk /dev/mapper/vg_centos6-lv_swap: 4194 MB, 4194304000 bytes 255 heads, 63 sectors/track, 509 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: 0x00000000 Disk /dev/mapper/vg_centos6-lv_home: 49.0 GB, 48964304896 bytes 255 heads, 63 sectors/track, 5952 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: 0x00000000 Disk /dev/sdc: 31.0 GB, 31037849600 bytes 32 heads, 63 sectors/track, 30069 cylinders Units = cylinders of 2016 * 512 = 1032192 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x3e833261 Device Boot Start End Blocks Id System /dev/sdc1 * 1 30069 30309520+ b W95 FAT32 [root@CentOS6 桌面]# mkdir /mnt/usb [root@CentOS6 桌面]# mount /dev/sdc1 /mnt/usb
當然有時候並不是一切都順利的,在CentOS中沒有辦法直接掛載NTFS的U盤或移動硬盤,這是因為CentOS沒有NTFS需要自行安裝
wget https://tuxera.com/opensource/ntfs-3g_ntfsprogs-2017.3.23.tgz //下載速度太慢,可以用windows下載好拷貝過來 tar -zxvf ntfs-3g_ntfsprogs-2017.3.23.tgz
cd ntfs-3g_ntfsprogs-2017.3.23 ./configure && make && make install //這里有可能提示缺少依賴關系,例如我的就是缺少gcc,裝好后重新運行即可
當然這時候的掛載命令有着細小的變化
mount -t ntfs-3g /dev/sdc1 /mnt/usb
2)掛載windows共享文件夾
[root@CentOS6 桌面]# mkdir -p /mnt/cifs [root@CentOS6 桌面]# mount -t cifs -o username=DT,password=Password0 //192.168.128.10/share /mnt/cifs/
3)掛載新硬盤或分區
我單獨寫了一下,就是fdisk,格式化,最后掛載即可
http://www.cnblogs.com/diantong/p/8855683.html
4)掛載光盤
[root@CentOS6 桌面]# mkdir /mnt/cdrom [root@CentOS6 mnt]# mount /dev/cdrom1 /mnt/cdrom mount: block device /dev/sr0 is write-protected, mounting read-only //只讀
5)掛載光盤鏡像
[root@CentOS6 桌面]# mkdir /mnt/vcdrom [root@CentOS6 桌面]# mount VM11\ toos\ linux.iso /mnt/vcdrom/ mount: /root/桌面/VM11 toos linux.iso is not a block device (maybe try `-o loop'?) [root@CentOS6 桌面]# mount -o loop VM11\ toos\ linux.iso /mnt/vcdrom/
資料:
http://tutu.spaces.eepw.com.cn/articles/article/item/70737
http://www.runoob.com/linux/linux-comm-mount.html
http://www.178linux.com/85066