vm中centos扩展硬盘空间

首先在vm中将虚拟机关机,然后扩展空间就好,图形化操作很简单。
然后就是开机进入centos系统中
df -h 查看硬盘空间

 df -h
Filesystem                     Size  Used Avail Use% Mounted on
/dev/mapper/vg_heaboy-lv_root   18G   16G  1.2G  93% /
tmpfs                          495M   76K  495M   1% /dev/shm
/dev/sda1                      485M   35M  426M   8% /boot

[root@heaboy ~]# 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: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 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: 0x000a188c

   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        2611    20458496   8e  Linux LVM

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
3
Invalid partition number for type `3'
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (2611-5221, default 2611): 
Using default value 2611
Last cylinder, +cylinders or +size{K,M,G} (2611-5221, default 5221): 
Using default value 5221

Command (m for help): p

Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 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: 0x000a188c

   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        2611    20458496   8e  Linux LVM
/dev/sda3            2611        5221    20966162+  83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

然后重启 reboot

pvcreate /dev/sda3
  Physical volume "/dev/sda3" successfully created

注意下面的vg_heaboy 和vg_heaboy-lv_root
vg_heaboy-lv_root这个是可以快捷显示出来的
并没有vg_heaboy 这个 但是这是一个组 可以用的
heaboy 是我的主机名
具体的请参照本机名

  vgextend /dev/mapper/vg_heaboy  /dev/sda3        
  Volume group "vg_heaboy" successfully extended
  lvextend -L +19G /dev/mapper/vg_heaboy-lv_root   
  Extending logical volume lv_root to 36.57 GiB
  Logical volume lv_root successfully resized
resize2fs /dev/mapper/vg_heaboy-lv_root 
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/vg_heaboy-lv_root is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 3
Performing an on-line resize of /dev/mapper/vg_heaboy-lv_root to 9586688 (4k) blocks.
The filesystem on /dev/mapper/vg_heaboy-lv_root is now 9586688 blocks long.

最后查看df -h 看是否添加成功
转载自http://www.linuxidc.com/Linux/2012-09/69568.htm

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值