LVM管理体系(三)通过扩展VG扩展逻辑卷(操作步骤)

本文介绍了如何通过添加新的硬盘并创建分区,将其转化为物理卷加入现有的卷组中,进而扩展逻辑卷的过程。包括使用fdisk进行分区、pvcreate创建物理卷、vgextend扩展卷组、lvextend扩展逻辑卷及调整文件系统。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、离线逻辑卷

[root@instructor Desktop]#umount /dev/testvg/testlv

[root@instructor Desktop]# mount
/dev/mapper/GLSvg-GLSroot on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
/dev/mapper/GLSvg-GLShome on /home type ext4 (rw)
/dev/mapper/GLSvg-GLStmp on /tmp type ext4 (rw)
/dev/sda5 on /usr/local/share/gls/GLSINST type ext4 (ro)
/dev/mapper/GLSvg-GLSvar on /var type ext4 (rw)
/dev/mapper/GLSvg-GLSpub on /var/ftp/pub type ext4 (rw)
/usr/local/share/gls/GLSINST/rhel6/isos/rhel-server-6.3-x86_64-dvd.iso on /var/ftp/pub/rhel6/dvd type iso9660 (ro,loop=/dev/loop0)
/dev/mapper/testvg-testlv on /tmp/testlv type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
/etc/named on /var/named/chroot/etc/named type none (rw,bind)
/etc/rndc.key on /var/named/chroot/etc/rndc.key type none (rw,bind)
/usr/lib64/bind on /var/named/chroot/usr/lib64/bind type none (rw,bind)
/etc/named.root.key on /var/named/chroot/etc/named.root.key type none (rw,bind)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
nfsd on /proc/fs/nfsd type nfsd (rw)
gvfs-fuse-daemon on /root/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev)

二、在主机上添加一块硬盘并为其创建主分区SDD

[root@instructor Desktop]# fdisk -cul /dev/sdd


Disk /dev/sdd: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


[root@instructor Desktop]# fdisk -cu /dev/sdd
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x20e92de4.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.


Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)


Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First sector (2048-41943039, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): 
Using default value 41943039


Command (m for help): p


Disk /dev/sdd: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x20e92de4


   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1            2048    41943039    20970496   83  Linux


Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)


Command (m for help): p


Disk /dev/sdd: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x20e92de4


   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1            2048    41943039    20970496   8e  Linux LVM


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


Calling ioctl() to re-read partition table.
Syncing disks.
[root@instructor Desktop]# fdisk -cul /dev/sdd1


Disk /dev/sdd1: 21.5 GB, 21473787904 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41940992 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

三、为创建物理卷sdd1
[root@instructor Desktop]# pvcreate /dev/sdd1
  Writing physical volume data to disk "/dev/sdd1"
  Physical volume "/dev/sdd1" successfully created
[root@instructor Desktop]# pvdisplay /dev/sdd1
  "/dev/sdd1" is a new physical volume of "20.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdd1
  VG Name               
  PV Size               20.00 GiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               bdeEPp-L9Az-QVMg-f1O6-gaK0-vRcw-RvL1cF
   
 四、使用vgextend命令扩展卷组
[root@instructor Desktop]# vgextend testvg /dev/sdd1
  Volume group "testvg" successfully extended
[root@instructor Desktop]# vgdisplay 
  --- Volume group ---
  VG Name               testvg
  System ID             
  Format                lvm2
  Metadata Areas        3
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                3
  Act PV                3
  VG Size               59.98 GiB
  PE Size               8.00 MiB
  Total PE              7677
  Alloc PE / Size       3840 / 30.00 GiB
  Free  PE / Size       3837 / 29.98 GiB
  VG UUID               ARmaCh-vFbx-dqxr-asWG-p11h-1Tzc-dv1OEi
五、使用lvextend命令扩展逻辑卷
   
[root@instructor Desktop]# lvextend -L +20G /dev/testvg/testlv
  Extending logical volume testlv to 50.00 GiB

  Logical volume testlv successfully resized

六、为逻辑卷重建文件系统

[root@instructor Desktop]# resize2fs /dev/testvg/testlv
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/testvg/testlv is mounted on /tmp/testlv; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 4
Performing an on-line resize of /dev/testvg/testlv to 13107200 (4k) blocks.
The filesystem on /dev/testvg/testlv is now 13107200 blocks long.

七、挂载逻辑卷并查看逻辑卷的挂载状态

[root@instructor Desktop]# mount /dev/testvg/testlv /tmp/testlv

[root@instructor Desktop]# mount
/dev/mapper/GLSvg-GLSroot on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
/dev/mapper/GLSvg-GLShome on /home type ext4 (rw)
/dev/mapper/GLSvg-GLStmp on /tmp type ext4 (rw)
/dev/sda5 on /usr/local/share/gls/GLSINST type ext4 (ro)
/dev/mapper/GLSvg-GLSvar on /var type ext4 (rw)
/dev/mapper/GLSvg-GLSpub on /var/ftp/pub type ext4 (rw)
/usr/local/share/gls/GLSINST/rhel6/isos/rhel-server-6.3-x86_64-dvd.iso on /var/ftp/pub/rhel6/dvd type iso9660 (ro,loop=/dev/loop0)
/dev/mapper/testvg-testlv on /tmp/testlv type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
/etc/named on /var/named/chroot/etc/named type none (rw,bind)
/etc/rndc.key on /var/named/chroot/etc/rndc.key type none (rw,bind)
/usr/lib64/bind on /var/named/chroot/usr/lib64/bind type none (rw,bind)
/etc/named.root.key on /var/named/chroot/etc/named.root.key type none (rw,bind)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
nfsd on /proc/fs/nfsd type nfsd (rw)

gvfs-fuse-daemon on /root/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev)

/dev/mapper/testvg-testlv on /tmp/testlv type ext4 (rw)

[root@instructor Desktop]# 







评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值