溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

CentOS下怎么添加新硬盤(pán)并分區(qū)格式化

發(fā)布時(shí)間:2021-09-17 17:45:46 來(lái)源:億速云 閱讀:195 作者:chen 欄目:系統(tǒng)運(yùn)維

這篇文章主要講解了“CentOS下怎么添加新硬盤(pán)并分區(qū)格式化”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來(lái)研究和學(xué)習(xí)“CentOS下怎么添加新硬盤(pán)并分區(qū)格式化”吧!

下面看我操作的步驟:
1.先用Fdisk -l 來(lái)查看當(dāng)前狀態(tài)下磁盤(pán)情況
 
[root@linux1 ~]# fdisk -l
Disk /dev/hda: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
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 = 516096 bytes
Disk /dev/hdb doesn't contain a valid partition table
上面紅色標(biāo)識(shí)行可以看出,我添加了一塊新硬盤(pán)/dev/hdb,大小為2G,未分區(qū)格式化狀態(tài)。
 
2.用Fdisk /dev/hdb來(lái)進(jìn)行分區(qū)操作。
 
[root@linux1 ~]# fdisk /dev/hdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
 
The number of cylinders for this disk is set to 4161.
There is nothing wrong with that, but this is larger 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 from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
 
Command (m for help): n //輸入N表示新建一個(gè)分區(qū)
Command action
e extended
p primary partition (1-4)
p //p 表示建立一個(gè)原始分區(qū)
Partition number (1-4): 1 //1 表示此分區(qū)編號(hào)為1.
First cylinder (1-4161, default 1): 1 //1表示使用默認(rèn)起始柱面號(hào).如果要分多個(gè)區(qū)的話(huà),先盤(pán)算好要多大,再輸入數(shù)字
Last cylinder or size or sizeM or sizeK (1-4161, default 4161): // 輸入: 回車(chē) 表示使用默認(rèn)結(jié)束柱面號(hào).即此分區(qū)使用整個(gè)硬盤(pán)空間
 
Using default value 4161
 
Command (m for help): w //保存分區(qū)
 
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
Syncing disks.
 
3.再次查看當(dāng)前分區(qū)狀態(tài):
[root@linux1 ~]# fdisk -l
 
Disk /dev/hda: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
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 = 516096 bytes
 
Device Boot Start End Blocks Id System
/dev/hdb1 1 4161 2097112 83 Linux
可以看出,已經(jīng)出來(lái)了一個(gè)/dev/hdb1的新分區(qū)。下一步將其格式化,再使用
 
4.用mkfs.ext3格式化新分區(qū)
[root@linux1 ~]# mkfs.ext3 /dev/hdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
262144 inodes, 524278 blocks
26213 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
 
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
 
This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
 
5.掛載使用。
[root@linux1 ~]# mkdir /mnt/hdb1 //新建一個(gè)掛載點(diǎn)。
[root@linux1 ~]# mount /dev/hdb1 /mnt/hdb1 //掛載。
[root@linux1 ~]# df -h
文件系統(tǒng) 容量 已用 可用 已用% 掛載點(diǎn)
/dev/mapper/VolGroup00-LogVol00
4.3G 3.6G 487M 89% /
/dev/hda1 99M 12M 82M 13% /boot
tmpfs 125M 0 125M 0% /dev/shm
/dev/hdb1 2.0G 3.0M 1.9G 1% /mnt/hdb1
 
6 .開(kāi)機(jī)自動(dòng)掛載
三.設(shè)置新硬盤(pán)開(kāi)機(jī)自動(dòng)掛載
在vi /etc/fstab中添加新硬盤(pán)的掛載信息.添加下面一行:
/dev/hdb1 /mnt/hdb1 ext3 defaults 1 2(如果還有一個(gè)分區(qū)就是1 3,以此類(lèi)推)
這樣,每次開(kāi)機(jī)后,系統(tǒng)會(huì)自動(dòng)將/dev/hdb1掛載到/mnt/hdb1

感謝各位的閱讀,以上就是“CentOS下怎么添加新硬盤(pán)并分區(qū)格式化”的內(nèi)容了,經(jīng)過(guò)本文的學(xué)習(xí)后,相信大家對(duì)CentOS下怎么添加新硬盤(pán)并分區(qū)格式化這一問(wèn)題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是億速云,小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI