感谢支持
我们一直在努力

新增硬盘扩容Linux下的分区大小





















     

主题


新增硬盘扩容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.

五、查看分区情况


[root@localhost~]# df -l


Filesystem           1K-blocks      Used Available Use% Mounted on


/dev/mapper/VolGroup00-LogVol00


                      19172036   3898228 14284216  22% /


/dev/sda1               101086     12177    83690  13% /boot


tmpfs                   257604         0   257604   0% /dev/shm


 


六、查看卷组信息


[root@localhost~]# vgdisplay


  /dev/hdc: open failed: No medium found


  — Volume group —


  VG Name               VolGroup00


  System ID            


  Format                lvm2


  Metadata Areas        1


  Metadata Sequence No  3


  VG Access             read/write


  VG Status             resizable


  MAX LV                0


  Cur LV                2


  Open LV               2


  Max PV                0


  Cur PV                1


  Act PV                1


  VG Size               19.88 GB


  PE Size               32.00 MB


  Total PE              636


  Alloc PE / Size       636 / 19.88 GB


  Free PE / Size       0 / 0  


  VG UUID              7jEsDl-z6et-uIFB-D4NY-9OIM-UGBK-HZrbrP


 


七、创建物理卷


 [root@localhost ~]# pvcreate /dev/sdb1


  Physical volume “/dev/sdb1″successfully created


 


八、想卷组中添加物理卷


 [root@localhost ~]# vgextend /dev/VolGroup00/dev/sdb1


  /dev/hdc: open failed: No medium found


  Volume group “VolGroup00″successfully extended


 


九、查看卷组信息


[root@localhost~]# vgdisplay


  /dev/hdc: open failed: No medium found


  — Volume group —


  VG Name               VolGroup00


  System ID            


  Format                lvm2


  Metadata Areas        2


  Metadata Sequence No  4


  VG Access             read/write


  VG Status            resizable


  MAX LV                0


  Cur LV                2


  Open LV               2


  Max PV                0


  Cur PV                2


  Act PV                2


  VG Size               39.84 GB


  PE Size               32.00 MB


  Total PE             1275


  Alloc PE / Size       636 / 19.88 GB


  Free PE / Size       639 / 19.97 GB


  VG UUID              7jEsDl-z6et-uIFB-D4NY-9OIM-UGBK-HZrbrP


 


 十、增加卷容量


 [root@localhost ~]# lvextend -L +1024M/dev/VolGroup00/LogVol00


  /dev/hdc: open failed: No medium found


  Extending logical volume LogVol00 to 19.88 GB


  Logical volume LogVol00 successfully resized

十一、重建大小


 [root@localhost ~]# /sbin/resize2fs/dev/VolGroup00/LogVol00


resize2fs 1.39(29-May-2006)


Filesystem at/dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required


Performing anon-line resize of /dev/VolGroup00/LogVol00 to 5210112 (4k) blocks.


The filesystemon /dev/VolGroup00/LogVol00 is now 5210112 blocks long.


 


十二、查看效果


[root@localhost~]# df -l


Filesystem           1K-blocks      Used Available Use% Mounted on


/dev/mapper/VolGroup00-LogVol00


                      20187780   3898352 15247420  21% /


/dev/sda1               101086     12177    83690  13% /boot


tmpfs                   257604         0   257604   0% /dev/shm

赞(0) 打赏
转载请注明出处:服务器评测 » 新增硬盘扩容Linux下的分区大小
分享到: 更多 (0)

听说打赏我的人,都进福布斯排行榜啦!

支付宝扫一扫打赏

微信扫一扫打赏