#2.在上面创建了两个分区sdb1和sdb2各500M。 $fdisk /dev/sdb Command (m forhelp): u Changing display/entry units to sectors
Command (m forhelp): m Command (m forhelp): u #建立两个主分区:p 分别500MB
Command (m forhelp): p Disk identifier: 0x91982288 Device Boot Start End Blocks Id System /dev/sdb1 2048 1026047 512000 83 Linux /dev/sdb2 1026048 2050047 512000 83 Linux
Command (m forhelp): w #写入操作 The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
$pvdisplay --- Physical volume --- PV Name /dev/sda2 VG Name vg_weiyigeek PV Size 19.51 GiB / not usable 3.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 4994 Free PE 0 Allocated PE 4994 PV UUID svdPF0-R72a-NU6n-qrZV-jUwP-cOEz-b9OXnm
"/dev/sdb1" is a new physical volume of "500.00 MiB" --- NEW Physical volume --- PV Name /dev/sdb1 VG Name #VG那一栏是所属的VG组,因为我们还没有划分VG组,所以这一栏也是空。 PV Size 500.00 MiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID M5biUE-eaM1-8U6X-gOpd-31iW-cgNC-m1sIG1
$vgdisplay vgdemo1 --- Volume group --- VG Name vgdemo1 System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 1 VG Access read/write VG Status resizable MAX LV 0 Cur LV 0 Open LV 0 Max PV 0 Cur PV 2 Act PV 2 VG Size 992.00 MiB #关键点:后面的LV分配大小不能藏此大小 PE Size 4.00 MiB #PE是卷组的最小储存单位默认是4MB,创建的时候我们也可以用-s参数来修改, #一旦卷组创建成功是没法再去修改PE大小的。 Total PE 248 Alloc PE / Size 0 / 0 Free PE / Size 248 / 992.00 MiB VG UUID AdWgG1-DkWu-3OrA-skAW-ad3i-n2V9-pTHYWF
$lvdisplay vgdemo1 #lvdisplay后跟卷组是查看这个卷组的详细信息,只输入lvdisplay是显示所有逻辑卷的详细信息 --- Logical volume --- LV Path /dev/vgdemo1/lv_disk1 LV Name lv_disk1 VG Name vgdemo1 LV UUID ohx66h-l1kU-qnTR-bZQH-eWb5-tVhS-3B03Rq LV Write Access read/write LV Creation host, time Master-data2, 2019-05-26 13:05:28 +0800 LV Status available # open 0 LV Size 200.00 MiB Current LE 50 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:2
$lvextend -L +100M /dev/vgdemo1/lv_disk1 #扩展lvs动态卷的大小 +100M是增加100M空间 Size of logical volume vgdemo1/lv_disk1 changed from 200.00 MiB (50 extents) to 300.00 MiB (75 extents). Logical volume lv_disk1 successfully resized.
#2.lvs卷扫描查看分配后的大小 $lvscan ACTIVE '/dev/vgdemo1/lv_disk1' [300.00 MiB] inherit ACTIVE '/dev/vg_weiyigeek/lv_root' [17.54 GiB] inherit ACTIVE '/dev/vg_weiyigeek/lv_swap' [1.97 GiB] inherit
#3.但这个时候我们用df-h命令查看一下发现挂载的文件系统并没有增大,这就需要我们使用resize2fs命令手动同步一下文件系统 #lvextend -L +100M /dev/vgdemo1/lv_disk1 -r #加上-r参数就此步可用忽略 $resize2fs -f /dev/vgdemo1/lv_disk1 resize2fs 1.41.12 (17-May-2010) Resizing the filesystem on /dev/vgdemo1/lv_disk1 to 307200 (1k) blocks. The filesystem on /dev/vgdemo1/lv_disk1 is now 307200 blocks long.
$df -h /lvsdisk #挂载完成并查看空间大小 Filesystem Size Used Avail Use% Mounted on /dev/mapper/vgdemo1-lv_disk1 287M 2.1M 270M 1% /lvsdisk
# 5) 查看UUID: $ blkid |grep web /dev/mapper/datastore-web_data: UUID="7a6e09bf-8fe7-4f66-86f6-5cdd82ffb380" TYPE="xfs"
# 6) 方式1.自动挂载 $ vim /etc/fstab # /etc/fstab # Created by anaconda on Thu Sep 22 17:50:17 2016 # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # 方式1 /dev/mapper/centos-root / xfs defaults 0 0 UUID=41f7a291-c7de-4694-a5ee-1e6313ff9f44 /boot xfs defaults 0 0 /dev/mapper/centos-swap swap swap defaults 0 0 UUID=7a6e09bf-8fe7-4f66-86f6-5cdd82ffb380 /data/web_data xfs defaults 0 0 # 方式2 # / was on /dev/ubuntu-vg/lv-0 during curtin installation /dev/disk/by-id/dm-uuid-LVM-cwiz8LJ0JAPp64DmkjU71YpKu235eWQv7GwryDiVe7e1Hvfg8yzYcFs53sWsHfFi / ext4 defaults 0 0
# 6) 方式2.手动创建挂载目录并挂载 [root@b ~]# mkdir -p /data/web_data [root@b ~]# mount /dev/mapper/datastore-web_data /data/web_data/ [root@b ~]# mount | grep web /dev/mapper/datastore-web_data on /data/web_data type xfs (rw,relatime,attr2,inode64,noquota)
$lvreduce -L 52M /dev/vgdemo1/lv_disk1 -r fsck from util-linux-ng 2.17.2 /dev/mapper/vgdemo1-lv_disk1: The filesystem size (according to the superblock) is 307200 blocks The physical size of the device is 258048 blocks Either the superblock or the partition table is likely to be corrupt! /dev/mapper/vgdemo1-lv_disk1: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY. (i.e., without -a or -p options)
$resize2fs -p -F /dev/mapper/ubuntu--vg-ubuntu--lv resize2fs 1.45.5 (07-Jan-2020) Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required old_desc_blocks = 1, new_desc_blocks = 25 The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 52164608 (4k) blocks long.
方式1.请访问本博主的B站【WeiyiGeek】首页关注UP主, 将自动随机获取解锁验证码。
Method 2.Please visit 【My Twitter】. There is an article verification code in the homepage.
方式3.扫一扫下方二维码,关注本站官方公众号
回复:验证码
将获取解锁(有效期7天)本站所有技术文章哟!