磁碟掛載

Linux磁碟掛載

[root @test /root ]# mount [-ahlV] 
[root @test /root ]# mount -t type /dev/hdxx /mountpoint
[root @test /root ]# mount -o [options]
[root @test /root ]# umount /mountpoint

參數說明:
-a   :依照 /etc/fstab 的內容將所有相關的磁碟都掛上來!
-h   :只列出 mount 相關的參數,並不掛載任何裝置
-l   :列出目前已經掛載的裝置、檔案系統名稱與掛載點!
-V   :列出 mount 的版本資訊
type :將後面 /dev/hdxx 這個裝置以 type 的檔案格式掛載到 /mountpoint 這個點,
      常見的 type 有底下幾個:
      vfat, msdos       :這個是支援 Windows 系統的檔案格式,尤其是 vfat 常用!
      ext, ext2         :這個就是 Linux 的主要檔案格式啦!
      iso9660           :光碟機的檔案格式
      nfs, ntfs, ufs    :Windows 2000 使用 NTFS 格式呀!
-o  :這個參數後面接的咚咚可多了!可用的資料可不少呢!
   rw   :讓 mount 的磁區為可讀寫
   suid   :允許該磁區可以設定檔案為 SUID 的狀態!
   exec   :允許該磁區可以執行 binary 的檔案!
   auto   :允許該磁區可以使用 mount -a 的參數設定!
    nouser :禁止其他人(非 root 之使用者)使用掛載功能!這是預設值!
    async :允許磁區可以進行非同步記錄(記憶體與硬碟不同步!最常用!)
    defaults:同時具有 rw, suid, dev, exec, auto, nouser, async 這些功能的設定值!
    nosuid :不許該磁區具有 SUID 的檔案屬性!
   ro   :設定為唯讀屬性!
    remount :讓系統本來掛載的磁區重新被掛載!

範例:
[root @test /root]# mount -a
[root @test /root]# mount -t iso9660 /dev/cdrom /mnt/cdrom<==掛上光碟
[root @test /root]# mount -t vfat /dev/fd0 /mnt/floppy   <==掛上 windows 檔案系統的軟碟
[root @test /root]# mount -t ext2 /dev/fd0 /mnt/floppy   <==掛上 Linux   檔案系統的軟碟
[root @test /root]# mount -t ext2 /dev/hdc6 /home        <==掛上 Linux 檔案格式硬碟
[root @test /root]# mount -o remount,rw /          <==讓根目錄重新掛載為可讀!

說明
這個指令只有 root 才能執行!如果你不想要單獨的將某個磁碟掛上來,那麼執行:
mount -a
就可以依照 /etc/fstab的的參數內容將所有的磁碟給他重新掛上去!此外,需要注意的是,由於 Linux 系統中,每一個路徑都有可能是一個獨立的磁區系統,所以需要將每個磁區系統都掛上各自的掛載點!。另外,由於各個磁區的檔案系統可能並不相同,所以您必須先要瞭解該磁區的檔案系統,這樣才可以進行 mount 的工作!如何知道該磁碟的檔案格式呢?可以使用 fdisk -l來顯示的功能即可!
 
請注意呦!由於 mount 之後的檔案格式是沒有辦法直接被拿掉的!尤其在使用 fsck 檢查你的硬碟時,更是不能掛上硬碟的!而如何將硬碟至掛載點卸載呢?呵呵,就直接使用 umount 即可囉!

※ WINDOWS掛載磁碟掛

使用 fdisk 指令的話就可以知道你的 Win95 FAT32 的磁區在哪一個,在下表中,顯示的是 /dev/hda1 這一個磁區囉!

fdisk –l /dev/hda


Disk /dev/hda: 255 heads, 63 sectors, 524 cylinders 
Units = cylinders of 16065 * 512 bytes 

   Device Boot    Start       End    Blocks   Id  System 
/dev/hda1             1       268   2152678+  83  Win95 FAT32 
/dev/hda2   *       269       395   1020127+  83  Linux 
/dev/hda3           396       459    514080   83  Linux 
/dev/hda4           460       524    522112+   5  Extended 
/dev/hda5           460       472    104391   83  Linux 
/dev/hda6           473       485    104391   83  Linux 
/dev/hda7           486       498    104391   82  Linux swap 
/dev/hda8           499       511    104391   83  Linux 
/dev/hda9           512       524    104391   83  Linux 

 

假設我要將 Windows 的目錄建置在 /mnt/win98 裡面呢?就這樣做吧:

[root @rh9 / ]# mkdir /mnt/win98 
[root @rh9 / ]# mount -t vfat /dev/hda1 /mnt/win98 


[root @rh9 / ]# mount -t vfat -o iocharset=cp950 /dev/hda1 /mnt/win98

所使用的參數可以讓您的 Windows 98 的磁區當中的檔案顯示出正確的中文呦! )

卸載:

umount -t vfat /dev/hda1 /mnt/win98