歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> 學習Linux >> centos7 掛載數據盤

centos7 掛載數據盤

日期:2017/3/6 9:49:19   编辑:學習Linux

centos7 掛載數據盤


centos7 掛載數據盤


  1. 使用遠程連接工具,輸入用戶名root和密碼登錄到實例。

  2. 運行fdisk -l命令查看數據盤。注意:在沒有分區和格式化數據盤之前,使用df -h命令是無法看到數據盤的。在下面的示例中,有一個 5 GB 的數據盤需要掛載。
    如果執行了fdisk -l命令後,沒有發現 /dev/xvdb,則表示您的實例沒有數據盤,因此無需掛載。可以忽略這一章。

     [root@xxxx ~]# fdisk -l Disk /dev/xvda: 42.9 GB, 42949672960 bytes 255 heads, 63 sectors/track, 5221 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: 0x00078f9c Device Boot      Start         End      Blocks   Id  System /dev/xvda1   *           1        5222    41940992   83  Linux Disk /dev/xvdb: 5368 MB, 5368709120 bytes 255 heads, 63 sectors/track, 652 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
  3. 執行下列命令,對數據盤進行分區。
     fdisk /dev/xvdb
  4. 根據提示,依次輸入n,p,1,兩次回車,wq,分區就開始了。

     [root@xxx ~]# fdisk /dev/xvdb Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklab            el Building a new DOS disklabel with disk identifier 0x33eb5059. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) WARNING: DOS-compatible mode is deprecated. It's strongly recommended to      switch off the mode (command 'c') and change display units to      sectors (command 'u'). Command (m for help): n Command action    e   extended    p   primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-652, default 1):  Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-652, default 652): Using default value 652 Command (m for help): wq The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
  5. 執行fdisk -l命令,查看新的分區。新分區 xvdb1 已經創建好。如下面示例中的/dev/xvdb1。

     [root@xxx ~]# fdisk -l Disk /dev/xvda: 42.9 GB, 42949672960 bytes 255 heads, 63 sectors/track, 5221 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: 0x00078f9c Device Boot      Start         End      Blocks   Id  System /dev/xvda1   *           1        5222    41940992   83  Linux Disk /dev/xvdb: 5368 MB, 5368709120 bytes 255 heads, 63 sectors/track, 652 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: 0x33eb5059 Device Boot      Start         End      Blocks   Id  System /dev/xvdb1               1         652     5237158+  83  Linux
  6. 執行下列命令,對新分區進行格式化。格式化所需時間取決於數據盤大小。您也可自主決定選用其他文件格式,如 ext14 等。

     mkfs.ext3 /dev/xvdb1
  7. 執行下列命令寫入新分區信息。

     echo '/dev/xvdb1 /mnt ext3 defaults 0 0'>> /etc/fstab


    完成後,可以使用 cat /etc/fstab 命令查看。
    注意: Ubuntu 12.04 不支持 barrier,所以對該系統正確的命令是:

     echo '/dev/xvdb1 /mnt ext3 barrier=0 0 0'>>/etc/fstab


    如果需要把數據盤單獨掛載到某個文件夾,比如單獨用來存放網頁,可以修改以上命令中的 /mnt 部分。

  8. 執行mount /dev/xvdb1 /mnt掛載新分區,然後執行df -h查看分區。如果出現數據盤信息,說明掛載成功,可以使用新分區了。

     [root@xxx ~]# mount /dev/xvdb1 /mnt [root@xxx ~]# df -h Filesystem      Size  Used Avail Use% Mounted on /dev/xvda1       40G  1.5G   36G   4% / tmpfs           498M     0  498M   0% /dev/shm /dev/xvdb1      5.0G  139M  4.6G   3% /mnt

http://xxxxxx/Linuxjc/1134150.html TechArticle

Copyright © Linux教程網 All Rights Reserved