Vmware centos 虚拟机根分区磁盘扩容(基于LVM)

由于开发测试机器dev-vhost017根分区规划不足只有10G,需要扩容。(基于LVM)

先关闭dev-vhost017,然后在vSphere Client 将根分区硬盘10G 调整到50G

开启虚拟机
原始/ 大小 10G

[root@dev-vhost017 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_centos6-lv_root
                      8.3G  4.0G  3.9G  51% /
tmpfs                 939M   12K  939M   1% /dev/shm
/dev/sda1             477M   57M  396M  13% /boot


查看磁盘sda已扩展到50G
[root@dev-vhost017 ~]# fdisk /dev/sda

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): p

Disk /dev/sda: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 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: 0x0007ef5b

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        1306     9972736   8e  Linux LVM

Disk /dev/mapper/vg_centos6-lv_root: 9135 MB, 9135194112 bytes
255 heads, 63 sectors/track, 1110 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: 0x00000000


Disk /dev/mapper/vg_centos6-lv_swap: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 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: 0x00000000


  
  


查看lvm状态
[root@dev-vhost017 ~]# pvs
  PV         VG         Fmt  Attr PSize PFree
  /dev/sda2  vg_centos6 lvm2 a--  9.51g    0 
[root@dev-vhost017 ~]# vgs
  VG         #PV #LV #SN Attr   VSize VFree
  vg_centos6   1   2   0 wz--n- 9.51g    0 
[root@dev-vhost017 ~]# lvs
  LV      VG         Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lv_root vg_centos6 -wi-ao---- 8.51g                                                    
  lv_swap vg_centos6 -wi-ao---- 1.00g


分区/dev/sda3
[root@dev-vhost017 ~]# fdisk /dev/sda

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): p

Disk /dev/sda: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 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: 0x0007ef5b

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        1306     9972736   8e  Linux LVM
/dev/sda3            1306        6527    41942367+  83  Linux


[root@dev-vhost017 ~]# partprobe


重启虚拟机 格式化/dev/sda3
[root@dev-vhost017 ~]# mkfs.ext4 /dev/sda3


lvm 扩容

[root@dev-vhost017 ~]# pvcreate  /dev/sda3
  Physical volume "/dev/sda3" successfully created

[root@dev-vhost017 ~]# pvs
  PV         VG         Fmt  Attr PSize  PFree 
  /dev/sda2  vg_centos6 lvm2 a--   9.51g     0 
  /dev/sda3             lvm2 ---  40.00g 40.00g

[root@dev-vhost017 ~]# vgextend /dev/mapper/vg_centos6 /dev/sda3 (注意组名)
  Volume group "vg_centos6" successfully extended

[root@dev-vhost017 ~]# lvextend -L 39.9G /dev/vg_centos6/lv_root /dev/sda3
  Rounding size to boundary between physical extents: 39.90 GiB
  Size of logical volume vg_centos6/lv_root changed from 8.51 GiB (2178 extents) to 39.90 GiB (10215 extents).
  Logical volume lv_root successfully resized


[root@dev-vhost017 ~]# resize2fs /dev/vg_centos6/lv_root 
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg_centos6/lv_root is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 3
Performing an on-line resize of /dev/vg_centos6/lv_root to 10460160 (4k) blocks.
The filesystem on /dev/vg_centos6/lv_root is now 10460160 blocks long.


[root@dev-vhost017 ~]# pvs
  PV         VG         Fmt  Attr PSize  PFree
  /dev/sda2  vg_centos6 lvm2 a--   9.51g    0 
  /dev/sda3  vg_centos6 lvm2 a--  40.00g 8.60g
[root@dev-vhost017 ~]# vgs
  VG         #PV #LV #SN Attr   VSize  VFree
  vg_centos6   2   2   0 wz--n- 49.50g 8.60g
[root@dev-vhost017 ~]# lvs
  LV      VG         Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lv_root vg_centos6 -wi-ao---- 39.90g                                                    
  lv_swap vg_centos6 -wi-ao----  1.00g   


[root@dev-vhost017 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_centos6-lv_root
                       40G  4.0G   34G  11% /
tmpfs                 939M   12K  939M   1% /dev/shm
/dev/sda1             477M   57M  396M  13% /boot




转载于:https://my.oschina.net/davehe/blog/528518

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值