===================
==========
========
- # 查看本机上包含sd的磁盘
- root@longchi:~# ls /dev/sd*
- /dev/sda /dev/sda1 /dev/sda2 /dev/sda3 /dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/sdf /dev/sdg /dev/sdh /dev/sdi
-
- # 安装 lvm2 的命令: apt install lvm2
- root@longchi:~# pvcreate /dev/sdf /dev/sdg
- Command 'pvcreate' not found, but can be installed with:
- apt install lvm2
- root@longchi:~# apt install lvm2
- Reading package lists... Done
- Building dependency tree... Done
- Reading state information... Done
- The following package was automatically installed and is no longer required:
- crda
- Use 'apt autoremove' to remove it.
- The following additional packages will be installed:
- dmeventd libaio1 libdevmapper-event1.02.1 liblvm2cmd2.03 thin-provisioning-tools
- The following NEW packages will be installed:
- dmeventd libaio1 libdevmapper-event1.02.1 liblvm2cmd2.03 lvm2 thin-provisioning-tools
- 0 upgraded, 6 newly installed, 0 to remove and 29 not upgraded.
- Need to get 2395 kB of archives.
- After this operation, 8959 kB of additional disk space will be used.
- Do you want to continue? [Y/n] y
- Get:1 http://us.archive.ubuntu.com/ubuntu jammy/main amd64 libaio1 amd64 0.3.112-13build1 [7176 B]
- Get:2 http://us.archive.ubuntu.com/ubuntu jammy/main amd64 libdevmapper-event1.02.1 amd64 2:1.02.175-2.1ubuntu4 [12.6 kB]
- Get:3 http://us.archive.ubuntu.com/ubuntu jammy/main amd64 liblvm2cmd2.03 amd64 2.03.11-2.1ubuntu4 [756 kB]
- Get:4 http://us.archive.ubuntu.com/ubuntu jammy/main amd64 dmeventd amd64 2:1.02.175-2.1ubuntu4 [38.4 kB]
- Get:5 http://us.archive.ubuntu.com/ubuntu jammy/main amd64 lvm2 amd64 2.03.11-2.1ubuntu4 [1154 kB]
- Get:6 http://us.archive.ubuntu.com/ubuntu jammy/main amd64 thin-provisioning-tools amd64 0.9.0-2ubuntu1 [426 kB]
- Fetched 2395 kB in 4s (660 kB/s)
- Selecting previously unselected package libaio1:amd64.
- (Reading database ... 222217 files and directories currently installed.)
- Preparing to unpack .../0-libaio1_0.3.112-13build1_amd64.deb ...
-
- Progress: [ 0%] [........................................................................................................]
- Unpacking libaio1:amd64 (0.3.112-13build1) ...............................................................................]
-
- Selecting previously unselected package libdevmapper-event1.02.1:amd64....................................................]
- Preparing to unpack .../1-libdevmapper-event1.02.1_2%3a1.02.175-2.1ubuntu4_amd64.deb ...
-
- Unpacking libdevmapper-event1.02.1:amd64 (2:1.02.175-2.1ubuntu4) .........................................................]
-
- Selecting previously unselected package liblvm2cmd2.03:amd64..............................................................]
- Preparing to unpack .../2-liblvm2cmd2.03_2.03.11-2.1ubuntu4_amd64.deb ...
-
- Unpacking liblvm2cmd2.03:amd64 (2.03.11-2.1ubuntu4) ......................................................................]
-
- Selecting previously unselected package dmeventd..........................................................................]
- Preparing to unpack .../3-dmeventd_2%3a1.02.175-2.1ubuntu4_amd64.deb ...
-
- Unpacking dmeventd (2:1.02.175-2.1ubuntu4) ...#...........................................................................]
-
- Selecting previously unselected package lvm2.######.......................................................................]
- Preparing to unpack .../4-lvm2_2.03.11-2.1ubuntu4_amd64.deb ...
-
- Unpacking lvm2 (2.03.11-2.1ubuntu4) ...################...................................................................]
-
- Selecting previously unselected package thin-provisioning-tools...........................................................]
- Preparing to unpack .../5-thin-provisioning-tools_0.9.0-2ubuntu1_amd64.deb ...
-
- Unpacking thin-provisioning-tools (0.9.0-2ubuntu1) ...#########...........................................................]
-
- Setting up libdevmapper-event1.02.1:amd64 (2:1.02.175-2.1ubuntu4) ........................................................]
-
- Progress: [ 52%] [######################################################..................................................]
- Setting up libaio1:amd64 (0.3.112-13build1) ...#############################..............................................]
-
- Progress: [ 60%] [##############################################################..........................................]
- Setting up thin-provisioning-tools (0.9.0-2ubuntu1) ...#############################......................................]
-
- Progress: [ 68%] [######################################################################..................................]
- Setting up liblvm2cmd2.03:amd64 (2.03.11-2.1ubuntu4) ...####################################..............................]
-
- Progress: [ 76%] [###############################################################################.........................]
- Setting up dmeventd (2:1.02.175-2.1ubuntu4) ...######################################################.....................]
-
- Created symlink /etc/systemd/system/sockets.target.wants/dm-event.socket → /lib/systemd/system/dm-event.socket............]
- dm-event.service is a disabled or a static unit, not starting it.
-
- Setting up lvm2 (2.03.11-2.1ubuntu4) ...#####################################################################.............]
-
- update-initramfs: deferring update (trigger activated)###########################################################.........]
- Created symlink /etc/systemd/system/sysinit.target.wants/blk-availability.service → /lib/systemd/system/blk-availability.service.
- Created symlink /etc/systemd/system/sysinit.target.wants/lvm2-monitor.service → /lib/systemd/system/lvm2-monitor.service.
- Created symlink /etc/systemd/system/sysinit.target.wants/lvm2-lvmpolld.socket → /lib/systemd/system/lvm2-lvmpolld.socket.
-
- Processing triggers for initramfs-tools (0.140ubuntu13.4) ...########################################################.....]
- update-initramfs: Generating /boot/initrd.img-6.5.0-18-generic
- Processing triggers for libc-bin (2.35-0ubuntu3.6) ...
- Processing triggers for man-db (2.10.2-1) ...
- root@longchi:~#
-
- # 创建 PV 物理卷
- root@longchi:~# pvcreate /dev/sdf /dev/sdg
- Physical volume "/dev/sdf" successfully created.
- Physical volume "/dev/sdg" successfully created.
- root@longchi:~#
-
- # 创建 VG 逻辑卷组
- root@longchi:~# vgcreate longchivg1 /dev/sdf /dev/sdg
- Volume group "longchivg1" successfully created
- # 扫描一下 pv
- root@longchi:~# pvs
- PV VG Fmt Attr PSize PFree
- /dev/sdf longchivg1 lvm2 a-- <50.00g <50.00g
- /dev/sdg longchivg1 lvm2 a-- <50.00g <50.00g
- # 扫描一下详细信息 pv
- root@longchi:~# pvscan
- PV /dev/sdf VG longchivg1 lvm2 [<50.00 GiB / <50.00 GiB free]
- PV /dev/sdg VG longchivg1 lvm2 [<50.00 GiB / <50.00 GiB free]
- Total: 2 [99.99 GiB] / in use: 2 [99.99 GiB] / in no VG: 0 [0 ]
- # 扫描一下 vg
- root@longchi:~# vgs
- VG #PV #LV #SN Attr VSize VFree
- longchivg1 2 0 0 wz--n- 99.99g 99.99g
- # 扫描一下详细信息 vg
- root@longchi:~# vgscan
- Found volume group "longchivg1" using metadata type lvm2
- # 显示 PV 的详细信息
- root@longchi:~# pvdisplay
- --- Physical volume ---
- PV Name /dev/sdf
- VG Name longchivg1
- PV Size 50.00 GiB / not usable 4.00 MiB
- Allocatable yes
- PE Size 4.00 MiB
- Total PE 12799
- Free PE 12799
- Allocated PE 0
- PV UUID elO3gs-Wp6T-16vO-813s-0RuF-zOUK-UO2wpL
-
- --- Physical volume ---
- PV Name /dev/sdg
- VG Name longchivg1
- PV Size 50.00 GiB / not usable 4.00 MiB
- Allocatable yes
- PE Size 4.00 MiB
- Total PE 12799
- Free PE 12799
- Allocated PE 0
- PV UUID Hi2Fdu-OP7S-nZKD-Yq0v-DBDC-ofxf-NCXBXf
-
- root@longchi:~#
-
- # 显示 VG 详细信息
- root@longchi:~# vgdisplay
- --- Volume group ---
- VG Name longchivg1
- 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 99.99 GiB
- PE Size 4.00 MiB
- Total PE 25598
- Alloc PE / Size 0 / 0
- Free PE / Size 25598 / 99.99 GiB
- VG UUID c390Ia-swcr-7mmr-E93R-DMct-ycQ1-ra7CQf
-
- # 创建 PV 物理卷
- root@longchi:~# pvcreate /dev/sdh
- Physical volume "/dev/sdh" successfully created.
- root@longchi:~# pvs
- PV VG Fmt Attr PSize PFree
- /dev/sdf longchivg1 lvm2 a-- <50.00g <50.00g
- /dev/sdg longchivg1 lvm2 a-- <50.00g <50.00g
- /dev/sdh lvm2 --- 50.00g 50.00g
- # 扩容,将 /dev/sdh 添加到 longchivg1 逻辑卷组中
- root@longchi:~# vgextend longchivg1 /dev/sdh
- Volume group "longchivg1" successfully extended
-
- # 显示一下卷组的信息,容量等 命令 vgdisplay
- root@longchi:~# vgdisplay
- --- Volume group ---
- VG Name longchivg1
- System ID
- Format lvm2
- Metadata Areas 3
- Metadata Sequence No 2
- VG Access read/write
- VG Status resizable
- MAX LV 0
- Cur LV 0
- Open LV 0
- Max PV 0
- Cur PV 3
- Act PV 3
- VG Size <149.99 GiB
- PE Size 4.00 MiB
- Total PE 38397
- Alloc PE / Size 0 / 0
- Free PE / Size 38397 / <149.99 GiB
- VG UUID c390Ia-swcr-7mmr-E93R-DMct-ycQ1-ra7CQf
-
- # 还可以缩小卷组的大小,剔除 /dev/sdh 命令 vgreduce longchivg1 /dev/sdh
- root@longchi:~# vgreduce longchivg1 /dev/sdh
- Removed "/dev/sdh" from volume group "longchivg1"
- # 删除 /dev/sdh 的物理卷 命令 pvremove /dev/sdh
- root@longchi:~# pvremove /dev/sdh
- Labels on physical volume "/dev/sdh" successfully wiped.
- # 显示一下物理卷信息 pvs
- root@longchi:~# pvs
- PV VG Fmt Attr PSize PFree
- /dev/sdf longchivg1 lvm2 a-- <50.00g <50.00g
- /dev/sdg longchivg1 lvm2 a-- <50.00g <50.00g
- # 使用此时的卷组,创建逻辑卷 LV,进行使用 /dev/sdf /dev/sdg
- # 查看一下此时的 VG 逻辑卷组 命令 vgs vgdisplay
- root@longchi:~# vgs
- VG #PV #LV #SN Attr VSize VFree
- longchivg1 2 0 0 wz--n- 99.99g 99.99g
- root@longchi:~# vgdisplay
- --- Volume group ---
- VG Name longchivg1
- System ID
- Format lvm2
- Metadata Areas 2
- Metadata Sequence No 3
- 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 99.99 GiB
- PE Size 4.00 MiB
- Total PE 25598
- Alloc PE / Size 0 / 0
- Free PE / Size 25598 / 99.99 GiB
- VG UUID c390Ia-swcr-7mmr-E93R-DMct-ycQ1-ra7CQf
- # 使用此时的卷组(longchivg1),创建逻辑卷 lv1,进行使用 /dev/sdf /dev/sdg
- root@longchi:~# lvcreate -n lv1 -L +2000M longchivg1
- Logical volume "lv1" created.
- root@longchi:~#
- # 查看 LV 逻辑卷
- root@longchi:~# lvs
- LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
- lv1 longchivg1 -wi-a----- 1.95g
- root@longchi:~# lvdisplay
- --- Logical volume ---
- LV Path /dev/longchivg1/lv1
- LV Name lv1
- VG Name longchivg1
- LV UUID ybbxnA-Xq66-vjhX-CKUb-mJFu-e0jX-2l0pkW
- LV Write Access read/write
- LV Creation host, time longchi, 2024-02-22 23:22:01 -0800
- LV Status available
- # open 0
- LV Size 1.95 GiB
- Current LE 500
- Segments 1
- Allocation inherit
- Read ahead sectors auto
- - currently set to 256
- Block device 252:0
- # 对刚创建的 lv1 逻辑卷进行格式化文件系统
- root@longchi:~# mkfs.ext4 /dev/longchivg1/lv1
- mke2fs 1.46.5 (30-Dec-2021)
- Creating filesystem with 512000 4k blocks and 128000 inodes
- Filesystem UUID: d20c97ba-258d-47a4-a94c-890c314650f4
- Superblock backups stored on blocks:
- 32768, 98304, 163840, 229376, 294912
-
- Allocating group tables: done
- Writing inode tables: done
- Creating journal (8192 blocks): done
- Writing superblocks and filesystem accounting information: done
-
- root@longchi:~# lsblk -f | grep sd
- sda
- |-sda1
- |-sda2 vfat FAT32 FEB1-E722 505.9M 1% /boot/efi
- `-sda3 ext4 1d8e3f92-eeaf-4cde-a566-1c7eea428509 81.5G /var/snap/firefox/common/host-hunspell
- sdb linux_raid_member 1.2 longchi:0 e79936a0-022f-080e-fcfc-7e5ff2114b46
- sdc linux_raid_member 1.2 longchi:0 e79936a0-022f-080e-fcfc-7e5ff2114b46
- sdd linux_raid_member 1.2 longchi:0 e79936a0-022f-080e-fcfc-7e5ff2114b46
- sde linux_raid_member 1.2 longchi:0 e79936a0-022f-080e-fcfc-7e5ff2114b46
- sdf LVM2_member LVM2 001 elO3gs-Wp6T-16vO-813s-0RuF-zOUK-UO2wpL
- sdg LVM2_member LVM2 001 Hi2Fdu-OP7S-nZKD-Yq0v-DBDC-ofxf-NCXBXf
- sdh
- sdi
- # 向磁盘中写入数据,查看空间容量
-
- # 向 lv1 逻辑卷中,进行挂载,以及数据写入 (就可以当一个普通分区来使用了)
- root@longchi:~# mkdir /longchi_lv1
- root@longchi:~# mount /dev/longchivg1/lv1 /longchi_lv1
- root@longchi:~#
- # 查看所有的挂载信息
- root@longchi:~# df -hT
- Filesystem Type Size Used Avail Use% Mounted on
- tmpfs tmpfs 790M 1.9M 788M 1% /run
- /dev/sda3 ext4 98G 11G 82G 12% /
- tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm
- tmpfs tmpfs 5.0M 4.0K 5.0M 1% /run/lock
- /dev/sda2 vfat 512M 6.1M 506M 2% /boot/efi
- tmpfs tmpfs 790M 72K 790M 1% /run/user/126
- /dev/mapper/longchivg1-lv1 ext4 1.9G 24K 1.8G 1% /longchi_lv1
- # 向磁盘中写入数据,查看空间容量
- root@longchi:~# echo {1..10000000} > /longchi_lv1/test.txt
- root@longchi:~# df -hT
- Filesystem Type Size Used Avail Use% Mounted on
- tmpfs tmpfs 790M 1.9M 788M 1% /run
- /dev/sda3 ext4 98G 11G 82G 12% /
- tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm
- tmpfs tmpfs 5.0M 4.0K 5.0M 1% /run/lock
- /dev/sda2 vfat 512M 6.1M 506M 2% /boot/efi
- tmpfs tmpfs 790M 72K 790M 1% /run/user/126
- /dev/mapper/longchivg1-lv1 ext4 1.9G 76M 1.7G 5% /longchi_lv1
- root@longchi:~# cd /longchi_lv1
- root@longchi:/longchi_lv1# ls
- lost+found test.txt
- root@longchi:/longchi_lv1# cp test.txt test.txt.1
- root@longchi:/longchi_lv1# cp test.txt test.txt.2
- root@longchi:/longchi_lv1# cp test.txt test.txt.3
- root@longchi:/longchi_lv1#
- root@longchi:/longchi_lv1# df -hT
- 文件系统 类型 容量 已用 可用 已用% 挂载点
- Filesystem Type Size Used Avail Use% Mounted on
- tmpfs tmpfs 790M 1.9M 788M 1% /run
- /dev/sda3 ext4 98G 11G 82G 12% /
- tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm
- tmpfs tmpfs 5.0M 4.0K 5.0M 1% /run/lock
- /dev/sda2 vfat 512M 6.1M 506M 2% /boot/efi
- tmpfs tmpfs 790M 72K 790M 1% /run/user/126
- /dev/mapper/longchivg1-lv1 ext4 1.9G 301M 1.5G 17% /longchi_lv1
- root@longchi:/longchi_lv1# cd # 退出 /longchi_lv1/ 目录
- root@longchi:~# umount /longchi_lv1/ # 取消挂载
- root@longchi:~# ls /longchi_lv1/
- root@longchi:~#
-
- # 取消挂载后,已经看不到 /longchi_lv1/ 挂载信息
- root@longchi:~# df -hT
- Filesystem Type Size Used Avail Use% Mounted on
- tmpfs tmpfs 790M 1.9M 788M 1% /run
- /dev/sda3 ext4 98G 11G 82G 12% /
- tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm
- tmpfs tmpfs 5.0M 4.0K 5.0M 1% /run/lock
- /dev/sda2 vfat 512M 6.1M 506M 2% /boot/efi
- tmpfs tmpfs 790M 72K 790M 1% /run/user/126
- root@longchi:~#
- # 向 /etc/fstab 文件中写入 开机自动挂载 命令
- echo "/dev/longchivg1/lv1 /longchi_lv1 ext4 defaults 0 0" >> /etc/fstab
- # 将挂载信息,写入开机自动挂载文件(/etc/fstab)中,以后就不需要每次都 mount 了
- root@longchi:~# vim /etc/fstab
- root@longchi:~# tail -1 /etc/fstab
- /dev/longchivg1/lv1 /longchi_lv1 ext4 defaults 0 0
- root@longchi:~#
- root@longchi:~# mount -l | grep lv1
-
- # 'mount -a'去执行 /etc/fstab 文件中所有的挂载信息 读取 /etc/fstab 文件中所有挂载信息
- root@longchi:~# mount -a
- root@longchi:~# mount -l | grep lv1
- /dev/mapper/longchivg1-lv1 on /longchi_lv1 type ext4 (rw,relatime)
- root@longchi:~#
- # 将挂载信息,写入开机自动挂载文件(/etc/fstab)中,以后就不需要每次都 mount 了
-
- root@longchi:~# tail -1 /etc/fstab
-
- /dev/longchivg1/lv1 /longchi_lv1 ext4 defaults 0 0
-
- # 通过命令,直接读取 /etc/fstab ,自动挂载所有设备
-
- root@longchi:~# mount -l | grep lv1
- /dev/mapper/longchivg1-lv1 on /longchi_lv1 type ext4 (rw,relatime)
- # 通过 mount 数据又回来了
-
- root@longchi:~# ls /longchi_lv1/
- lost+found test.txt test.txt.1 test.txt.2 test.txt.3
-
- # 向磁盘中写入数据,查看空间容量
- root@longchi:~# df -hT
- Filesystem Type Size Used Avail Use% Mounted on
- tmpfs tmpfs 790M 1.9M 788M 1% /run
- /dev/sda3 ext4 98G 11G 82G 12% /
- tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm
- tmpfs tmpfs 5.0M 4.0K 5.0M 1% /run/lock
- /dev/sda2 vfat 512M 6.1M 506M 2% /boot/efi
- tmpfs tmpfs 790M 72K 790M 1% /run/user/126
- /dev/mapper/longchivg1-lv1 ext4 1.9G 301M 1.5G 17% /longchi_lv1
- root@longchi:~#
-
- # 针对 lv 逻辑卷的扩容操作,只要卷组中的容量够用,就可以对 lv 逻辑卷扩容
- root@longchi:~# vgdisplay
- --- Volume group ---
- VG Name longchivg1
- System ID
- Format lvm2
- Metadata Areas 2
- 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 2
- Act PV 2
- VG Size 99.99 GiB
- PE Size 4.00 MiB
- Total PE 25598
- Alloc PE / Size 500 / 1.95 GiB
- Free PE / Size 25098 / <98.04 GiB
- VG UUID c390Ia-swcr-7mmr-E93R-DMct-ycQ1-ra7CQf
root@longchi:~# umount /longchi_lv1/
- root@longchi:~# lvextend -L +10G /dev/longchivg1/lv1
- Size of logical volume longchivg1/lv1 changed from 1.95 GiB (500 extents) to 11.95 GiB (3060 extents).
- Logical volume longchivg1/lv1 successfully resized.
- root@longchi:~#
- root@longchi:~# df -hT
- Filesystem Type Size Used Avail Use% Mounted on
- tmpfs tmpfs 790M 1.9M 788M 1% /run
- /dev/sda3 ext4 98G 11G 82G 12% /
- tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm
- tmpfs tmpfs 5.0M 4.0K 5.0M 1% /run/lock
- /dev/sda2 vfat 512M 6.1M 506M 2% /boot/efi
- tmpfs tmpfs 790M 72K 790M 1% /run/user/126
- /dev/mapper/longchivg1-lv1 ext4 1.9G 301M 1.5G 17% /longchi_lv1
- # 刷新命令 (centos7 文件系统为 xfs) 只有刷新了,'df -hT'命令才能读取到扩容后 逻辑卷的大小
- root@longchi:~# xfs_growfs /dev/mapper/longchivg1-lv1 # 刷新命令
- # 刷新命令 (ubuntu 文件系统为 ext4) 只有刷新了,'df -hT'命令才能读取到扩容后 逻辑卷的大小
- root@longchi:~# resize2fs /dev/mapper/longchivg1-lv1 # 刷新命令
- resize2fs 1.46.5 (30-Dec-2021)
- Filesystem at /dev/mapper/longchivg1-lv1 is mounted on /longchi_lv1; on-line resizing required
- old_desc_blocks = 1, new_desc_blocks = 2
- The filesystem on /dev/mapper/longchivg1-lv1 is now 3133440 (4k) blocks long.
-
- root@longchi:~# df -hT
- Filesystem Type Size Used Avail Use% Mounted on
- tmpfs tmpfs 790M 1.9M 788M 1% /run
- /dev/sda3 ext4 98G 11G 82G 12% /
- tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm
- tmpfs tmpfs 5.0M 4.0K 5.0M 1% /run/lock
- /dev/sda2 vfat 512M 6.1M 506M 2% /boot/efi
- tmpfs tmpfs 790M 72K 790M 1% /run/user/126
- /dev/mapper/longchivg1-lv1 ext4 12G 301M 11G 3% /longchi_lv1
- root@longchi:~#
root@longchi:~# mount /dev/longchivg1/lv1 /longchi_lv1/
- root@longchi:~# lvdisplay
- --- Logical volume ---
- LV Path /dev/longchivg1/lv1
- LV Name lv1
- VG Name longchivg1
- LV UUID ybbxnA-Xq66-vjhX-CKUb-mJFu-e0jX-2l0pkW
- LV Write Access read/write
- LV Creation host, time longchi, 2024-02-22 23:22:01 -0800
- LV Status available
- # open 0
- LV Size 11.95 GiB
- Current LE 3060
- Segments 1
- Allocation inherit
- Read ahead sectors auto
- - currently set to 256
- Block device 252:0
-
- root@longchi:~# df -hT
- Filesystem Type Size Used Avail Use% Mounted on
- tmpfs tmpfs 790M 1.9M 788M 1% /run
- /dev/sda3 ext4 98G 11G 82G 12% /
- tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm
- tmpfs tmpfs 5.0M 4.0K 5.0M 1% /run/lock
- /dev/sda2 vfat 512M 6.1M 506M 2% /boot/efi
- tmpfs tmpfs 790M 72K 790M 1% /run/user/126
- /dev/mapper/longchivg1-lv1 ext4 1.9G 301M 1.5G 17% /longchi_lv1
-
- # 刷新命令 (ubuntu 文件系统为 ext4) 只有刷新了,'df -hT'命令才能读取到扩容后 逻辑卷的大小
- # 调整 ext4 文件系统
- root@longchi:~# resize2fs /dev/mapper/longchivg1-lv1
- resize2fs 1.46.5 (30-Dec-2021)
- Filesystem at /dev/mapper/longchivg1-lv1 is mounted on /longchi_lv1; on-line resizing required
- old_desc_blocks = 1, new_desc_blocks = 2
- The filesystem on /dev/mapper/longchivg1-lv1 is now 3133440 (4k) blocks long.
-
- root@longchi:~# df -hT # 查看 lv1 是否正确调整了空间容量
- Filesystem Type Size Used Avail Use% Mounted on
- tmpfs tmpfs 790M 1.9M 788M 1% /run
- /dev/sda3 ext4 98G 11G 82G 12% /
- tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm
- tmpfs tmpfs 5.0M 4.0K 5.0M 1% /run/lock
- /dev/sda2 vfat 512M 6.1M 506M 2% /boot/efi
- tmpfs tmpfs 790M 72K 790M 1% /run/user/126
- /dev/mapper/longchivg1-lv1 ext4 12G 301M 11G 3% /longchi_lv1
- root@longchi:~#
- # 查看 /longchi_lv1 挂载目录数据
- root@longchi:~# ls /longchi_lv1
- lost+found test.txt test.txt.1 test.txt.2 test.txt.3
- # 取消挂载
- root@longchi:~# umount /longchi_lv1
- # 取消挂载后,再次查看 /longchi_lv1 挂载目录数据,已经看不到数据了
- root@longchi:~# ls /longchi_lv1
- root@longchi:~#
- root@longchi:~# lvremove /dev/longchivg1/lv1
- Do you really want to remove and DISCARD active logical volume longchivg1/lv1? [y/n]: y
- Logical volume "lv1" successfully removed
- root@longchi:~#
- root@longchi:~# vgremove longchivg1
- Volume group "longchivg1" successfully removed
- root@longchi:~#
- # 扫描一下有哪些物理卷设备
- root@longchi:~# pvs
- PV VG Fmt Attr PSize PFree
- /dev/sdf lvm2 --- 50.00g 50.00g
- /dev/sdg lvm2 --- 50.00g 50.00g
- root@longchi:~#
- # 删除物理卷设备 /dev/sdf /dev/sdg
- root@longchi:~# pvremove /dev/sdf /dev/sdg
- Labels on physical volume "/dev/sdf" successfully wiped.
- Labels on physical volume "/dev/sdg" successfully wiped.
- root@longchi:~#
- # 扫描 PV
- root@longchi:~# pvs
- root@longchi:~# pvdisplay
- root@longchi:~# pvscan
- No matching physical volumes found
- root@longchi:~#
-
- # 扫描 VG
- root@longchi:~# vgs
- root@longchi:~# vgdisplay
- root@longchi:~# vgscan
- root@longchi:~#
-
- # 扫描 LV
- root@longchi:~# lvs
- root@longchi:~# lvdisplay
- root@longchi:~# lvscan
- root@longchi:~#
总结,以上检查 lvm 相关信息 pvs vgs lvs 均没有相关信息,表示 lvm 彻底被删除了