- 首先查看機(jī)器上有多少塊硬盤(pán):
$ fdisk -l
Disk /dev/sdd: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 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
Disk /dev/sdd doesn't contain a valid partition table
……
Disk /dev/sdh: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 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: 0xd54c485e
Device Boot Start End Blocks Id System
/dev/sdh1 1 121601 976760001 83 Linux
我的服務(wù)器上有很多塊,有上述信息可知,目前sdd硬盤(pán)還為掛載
- 硬盤(pán)分區(qū)
$ fdisk /dev/sdd
n->p->1->回車(chē)->回車(chē)
意思就是新建一個(gè)主分區(qū),大小是整個(gè)sdd磁盤(pán)
最后執(zhí)行w,寫(xiě)入磁盤(pán)
此時(shí)磁盤(pán)已經(jīng)分區(qū),但是還沒(méi)有文件系統(tǒng),磁盤(pán)依然不能用
- 格式化磁盤(pán)并寫(xiě)入文件系統(tǒng)
$ mkfs.ext4 /dev/sdd1
等待命令執(zhí)行完成
- 掛載新硬盤(pán)到操作系統(tǒng)的某個(gè)節(jié)點(diǎn)上
$ mkdir /mnt/sdd
$ mount /dev/sdd1 /mnt/sdd
- 執(zhí)行df命令查看磁盤(pán)信息,確認(rèn)掛載新硬盤(pán)成功
$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 928204272 4191296 876862896 1% /
tmpfs 32981876 12 32981864 1% /dev/shm
/dev/sda1 198337 31960 156137 17% /boot
/dev/sdh1 961432072 204436 912389636 1% /mnt/sdh
/dev/sdd1 961432072 204436 912389636 1% /mnt/sdd
以上加粗字體就是新增磁盤(pán)。