LINUX LVM 添加新的硬盘扩容lv

/ linux / 0 条评论 / 2810浏览

虚拟机增加了一个50G 的硬盘。用 fdisk -l 可以看到这个新建的硬盘是/dev/sdb [root@test-mysql02 ~]# fdisk -l

Disk /dev/sda: 53.7 GB, 53687091200 bytes 64 heads, 32 sectors/track, 51200 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: 0x000af4e1

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 51200 51915776 8e Linux LVM Partition 2 does not end on cylinder boundary.

Disk /dev/mapper/vg_testmysql02-lv_root: 47.8 GB, 47789899776 bytes 255 heads, 63 sectors/track, 5810 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_testmysql02-lv_swap: 5368 MB, 5368709120 bytes 255 heads, 63 sectors/track, 652 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/sdb: 53.7 GB, 53687091200 bytes 64 heads, 32 sectors/track, 51200 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: 0x00000000 ###将硬盘创建成PV [root@test-mysql02 ~]# pvcreate /dev/sdb Physical volume "/dev/sdb" successfully created [root@test-mysql02 ~]# vgs VG #PV #LV #SN Attr VSize VFree vg_testmysql02 1 2 0 wz--n- 49.51g 0 ###将硬盘增加到VG中 [root@test-mysql02 ~]# vgextend vg_testmysql02 /dev/sdb Volume group "vg_testmysql02" successfully extended #####VG剩余空间,添加lv [root@test-mysql02 ~]# lvextend -l +100%FREE /dev/vg_testmysql02/lv_root Size of logical volume vg_testmysql02/lv_root changed from 44.51 GiB (11394 extents) to 94.50 GiB (24193 extents). Logical volume lv_root successfully resized. #######发现文件系统的大小没有改变,需要同步文件系统 [root@test-mysql02 ~]# resize2fs /dev/vg_testmysql02/lv_root resize2fs 1.41.12 (17-May-2010) Filesystem at /dev/vg_testmysql02/lv_root is mounted on /; on-line resizing required old desc_blocks = 3, new_desc_blocks = 6 Performing an on-line resize of /dev/vg_testmysql02/lv_root to 24773632 (4k) blocks. The filesystem on /dev/vg_testmysql02/lv_root is now 24773632 blocks long.

[root@test-mysql02 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_testmysql02-lv_root 93G 20G 69G 22% / tmpfs 3.9G 0 3.9G 0% /dev/shm /dev/sda1 477M 40M 412M 9% /boot