掛載硬碟【CentOS】

來源:互聯網
上載者:User

標籤:mkfs 分區 fdisk mount umount

我們之前就說過,掛載點是目錄,而這個目錄是進入磁碟分割的入口。不過要就行掛載之前,你最好先確定幾件事:

      單一檔案系統不應該被重複掛載在不同的掛載點(目錄)中;

      單一目錄應該重複掛載多個檔案系統;

      要作為掛載點的目錄,理論上應該都是空目錄才是。

      尤其是上面的後兩點,如果你要用來掛載的目錄並不是空的,那麼掛載了檔案系統之後,原目錄下的東西就會暫時消失。舉個例子來說,假設你的/home原本與 根目錄(/)在同一個檔案系統中,底下原本就有/home/test與/home/heetian兩個目錄。然後你加入新的硬碟,並且直接掛載到 /home底下,那麼當你掛載好了之後,則/home目錄顯示的是新掛載的分區的資料。至於原來的test與heetian這兩個目錄就會暫時的被隱藏 了。注意了!並不是被覆蓋掉了。而是暫時隱藏起來了,當新的分區被卸載後,/home下面的東西就會恢複正常了。

如何?開機自動掛載檔案系統

      請思考,我們掛載的檔案系統,在系統重啟之後還有沒有呢?

      讓我們來測試一下:

650) this.width=650;" src="http://erange.heetian.com/server/files/upload/guidebook/image/c1283788-77e0-4d6b-82bf-0a9b309a0f38.jpg" style="height:124px;border:0px none;vertical-align:top;width:554px;" alt="c1283788-77e0-4d6b-82bf-0a9b309a0f38.jpg" />

      我們reboot一下:直接敲 reboot ,斷行符號,過1分鐘左右再用putty連結Linux。

      重啟之後,我們再來看一下,sdb4還在不在?

650) this.width=650;" src="http://erange.heetian.com/server/files/upload/guidebook/image/97fb7c44-46f9-4156-8a0f-92939b362eca.jpg" style="height:140px;border:0px none;vertical-align:top;width:554px;" alt="97fb7c44-46f9-4156-8a0f-92939b362eca.jpg" />

      咦 ?看不到sdb4了,難道我重啟系統就要重新手動掛載一次嗎?那怎麼樣讓檔案系統自動掛載呢?那就需要寫設定檔了。設定檔的的路徑是 /etc/fstab 。

      我們用 cat 命令查看一下裡面有什麼東西吧?

650) this.width=650;" src="http://erange.heetian.com/server/files/upload/guidebook/image/18ef0945-f6ce-47ca-b2a9-6870356cf62b.jpg" style="height:174px;border:0px none;vertical-align:top;width:554px;" alt="18ef0945-f6ce-47ca-b2a9-6870356cf62b.jpg" />

      那有沒有發現,總共可分為6列,那每列都是啥呢?就是一下這幾個了

650) this.width=650;" src="http://erange.heetian.com/server/files/upload/guidebook/image/03fa2389-9d33-4d19-b6b7-20943b681ac5.png" style="height:28px;border:0px none;vertical-align:top;width:440px;" alt="03fa2389-9d33-4d19-b6b7-20943b681ac5.png" />

      fs_spec :定義希望載入的檔案系統所在的裝置或遠程檔案系統

      fs_file:該欄位描述希望的檔案系統掛載的目錄點

      fs_type:檔案系統類型:如ext2

      fs_options:指定掛載該裝置的檔案系統是需要使用的特定參數選項,多個參數是由逗號分隔開來

      fs_dump:是一個備份指令,不需要為0 ,需要備份為 1以後會講到這個指令。

      fs_pass:是否在開機是進行磁碟校正,0 為不校正,1為校正。通常 / 設定為 1。

      那設定開機自動掛載/dev/sdb4怎麼寫呢?

      用vim /etc/fstab開啟 (vim的時候我們會在後續的課程裡面講解的哦)

      按“i”鍵,按鍵盤上的上下左右,移動游標到最後,然後斷行符號

