CentOS 下添加新硬盤並分區格式化

CentOS  下添加新硬盤並分區格式化

1.先添加一塊硬盤,並建立分區,格式化,然後掛載使用

Fdisk  l 來查看當前狀態下磁盤情況

[root@linux1 ~]# fdisk -l

Disk/dev/hda: 5368 MB, 5368709120 bytes

255heads, 63 sectors/track, 652 cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

Device Boot Start End Blocks Id System

/dev/hda1 * 1 13 104391 83 Linux

/dev/hda2 14 652 5132767 8e Linux LVM Disk/dev/hdb: 2147 MB, 2147483648 bytes

16heads, 63 sectors/track, 4161 cylinders

Units = cylinders of 1008 * 512 = 516096 bytes

Disk/dev/hdb doesn't contain a valid partition table

上面紅色標識行可以看出,添加了一塊新硬盤/dev/hdb,大小爲 2G,未分區格式化狀態。

2. Fdisk /dev/hdb 來進行分區操作

[root@linux1 ~]# fdisk /dev/hdb

Device contains neither a valid DOS partitiontable, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel. Changes willremain in memory only, until you decide to write them. After that, of course,the previous content won't be recoverable.

Thenumber of cylinders for this disk is set to 4161.

There is nothing wrong with that, but this islarger than 1024, and could in certain setups cause problems with:

1) software that runs at boot time (e.g.,old versions of LILO)

2) booting and partitioning software fromother OSs

(e.g., DOS FDISK, OS/2 FDISK)

Warning: invalid flag 0x0000 of partitiontable 4 will be corrected by w(rite)

Command (m for help): n //輸入 N 表示新建一個分區

Command action e extended

p primary partition (1-4)

p //p 表示建立一個原始分區

Partition number (1-4): 1 //1  表示此分區編號爲 1.

First cylinder (1-4161, default 1): 1 //1 表示使用默認起始柱面號.如果要分多個區的話,先盤算好要多大,再輸入數字

Last cylinder or size or sizeM or sizeK(1-4161, default 4161): //  輸入:  回車表示使用默認結束柱面號.即此分區使用整個硬盤空間

Using default value 4161

Command (m for help): w //保存分區

The partition table has been altered!Calling ioctl() to re-read partition table.

Syncing disks.

3.再次查看當前分區狀態

[root@linux1 ~]# fdisk -l

Disk /dev/hda: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

Device Boot Start End Blocks Id System

/dev/hda1 * 1 13 104391 83 Linux

/dev/hda2 14 652 5132767 8e Linux LVM

Disk /dev/hdb: 2147 MB, 2147483648 bytes

16 heads, 63 sectors/track, 4161 cylinders

Units = cylinders of 1008 * 512 = 516096bytes

Device Boot Start End Blocks Id System

/dev/hdb1 1 4161 2097112 83 Linux

可以看出,已經出來了一個/dev/hdb1 的新分區。下一步將其格式化,再使用

4. mkfs.ext4格式化新分區(服務器的話建議使用 ext4/mkf 格式)

[root@linux1 ~]# mkfs.ext4 /dev/hdb1

5.掛載使用

[root@linux1 ~]# mkdir /mnt/hdb1 //新建一個掛載點。

[root@linux1 ~]# mount /dev/hdb1 /mnt/hdb1//掛載。

[root@linux1 ~]# df -h

文件系統容量已用可用已用%  掛載點

/dev/mapper/VolGroup00-LogVol00

4.3G 3.6G 487M 89% /

/dev/hda1 99M 12M 82M 13% /boot tmpfs 125M0 125M 0% /dev/shm

/dev/hdb1 2.0G 3.0M 1.9G 1% /mnt/hdb1

7.設置新硬盤開機自動掛載

vi /etc/fstab 中添加新硬盤的掛載信息.添加下面一行:

/dev/hdb1 /mnt/hdb1 ext3 defaults 1 2(如果還有一個分區就是 1 3,以此類推)

這樣,每次開機後,系統會自動將/dev/hdb1 掛載到/mnt/hdb1


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章