Linux 下掛載新硬盤方法

Linux的硬盤識別:node

通常使用」fdisk -l」命令能夠列出系統中當前鏈接的硬盤vim

設備和分區信息.新硬盤沒有分區信息,則只顯示硬盤大小信息.服務器

 

1.關閉服務器加上新硬盤ide

 

2.啓動服務器,以root用戶登陸spa

 

3.查看硬盤信息操作系統

#fdisk -l.net

[cpp] view plain copy
 
  1. Disk /dev/sda: 42.9 GB, 42949672960 bytes  
  2. 255 heads, 63 sectors/track, 5221 cylinders  
  3. Units = cylinders of 16065 * 512 = 8225280 bytes  
  4. Sector size (logical/physical): 512 bytes / 512 bytes  
  5. I/O size (minimum/optimal): 512 bytes / 512 bytes  
  6. Disk identifier: 0x0004406e  
  7.    Device Boot      Start         End      Blocks   Id  System  
  8. /dev/sda1   *           1          39      307200   83  Linux  
  9. Partition 1 does not end on cylinder boundary.  
  10. /dev/sda2              39        2589    20480000   83  Linux  
  11. /dev/sda3            2589        2850     2097152   82  Linux swap / Solaris  
  12. /dev/sda4            2850        5222    19057664    5  Extended  
  13. /dev/sda5            2850        5222    19056640   83  Linux  
  14.    
  15. Disk /dev/sdb: 10.7 GB, 10737418240 bytes  
  16. 255 heads, 63 sectors/track, 1305 cylinders  
  17. Units = cylinders of 16065 * 512 = 8225280 bytes  
  18. Sector size (logical/physical): 512 bytes / 512 bytes  
  19. I/O size (minimum/optimal): 512 bytes / 512 bytes  
  20. Disk identifier: 0x14b52796  
  21.    Device Boot      Start         End      Blocks   Id  System  

 

 

4.建立新硬盤分區命令參數:orm

fdisk能夠用m命令來看fdisk命令的內部命令;blog

a:命令指定啓動分區;ip

d:命令刪除一個存在的分區;

l:命令顯示分區ID號的列表;

m:查看fdisk命令幫助;

n:命令建立一個新分區;

p:命令顯示分區列表;

t:命令修改分區的類型ID號;

w:命令是將對分區表的修改存盤讓它發生做用。

 

 

5.進入磁盤,對磁盤進行分區,注意紅色部分。

#fdisk /dev/sdb

[cpp] view plain copy
 
  1. Command (m for help):n  
  2. Command action  
  3.      e    extended                  //輸入e爲建立擴展分區  
  4.      p    primary partition (1-4)      //輸入p爲建立邏輯分區  
  5. p  
  6. Partion number(1-4):1      //在這裏輸入l,就進入劃分邏輯分區階段了;  
  7. First cylinder (51-125, default 51):   //注:這個就是分區的Start 值;這裏最好直接按回車,若是您輸入了一個非默認的數字,會形成空間浪費;  
  8. Using default value 51  
  9. Last cylinder or +size or +sizeM or +sizeK (51-125, default 125): +200M 注:這個是定義分區大小的,+200M 就是大小爲200M ;固然您也能夠根據p提示的單位cylinder的大小來算,而後來指定 End的數值。回頭看看是怎麼算的;仍是用+200M這個辦法來添加,這樣能直觀一點。若是您想添加一個10G左右大小的分區,請輸入 +10000M ;  
  10.   
  11. Command (m for help): w                     //最後輸入w回車保存。  

查看一下: 

#fdisk -l

能夠看到/dev/sdb1分區,我就省略截圖咯。

 

6.格式化分區:

#mkfs.ext3 /dev/sdb1           //注:將/dev/sdb1格式化爲ext3類型

[cpp] view plain copy
 
  1. mke2fs 1.41.12 (17-May-2010)  
  2. 文件系統標籤=  
  3. 操做系統:Linux  
  4. 塊大小=4096 (log=2)  
  5. 分塊大小=4096 (log=2)  
  6. Stride=0 blocks, Stripe width=0 blocks  
  7. 640848 inodes, 2562359 blocks  
  8. 128117 blocks (5.00%) reserved for the super user  
  9. 第一個數據塊=0  
  10. Maximum filesystem blocks=2625634304  
  11. 79 block groups  
  12. 32768 blocks per group, 32768 fragments per group  
  13. 8112 inodes per group  
  14. Superblock backups stored on blocks:  
  15.         32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632  
  16.    
  17. 正在寫入inode表: 完成  
  18. Creating journal (32768 blocks): 完成  
  19. Writing superblocks and filesystem accounting information: 完成  
  20.    
  21. This filesystem will be automatically checked every 35 mounts or  
  22. 180 days, whichever comes first.  Use tune2fs -c or -i to override.  

這樣就格式化好了,咱們就能夠用mount 加載這個分區,而後使用這個文件系統;

 

7.建立/data1目錄:

#mkdir /data1

 

8.開始掛載分區:

#mount /dev/sdb1 /data1

 

9.查看硬盤大小以及掛載分區:

#df -h

 

10.配置開機自動掛載

由於mount掛載在重啓服務器後會失效,因此須要將分區信息寫到/etc/fstab文件中讓它永久掛載:

#vim /etc/fstab

加入:

/dev/sdb1(磁盤分區)  /data1(掛載目錄) ext3(文件格式)defaults  0  0


11.重啓系統

 

http://www.javashuo.com/article/p-mvvlkvnp-hc.html

相關文章
相關標籤/搜索