掛接命令(mount)

來源:互聯網
上載者:User
掛接命令(mount)

  首先,介紹一下掛接(mount)命令的使用方法,mount命令參數非常多,這裡主要講一下今天我們要用到的。

  命令格式:

  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)。

  掛接光碟片鏡像檔案

  由於近年來磁碟技術的巨大進步,新的電腦系統都配備了大容量的磁碟系統,在Windows下許多人都習慣把軟體和資料做成光碟片鏡像檔案通過虛擬光碟機來使用。這樣做有許多好處:一、減輕了光碟機的磨損;二、現在硬碟容量巨大存放幾十個光碟片鏡像檔案不成問題,隨用隨調十分方便;三、硬碟的讀取速度要遠遠高於光碟片的讀取速度,CPU佔用率大大降低。其實linux系統下製作和使用光碟片鏡像比Windows系統更方便,不必借用任何第三方軟體包。

  1、從光碟片製作光碟片鏡像檔案。將光碟片放入光碟機,執行下面的命令。

   #cp /dev/cdrom /home/sunky/mydisk.iso 或

   #dd if=/dev/cdrom of=/home/sunky/mydisk.iso

   註:執行上面的任何一條命令都可將當前光碟機裡的光碟片製作成光碟片鏡像檔案/home/sunky/mydisk.iso

  2、將檔案和目錄製作成光碟片鏡像檔案,執行下面的命令。

   #mkisofs -r -J -V mydisk -o /home/sunky/mydisk.iso /home/sunky/ mydir

   註:這條命令將/home/sunky/mydir目錄下所有的目錄和檔案製作成光碟片鏡像檔案/home/sunky/mydisk.iso,光碟片卷標為:mydisk

  3、光碟片鏡像檔案的掛接(mount)

   #mkdir /mnt/vcdrom

   註:建立一個目錄用來作掛接點(mount point)

   #mount -o loop -t iso9660 /home/sunky/mydisk.iso /mnt/vcdrom

   註:使用/mnt/vcdrom就可以訪問盤鏡像檔案mydisk.iso裡的所有檔案了。

{{分頁}}

掛接移動硬碟

  對linux系統而言,USB介面的移動硬碟是當作SCSI裝置對待的。插入移動硬碟之前,應先用fdisk –l 或 more /proc/partitions查看系統的硬碟和硬碟分區情況。

  [root at pldyrouter /]# 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

  在這裡可以清楚地看到系統有一塊SCSI硬碟/dev/sda和它的四個磁碟分割/dev/sda1 -- /dev/sda4, /dev/sda5是分區/dev/sda4的邏輯分區。接好移動硬碟後,再用fdisk –l 或 more /proc/partitions查看系統的硬碟和硬碟分區情況

  [root at pldyrouter /]# 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/sdc: 40.0 GB, 40007761920 bytes

  255 heads, 63 sectors/track, 4864 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot Start End Blocks Id System

  /dev/sdc1 1 510 4096543+ 7 HPFS/NTFS

  /dev/sdc2 511 4864 34973505 f Win95 Ext'd (LBA)

  /dev/sdc5 511 4864 34973473+ b Win95 FAT32

  大家應該可以發現多了一個SCSI硬碟/dev/sdc和它的兩個磁碟分割/dev/sdc1?、/dev/sdc2,其中/dev/sdc5是/dev/sdc2分區的邏輯分區。我們可以使用下面的命令掛接/dev/sdc1和/dev/sdc5。

   #mkdir -p /mnt/usbhd1

   #mkdir -p /mnt/usbhd2

   註:建立目錄用來作掛接點(mount point)

   #mount -t ntfs /dev/sdc1 /mnt/usbhd1

   #mount -t vfat /dev/sdc5 /mnt/usbhd2

   註:對ntfs格式的磁碟分割應使用-t ntfs 參數,對fat32格式的磁碟分割應使用-t vfat參數。若漢字檔案名稱顯示為亂碼或不顯示,可以使用下面的命令格式。

   #mount -t ntfs -o iocharset=cp936 /dev/sdc1 /mnt/usbhd1

   #mount -t vfat -o iocharset=cp936 /dev/sdc5 /mnt/usbhd2

  linux系統下使用fdisk分區命令和mkfs檔案系統建立命令可以將移動硬碟的分區製作成linux系統所特有的ext2、ext3格式。這樣,在linux下使用就更方便了。使用下面的命令直接掛接即可。

   #mount /dev/sdc1 /mnt/usbhd1 
{{分頁}}

掛接隨身碟

  和USB介面的移動硬碟一樣對linux系統而言隨身碟也是當作SCSI裝置對待的。使用方法和移動硬碟完全一樣。插入隨身碟之前,應先用fdisk –l 或 more /proc/partitions查看系統的硬碟和硬碟分區情況。

  [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

  插入隨身碟後,再用fdisk –l 或 more /proc/partitions查看系統的硬碟和硬碟分區情況。

  [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)

  系統多了一個SCSI硬碟/dev/sdd和一個磁碟分割/dev/sdd1,/dev/sdd1就是我們要掛接的隨身碟。

  #mkdir -p /mnt/usb

  註:建立一個目錄用來作掛接點(mount point)

  #mount -t vfat /dev/sdd1 /mnt/usb

  註:現在可以通過/mnt/usb來訪問隨身碟了, 若漢字檔案名稱顯示為亂碼或不顯示,可以使用下面的命令。

  #mount -t vfat -o iocharset=cp936 /dev/sdd1 /mnt/usb

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.