Linux的硬盤(pán)識(shí)別:
一般使用”fdisk -l”命令可以列出系統(tǒng)中當(dāng)前連接的硬盤(pán)
設(shè)備和分區(qū)信息.新硬盤(pán)沒(méi)有分區(qū)信息,則只顯示硬盤(pán)大小信息.
1.關(guān)閉服務(wù)器加上新硬盤(pán)
2.啟動(dòng)服務(wù)器,以root用戶(hù)登錄
3.查看硬盤(pán)信息
1
|
#fdisk -l |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
Disk /dev/sda : 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: 0x0004406e Device Boot Start End Blocks Id System /dev/sda1 * 1 39 307200 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 39 2589 20480000 83 Linux /dev/sda3 2589 2850 2097152 82 Linux swap / Solaris /dev/sda4 2850 5222 19057664 5 Extended /dev/sda5 2850 5222 19056640 83 Linux Disk /dev/sdb : 10.7 GB, 10737418240 bytes 255 heads, 63 sectors /track , 1305 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: 0x14b52796 Device Boot Start End Blocks Id System |
4.創(chuàng)建新硬盤(pán)分區(qū)命令參數(shù):
fdisk可以用m命令來(lái)看fdisk命令的內(nèi)部命令;
- a:命令指定啟動(dòng)分區(qū);
- d:命令刪除一個(gè)存在的分區(qū);
- l:命令顯示分區(qū)ID號(hào)的列表;
- m:查看fdisk命令幫助;
- n:命令創(chuàng)建一個(gè)新分區(qū);
- p:命令顯示分區(qū)列表;
- t:命令修改分區(qū)的類(lèi)型ID號(hào);
- w:命令是將對(duì)分區(qū)表的修改存盤(pán)讓它發(fā)生作用。
5.進(jìn)入磁盤(pán),對(duì)磁盤(pán)進(jìn)行分區(qū),注意紅色部分。
1
|
#fdisk /dev/sdb |
1
2
3
4
5
6
7
8
9
10
11
|
Command (m for help):n Command action e extended // 輸入e為創(chuàng)建擴(kuò)展分區(qū) p primary partition (1-4) // 輸入p為創(chuàng)建邏輯分區(qū) p Partion number(1-4):1 // 在這里輸入l,就進(jìn)入劃分邏輯分區(qū)階段了; First cylinder (51-125, default 51): // 注:這個(gè)就是分區(qū)的Start 值;這里最好直接按回車(chē),如果您輸入了一個(gè)非默認(rèn)的數(shù)字,會(huì)造成空間浪費(fèi); Using default value 51 Last cylinder or +size or +sizeM or +sizeK (51-125, default 125): +200M 注:這個(gè)是定義分區(qū)大小的,+200M 就是大小為200M ;當(dāng)然您也可以根據(jù)p提示的單位cylinder的大小來(lái)算,然后來(lái)指定 End的數(shù)值。回頭看看是怎么算的;還是用+200M這個(gè)辦法來(lái)添加,這樣能直觀一點(diǎn)。如果您想添加一個(gè)10G左右大小的分區(qū),請(qǐng)輸入 +10000M ; Command (m for help): w // 最后輸入w回車(chē)保存。 |
查看一下:
1
|
#fdisk -l |
可以看到/dev/sdb1分區(qū),我就省略截圖咯。
6.格式化分區(qū):
1
|
#mkfs.ext3 /dev/sdb1 //注:將/dev/sdb1格式化為ext3類(lèi)型 |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
mke2fs 1.41.12 (17-May-2010) 文件系統(tǒng)標(biāo)簽= 操作系統(tǒng):Linux 塊大小=4096 (log=2) 分塊大小=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 640848 inodes, 2562359 blocks 128117 blocks (5.00%) reserved for the super user 第一個(gè)數(shù)據(jù)塊=0 Maximum filesystem blocks=2625634304 79 block groups 32768 blocks per group, 32768 fragments per group 8112 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 正在寫(xiě)入inode表: 完成 Creating journal (32768 blocks): 完成 Writing superblocks and filesystem accounting information: 完成 This filesystem will be automatically checked every 35 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. |
這樣就格式化好了,我們就可以用mount 加載這個(gè)分區(qū),然后使用這個(gè)文件系統(tǒng);
7.創(chuàng)建/data1目錄:
1
|
#mkdir /data1 |
8.開(kāi)始掛載分區(qū):
1
|
#mount /dev/sdb1 /data1 |
9.查看硬盤(pán)大小以及掛載分區(qū):
1
|
#df -h |
10.配置開(kāi)機(jī)自動(dòng)掛載
因?yàn)閙ount掛載在重啟服務(wù)器后會(huì)失效,所以需要將分區(qū)信息寫(xiě)到/etc/fstab文件中讓它永久掛載:
1
|
#vim /etc/fstab |
加入:
/dev/sdb1(磁盤(pán)分區(qū)) /data1(掛載目錄) ext3(文件格式)defaults 0 0
11.重啟系統(tǒng)
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持服務(wù)器之家。
原文鏈接:http://blog.csdn.net/zqixiao_09/article/details/51417432