大网数据广告活动
服务器运维问答

Increase the size of LVM after adding virtual disk space

· 52CE 我爱测

I have asked for a hard drive upgrade for my virtual server running centos 6.5 i can see that the space has been increased as /dev/sdb now is 214.7GB and used to be 150.3GB root@webhost [/sys/class/block/sdb/device]# fdisk -l Dis…

问题原文

原帖链接 · Meni · CC BY-SA 4.0

I have asked for a hard drive upgrade for my virtual server running centos 6.5

i can see that the space has been increased as /dev/sdb now is 214.7GB and used to be 150.3GB

root@webhost [/sys/class/block/sdb/device]# fdisk -l

Disk /dev/sda: 85.9 GB, 85899345920 bytes
64 heads, 32 sectors/track, 81920 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000390ad

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           2         501      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2             502        3573     3145728   82  Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3            3574       81920    80227328   83  Linux

Disk /dev/sdb: 214.7 GB, 214748364800 bytes
64 heads, 32 sectors/track, 204800 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x796ffff3

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1      143360   146800624   83  Linux

Disk /dev/mapper/backup-lv0: 150.3 GB, 150319661056 bytes
255 heads, 63 sectors/track, 18275 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

root@webhost [/sys/class/block/sdb/device]#

as you can see the current lvm size is 140GB

  --- Volume group ---
  VG Name               backup
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  15
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               140.00 GiB
  PE Size               4.00 MiB
  Total PE              35839
  Alloc PE / Size       35839 / 140.00 GiB
  Free  PE / Size       0 / 0   
  VG UUID               9WAEQb-oEXG-QdJ0-MIK9-ZEu1-x176-U76PzS

root@webhost [/sys/class/block/sdb/device]# 

how can i resize the lvm partition to match the drive's size?

已采纳解答

原帖链接 · shodanshok · CC BY-SA 4.0

You need to expand sdb1 to cover all available disk space. Then, you can pvresize /dev/sdb1 and lvextend -l +100%FREE <your_volume_name>.

Background info: in RHEL6 and previous, RedHat suggested to create a "Protective MBR" to prevent old OSes from modifying the LVM metadata. This means that LVM physical volumes where partition-based, rather than disk-based (as in your case). So, to extend the physical volume, you first need to extend the partition.

However, the fdisk version shipped with RHEL6 does not support simple partition resize. You need to remove and re-create the sdb1 partition, which needs to be absolutely identical to what you now have (except for the lenght/size, of course). I strongly suggest you to use fdisk -u, which will give you partition size in sector number rather than cylinders.

Alternatively, you can use parted which should support partition resize (this feature is version-dependent and I do not remember if the one shipped with RHEL6 supports it).

Be carefull: a wrongly-recreated partition will meen DATA LOSS. I suggest you practicing on a test virtual machine before doing that in producion.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-12-24)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。