650) this.width=650;" src="http://erange.heetian.com/server/files/upload/guidebook/image/78659519-9fb9-49ff-9240-8da3885189c6.jpg" style="height:184px;border:0px none;vertical-align:top;width:554px;" alt="78659519-9fb9-49ff-9240-8da3885189c6.jpg" />

      添加一行 :/dev/sdb4 /mnt/sdb4 ext2 defaults 0 0

650) this.width=650;" src="http://erange.heetian.com/server/files/upload/guidebook/image/58c37091-8c4d-4af4-a4ee-41f25c1de83c.jpg" style="height:198px;border:0px none;vertical-align:top;width:554px;" alt="58c37091-8c4d-4af4-a4ee-41f25c1de83c.jpg" />

      然後按兩下鍵盤左上方的 ESC鍵。然後輸入 “:x”,斷行符號,就儲存了

650) this.width=650;" src="http://erange.heetian.com/server/files/upload/guidebook/image/5d41c346-6cbe-4cf4-b2d0-de2bad17d901.jpg" style="height:344px;border:0px none;vertical-align:top;width:554px;" alt="5d41c346-6cbe-4cf4-b2d0-de2bad17d901.jpg" />

      修改後的/etc/fstab是這樣的:

650) this.width=650;" src="http://erange.heetian.com/server/files/upload/guidebook/image/eb3e39a0-9d25-4676-bedb-d21680809dcd.jpg" style="height:212px;border:0px none;vertical-align:top;width:553px;" alt="eb3e39a0-9d25-4676-bedb-d21680809dcd.jpg" />

      我們再 reboot 試試?

650) this.width=650;" src="http://erange.heetian.com/server/files/upload/guidebook/image/5ee5bd52-0a51-4560-b7b1-669be0a32fe4.png" style="height:156px;border:0px none;vertical-align:top;width:503px;" alt="5ee5bd52-0a51-4560-b7b1-669be0a32fe4.png" />

650) this.width=650;" src="http://erange.heetian.com/server/files/upload/guidebook/image/474b87af-e531-47ae-90aa-4771cd12df67.jpg" style="height:239px;border:0px none;vertical-align:top;width:554px;" alt="474b87af-e531-47ae-90aa-4771cd12df67.jpg" />

      看,被自動掛載了。媽媽再也不用擔心我重啟系統,掛載不了檔案系統了!!

如何掛載一個iso鏡像檔案

      很多時候我們需要用到iso鏡像,那麼iso鏡像怎麼使用呢?

      我們的系統中因為沒有iso鏡像檔案,我們先來造一個。不用明白命令的意思:

      我們用mkisofs做一個iso9660鏡像檔案:

      mkisofs -o heetian.iso /tmp

650) this.width=650;" src="http://erange.heetian.com/server/files/upload/guidebook/image/bc75a32c-452a-4044-a909-d2c604ea349e.jpg" style="height:189px;border:0px none;vertical-align:top;width:554px;" alt="bc75a32c-452a-4044-a909-d2c604ea349e.jpg" />

      iso 檔案做好了,我們來掛載使用它吧:我們掛載到/media/iso下面如何:

      mount -o loop -t iso9660 ./heetian.iso /media/iso/

650) this.width=650;" src="http://erange.heetian.com/server/files/upload/guidebook/image/aed84eb2-5ca8-4ba4-a62b-86f261023873.jpg" style="height:136px;border:0px none;vertical-align:top;width:553px;" alt="aed84eb2-5ca8-4ba4-a62b-86f261023873.jpg" />

      這條命令的意思就是掛載“迴旋裝置”和iso鏡像 –t是指定為iso9660光碟片格式


本文出自 “淨空藍星” 部落格,請務必保留此出處http://jingkonglanxing.blog.51cto.com/1152128/1630604

掛載硬碟【CentOS】

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.