linux系统下如何新增vg大小
作者:Lfei5120
文章介绍了在Linux系统下新增和扩容卷组(VG)的操作步骤,包括添加数据盘、创建物理卷(PV)、将PV添加到VG、创建逻辑卷(LV)、赋予文件系统以及挂载LV
linux系统下新增vg大小
最近有很多身边小伙伴问我呀,linux下面新增vg具体怎么操作,还有linux下面扩容已有vg怎么操作,那么接下来,我就带大家看看我们如何新增和扩容。
1.由于资源有限
所以我只能新增10G,哎~~,添加一个10G的数据盘。
添加数据盘之后我们可以看见的哈,我添加完成之后名字叫sdb,
[root@localhost ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 20G 0 disk ├─sda1 8:1 0 300M 0 part /boot ├─sda2 8:2 0 2G 0 part [SWAP] └─sda3 8:3 0 17.7G 0 part / sdb 8:16 0 10G 0 disk sr0 11:0 1 1024M 0 rom [root@localhost ~]# fdisk -l Disk /dev/sda: 21.5 GB, 21474836480 bytes, 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 label type: dos Disk identifier: 0x000dad8d Device Boot Start End Blocks Id System /dev/sda1 * 2048 616447 307200 83 Linux /dev/sda2 616448 4810751 2097152 82 Linux swap / Solaris /dev/sda3 4810752 41943039 18566144 83 Linux Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 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 [root@localhost ~]#
2.创建这块盘PV
[root@localhost ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 20G 0 disk ├─sda1 8:1 0 300M 0 part /boot ├─sda2 8:2 0 2G 0 part [SWAP] └─sda3 8:3 0 17.7G 0 part / sdb 8:16 0 10G 0 disk sr0 11:0 1 1024M 0 rom [root@localhost ~]# pvcreate /dev/sdb Physical volume "/dev/sdb" successfully created. [root@localhost ~]#
3.将这一块盘创建成VG
VG名vgdata1
[root@localhost ~]# vgcreate vgdata1 /dev/sdb Volume group "vgdata1" successfully created [root@localhost ~]# vgs VG #PV #LV #SN Attr VSize VFree vgdata1 1 0 0 wz--n- <10.00g <10.00g [root@localhost ~]#
4.创建一个LV
名称为Lvdata1,创建完成之后并查看。
[root@localhost ~]# lvcreate -L 9.9G -n Lvdata1 vgdata1 Rounding up size to full physical extent 9.90 GiB Logical volume "Lvdata1" created. [root@localhost ~]# cd /dev/mapper/ [root@localhost mapper]# ls control vgdata1-Lvdata1 [root@localhost mapper]#
5.将已经创建完成的vgdata1-Lvdata1给它赋予文件系统
我在这里就不过多解释哦~~
[root@localhost ~]# mkfs.ext4 /dev/mapper/ control vgdata1-Lvdata1 [root@localhost ~]# mkfs.ext4 /dev/mapper/vgdata1-Lvdata1 mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 648960 inodes, 2595840 blocks 129792 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2151677952 80 block groups 32768 blocks per group, 32768 fragments per group 8112 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done [root@localhost ~]#
6.到这一步就算是已经完成勒
如果需要挂载的话,那么可以继续往下面看哦~~
[root@localhost ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 20G 0 disk ├─sda1 8:1 0 300M 0 part /boot ├─sda2 8:2 0 2G 0 part [SWAP] └─sda3 8:3 0 17.7G 0 part / sdb 8:16 0 10G 0 disk └─vgdata1-Lvdata1 253:0 0 9.9G 0 lvm sr0 11:0 1 1024M 0 rom [root@localhost ~]#
7.需要挂载的话
悄悄告诉大家,需要创建挂载路径,或者在已经有的路径上进行挂载,根据客户需要,想挂哪儿就挂哪儿。
在这里我就想挂载到、/opt/a里面
[root@localhost ~]# mkdir /opt/a [root@localhost ~]# ls /opt a rh [root@localhost ~]# 在这里就已经挂载完成啦, [root@localhost ~]# mount /dev/mapper/vgdata1-Lvdata1 /opt/a [root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 18G 4.3G 14G 24% / devtmpfs 471M 0 471M 0% /dev tmpfs 487M 0 487M 0% /dev/shm tmpfs 487M 8.6M 478M 2% /run tmpfs 487M 0 487M 0% /sys/fs/cgroup /dev/sda1 297M 147M 151M 50% /boot tmpfs 98M 20K 98M 1% /run/user/1000 tmpfs 98M 0 98M 0% /run/user/0 /dev/mapper/vgdata1-Lvdata1 9.7G 37M 9.1G 1% /opt/a [root@localhost ~]#
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。