今天线上磁盘满了,一开始没有做lvm,最后还是坑的自己,下面是自己测试过程
1、挂载两个数据盘
/dev/sdb /dev/sdc
2、创建基于分区的LV
1、 通过fdisk创建分区 可参考如下: #两块磁盘信息 fdisk /dev/sdc n p 1 t 8e w
3、创建基于分区的物理卷 pvcreate
pvcreate /dev/sdb
pvcreate /dev/sdc
[root@master-node ~]# pvcreate /dev/sdb Physical volume "/dev/sdb" successfully created [root@master-node ~]# pvcreate /dev/sdc Physical volume "/dev/sdc" successfully created [root@master-node ~]#
4、 创建卷组:
soft 卷组名称
vgcreate soft /dev/sdb1
[root@master-node ~]# vgcreate soft /dev/sdb1 Volume group "soft" successfully created
4.1 将新的物理卷添加到现有卷组
vgextend soft /dev/sdc1
vgextend soft /dev/sdb2
4.2 从卷组中删除物理卷
[root@master-node ~]# vgreduce soft /dev/sdc1 Removed "/dev/sdc1" from volume group "soft"
5、 创建LV
Total PE 5119 == 100%FREE 全部大写 卷组名称 lvm命令 lvcreate -l 100%FREE soft -n soft01 -L200M 指定大写 lvcreate -L200M soft -n soft01
6、创建文件系统
[root@master-node ~]# mkfs.ext4 /dev/soft/soft01 mke2fs 1.42.13 (17-May-2015) Creating filesystem with 5241856 4k blocks and 1310720 inodes Filesystem UUID: bce3312b-5a41-4d12-b4a7-62d440cce327 Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
7、挂载文件系统
[root@master-node ~]# mkdir /soft [root@master-node ~]# mount /dev/soft/soft01 /soft/ [root@master-node ~]# df -h Filesystem Size Used Avail Use% Mounted on udev 468M 0 468M 0% /dev tmpfs 98M 4.6M 93M 5% /run /dev/mapper/ubuntu--vg-root 19G 2.4G 15G 14% / tmpfs 488M 0 488M 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 488M 0 488M 0% /sys/fs/cgroup /dev/sda1 472M 58M 391M 13% /boot tmpfs 98M 0 98M 0% /run/user/1000 /dev/mapper/soft-soft01 20G 44M 19G 1% /soft [root@master-node ~]#
8、 扩lv
pvcreate /dev/sdc1 [root@master-node ~]# vgextend soft /dev/sdc1 Volume group "soft" successfully extended [root@master-node ~]# vgdisplay soft --- Volume group --- VG Name soft System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 5 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 2 Act PV 2 VG Size 39.99 GiB PE Size 4.00 MiB Total PE 10238 Alloc PE / Size 5119 / 20.00 GiB Free PE / Size 5119 / 20.00 GiB VG UUID zb5xiT-bM5p-y37X-acNs-Su1Z-WweZ-u5iaM6 写法一: 在现有的空间中添加500M [root@master-node ~]# lvextend -L+2G /dev/soft/soft01 Size of logical volume soft/soft01 changed from 20.00 GiB (5119 extents) to 22.00 GiB (5631 extents). Logical volume soft01 successfully resized. 扩容文件系统 [root@master-node ~]# resize2fs /dev/soft/soft01 resize2fs 1.42.13 (17-May-2015) Filesystem at /dev/soft/soft01 is mounted on /soft; on-line resizing required old_desc_blocks = 2, new_desc_blocks = 2 The filesystem on /dev/soft/soft01 is now 5766144 (4k) blocks long. [root@master-node ~]# df -h Filesystem Size Used Avail Use% Mounted on udev 468M 0 468M 0% /dev tmpfs 98M 4.6M 93M 5% /run /dev/mapper/ubuntu--vg-root 19G 2.4G 15G 14% / tmpfs 488M 0 488M 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 488M 0 488M 0% /sys/fs/cgroup /dev/sda1 472M 58M 391M 13% /boot tmpfs 98M 0 98M 0% /run/user/1000 /dev/mapper/soft-soft01 22G 44M 21G 1% /soft
原文:https://www.cnblogs.com/zhaojingyu/p/11647706.html