主題
新增硬盤擴容Linux下的分區大小
關鍵詞
Linux分區 調整大小
操作環境
VMWare7.0+RHEL5
問題分析
在目錄大小不足的情況下在線對其進行擴容
一、首先是在關機的環境下點擊虛擬機的屬性,對其添加一塊硬盤
二、查看硬盤狀態
[root@localhost~]# fdisk -l
Disk /dev/sda:21.4 GB, 21474836480 bytes
255 heads, 63sectors/track, 2610 cylinders
Units =cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 2610 20860402+ 8e Linux LVM
Disk /dev/sdb:21.4 GB, 21474836480 bytes
255 heads, 63sectors/track, 2610 cylinders
Units =cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdbdoesn't contain a valid partition table//顯示找到一個盤sdb,但是沒有有效的分區表
三、查看新盤的信息
[root@localhost~]# df /dev/sdb
Filesystem 1K-blocks Used Available Use% Mounted on
- 257604 100 257504 1% /dev
四、對新盤進行分區
[root@localhost~]# fdisk /dev/sdb
Device containsneither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a newDOS disklabel. Changes will remain in memory only,
until youdecide to write them. After that, of course, the previous
content won'tbe recoverable.
The number ofcylinders for this disk is set to 2610.
There isnothing wrong with that, but this is larger than 1024,
and could incertain setups cause problems with:
1) softwarethat runs at boot time (e.g., old versions of LILO)
2) booting andpartitioning 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 forhelp): n//創建一個新的邏輯磁盤
Command action
e extended//擴展分區
p primary partition (1-4)
p//主分區
Partitionnumber (1-4): 1//相當於盤符
First cylinder(1-2610, default 1): 1//第一柱頭
Last cylinderor +size or +sizeM or +sizeK (1-2610, default 2610): 2610//最後的柱頭
Command (m forhelp): t//選擇分區類型
Selectedpartition 1
Hex code (typeL to list codes): 83//83是Linux類型,,具體類型可以在l下面看到
Command (m forhelp): w//寫入分區表
The partitiontable has been altered!
Calling ioctl()to re-read partition table.
Syncing disks.
//下面是格式化分區為ext3格式
[root@localhost~]# mkfs.ext3 /dev/sdb1
mke2fs 1.39(29-May-2006)
Filesystemlabel=
OS type: Linux
Block size=4096(log=2)
Fragmentsize=4096 (log=2)
2621440 inodes,5241198 blocks
262059 blocks(5.00%) reserved for the super user
First datablock=0
Maximumfilesystem blocks=0
160 blockgroups
32768 blocksper group, 32768 fragments per group
16384 inodesper group
Superblockbackups stored on blocks:
32768, 98304, 163840, 229376, 294912,819200, 884736, 1605632, 2654208,
4096000
Writing inodetables: done
Creatingjournal (32768 blocks): done
Writingsuperblocks and filesystem accounting information: done
This filesystemwill be automatically checked every 37 mounts or
180 days,whichever comes first. Use tune2fs -c or-i to override.