博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Linux LVM系列(四)vg扩容和lv扩容
阅读量:6325 次
发布时间:2019-06-22

本文共 5174 字,大约阅读时间需要 17 分钟。

上篇是lv卷的大小扩容,本篇是怎样给卷组增加容量和对lv在线扩容

增加磁盘(略)

快速分区

[root@aiker01 ~]# fdisk /dev/sdbCommand (m for help): nAll primary partitions are in useAdding logical partition 8First sector (25176064-41943039, default 25176064): Using default value 25176064Last sector, +sectors or +size{K,M,G} (25176064-41943039, default 41943039): +2GPartition 8 of type Linux and of size 2 GiB is setCommand (m for help): tPartition number (1-8, default 8): Hex code (type L to list all codes): 8eChanged type of partition 'Linux' to 'Linux LVM'Command (m for help): wThe partition table has been altered!

手动更新分区表

[root@aiker01 ~]# partprobe

列出分区

**[root@aiker01 ~]# parted -l

Model: VMware, VMware Virtual S (scsi)Disk /dev/sdb: 21.5GBSector size (logical/physical): 512B/512BPartition Table: msdosDisk Flags: Number  Start   End     Size    Type      File system  Flags 1      1049kB  2149MB  2147MB  primary                lvm 2      2149MB  4296MB  2147MB  primary                lvm 3      4296MB  6443MB  2147MB  primary                lvm 4      6443MB  21.5GB  15.0GB  extended 5      6445MB  8592MB  2147MB  logical                lvm 6      8593MB  10.7GB  2147MB  logical                lvm 7      10.7GB  12.9GB  2147MB  logical                lvm 8      12.9GB  15.0GB  2147MB  logical                lvm

**

创建PV

[root@aiker01 ~]# pvcreate /dev/sdb8  Physical volume "/dev/sdb8" successfully created.    **vg扩展**[root@aiker01 ~]# vgextend vg1 /dev/sdb8  Volume group "vg1" successfully extended
[root@aiker01 ~]# vgdisplay vg1  --- Volume group ---  VG Name               vg1  System ID               Format                lvm2  Metadata Areas        4  Metadata Sequence No  26  VG Access             read/write  VG Status             resizable  MAX LV                0  Cur LV                1  Open LV               1  Max PV                0  Cur PV                4  Act PV                4  VG Size               7.98 GiB  PE Size               4.00 MiB  Total PE              2044  Alloc PE / Size       1152 / 4.50 GiB  Free  PE / Size       892 / 3.48 GiB  VG UUID               dx3XD9-rQBV-QtBu-EebN-wgjI-CQcn-36iIbm

lv扩容

这里是比较简单的扩容,直接把新分区给加了进去

[root@aiker01 ~]# lvextend /dev/vg1/lv1 /dev/sdb8  Size of logical volume vg1/lv1 changed from 4.50 GiB (1152 extents) to <6.50 GiB (1663 extents).  Logical volume vg1/lv1 successfully resized.[root@aiker01 ~]# lvdisplay /dev/vg1/lv1  --- Logical volume ---  LV Path                /dev/vg1/lv1  LV Name                lv1  VG Name                vg1  LV UUID                q6dAzJ-1dbC-2EoY-Fzcp-QqEE-enuU-FS5BLT  LV Write Access        read/write  LV Creation host, time aiker01, 2017-12-06 03:02:40 +0800  LV Status              available  # open                 1  LV Size                <6.50 GiB  Current LE             1663  Segments               4  Allocation             inherit  Read ahead sectors     auto  - currently set to     8192  Block device           253:4

更新lv挂载卷前

[root@aiker01 ~]# df -hTFilesystem          Type      Size  Used Avail Use% Mounted on/dev/mapper/cl-root xfs       8.6G  5.3G  3.4G  62% /devtmpfs            devtmpfs  2.4G     0  2.4G   0% /devtmpfs               tmpfs     2.4G     0  2.4G   0% /dev/shmtmpfs               tmpfs     2.4G  8.7M  2.4G   1% /runtmpfs               tmpfs     2.4G     0  2.4G   0% /sys/fs/cgroup/dev/mapper/cl-home xfs       4.0G   33M  4.0G   1% /home/dev/mapper/cl-var  xfs       3.0G  159M  2.8G   6% /var/dev/sda2           xfs       497M  132M  366M  27% /boottmpfs               tmpfs     479M     0  479M   0% /run/user/0/dev/mapper/vg2-lv2 ext4      3.9G   16M  3.7G   1% /data/dev/mapper/vg1-lv1 ext4      4.4G   16M  4.2G   1% /mnt

更新lv挂载信息(这步很重要)

[root@aiker01 ~]# resize2fs /dev/mapper/vg1-lv1  #xfs文件系统不适用,xfs文件系统需要执行xfs_growfs /dev/vg1/lv1  xfs![](https://s1.51cto.com/images/blog/201712/08/f4977ad91fc0c475ced44d60e51dc25a.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)resize2fs 1.42.9 (28-Dec-2013)Filesystem at /dev/mapper/vg1-lv1 is mounted on /mnt; on-line resizing requiredold_desc_blocks = 1, new_desc_blocks = 1The filesystem on /dev/mapper/vg1-lv1 is now 1702912 blocks long.

更新后

[root@aiker01 ~]# df -hTFilesystem          Type      Size  Used Avail Use% Mounted on/dev/mapper/cl-root xfs       8.6G  5.3G  3.4G  62% /devtmpfs            devtmpfs  2.4G     0  2.4G   0% /devtmpfs               tmpfs     2.4G     0  2.4G   0% /dev/shmtmpfs               tmpfs     2.4G  8.7M  2.4G   1% /runtmpfs               tmpfs     2.4G     0  2.4G   0% /sys/fs/cgroup/dev/mapper/cl-home xfs       4.0G   33M  4.0G   1% /home/dev/mapper/cl-var  xfs       3.0G  159M  2.8G   6% /var/dev/sda2           xfs       497M  132M  366M  27% /boottmpfs               tmpfs     479M     0  479M   0% /run/user/0/dev/mapper/vg2-lv2 ext4      3.9G   16M  3.7G   1% /data/dev/mapper/vg1-lv1 ext4      6.4G   18M  6.1G   1% /mnt[root@aiker01 ~]# ll /mnt/total 36-rw-r--r-- 1 root root     9 Dec  7 02:26 1.txt-rw-r--r-- 1 root root     9 Dec  7 02:26 2.txtdrwxr-xr-x 2 root root  4096 Dec  7 02:34 6[root@aiker01 ~]# cat /mnt/1.txt 12345678

转载于:https://blog.51cto.com/m51cto/2048558

你可能感兴趣的文章
linux日志服务器
查看>>
<北京青年>--思考
查看>>
事务和锁
查看>>
Linux命令TOP TEN
查看>>
shell脚本清空日志文件
查看>>
How to Set the /3GB Startup Switch in Windows
查看>>
vSphere 5 主机网卡设计与配置
查看>>
登录shell和非登录shell
查看>>
笔记三
查看>>
加入域找不到网络路径
查看>>
ansible 中的变量vars和items
查看>>
IT好宽广!
查看>>
Android 内核源代码交叉编译
查看>>
python url采集
查看>>
深入浅出Java垃圾回收机制(一)
查看>>
Red Hat Linux、rhel和Fedora Core以及Centos区别与联系
查看>>
配置Apache、Php、Mysql
查看>>
Java基础---Java常量的应用(九)
查看>>
北大校长王恩哥送给毕业学生的十句话
查看>>
IDC简报:2012年全球六大最佳主机服务器提供商
查看>>