轉自:http://blog.csdn.net/season_hangzhou/article/details/36423223
一、安裝硬盤到物理機上。
二、查看硬盤是否正確安裝。
使用“fdisk -l”命令查看硬盤代號。
root@greatms-All-Series:/home/share# fdisk -l Disk /dev/sda: 500.1 GB, 500107862016 bytes 255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors Units = 扇區 of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk identifier: 0x000aab9b 設備 啟動 起點 終點 塊數 Id 系統 /dev/sda1 * 2048 488282111 244140032 83 Linux /dev/sda2 488284158 976771071 244243457 5 擴展 Partition 2 does not start on physical sector boundary. /dev/sda5 488284160 820314111 166014976 83 Linux /dev/sda6 820316160 976771071 78227456 82 Linux 交換 / Solaris WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted. Disk /dev/sdb: 3000.6 GB, 3000592982016 bytes 255 heads, 63 sectors/track, 364801 cylinders, total 5860533168 sectors Units = 扇區 of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk identifier: 0x00000000 設備 啟動 起點 終點 塊數 Id 系統 /dev/sdb1 1 4294967295 2147483647+ ee GPT Partition 1 does not start on physical sector boundary.
可以看到我新增了的硬盤標識為sdb。
三、將硬盤分區。
1、當硬盤小於等於2T時,可以用fdisk。
fdisk /dev/sdb 1、查看幫助。 輸入:m 2、新建分區。 輸入:n 3、創建邏輯分區 輸入:p 4、輸入分區號以及指定分區大小 依照提示,回車表示默認。 5、檢查分區情況(此時還未執行分區操作) Command(m for help):p 6、保存退出 Command(m for help):w
2、當硬盤大於2T時,用parted命令。
parted /dev/sdb (用part命令對3T硬盤進行分區處理) mklabel gpt (用gpt格式可以將3TB弄在一個分區里) unit TB (設置單位為TB) mkpart primary 0 3 (設置為一個主分區,大小為3TB,開始是0,結束是3) print (顯示設置的分區大小) quit (退出parted程序)
四、格式化分區。
mkfs.ext4 /dev/sdb1
五、將硬盤掛載到文件夾下。
1、手動掛載。
新建一個文件夾:mkdir /home/sdb1
掛載:mount /dev/sdb1 /home/sdb1
2、開機自動掛載。
輸入:vi /etc/fstab
在最后加入:
/dev/sdb1 /home/sdb1 ext4 defaults 1 1