linux逻辑卷管理(LVM)
1. 逻辑卷(LVM)的原理
LVM(Logical Volume Manager)逻辑卷管理 是在物理磁盘和文件系统的之间添加一个逻辑层,通过对底层物理磁盘的封装,以逻辑卷的方式呈现给上层应用,通过对逻辑卷的操作来管理底层物理磁盘
2. LVM 中的基本术语
物理存储介质(The physical media): 可以使整个磁盘、磁盘分区、RAID阵列、SAN磁盘,这些设备必须初始化为LVM物理卷,才可以与LVM 结合使用
物理卷PV(Physical Volume):LVM基本的存储逻辑块,包含了物理介质没有的LVM相关的管理参数
卷组VG(Volume Group):由一个或多个PV组成
逻辑卷LV(Logical Volume):LV是建立在VG上,VG可以把部分磁盘空间给LV,也可以把全部的磁盘空间给LV,可以在LV上创建文件系统
PE(Physical extent):PV可以分配的最小存储单位
LE(Logical extent):LV中可以分配的最小存储单位,在同一个卷组中,LE与PE大小相同
lvm常用的命令 功能 PV管理命令 VG管理命令 LV管理命令 scan 扫描 pvscan vgscan lvscan create 创建 pvcreate vgcreate lvcreate display显示 pvdisplay vgdisplay lvdisplay remove 移除 pvremove vgremove lvremove extend 扩展 vgextend lvextend reduce减少 vgreduce lvreduce
查看卷名 简单对应卷信息的查看 扫描相关的所有的对应卷 详细对应卷信息的查看 物理卷 pvs pvscan pvdisplay 卷组 vgs vgscan vgdisplay 逻辑卷 lvs lvscan lvdisplay
3.LVM的优点
1.使用VG对多个物理磁盘空间进行整合,变成一个大磁盘
2.使用LVM可以跨越多个磁盘分区,动态的调整逻辑卷的大小,扩容、缩减、删除
3.可以调整基于LVM上创建的文件系统的大小
4.可以创建快照,来备份文件系统
4.创建LVM
步骤:
创建PV——>创建VG——>创建LV——>格式化LV成文件系统——>挂载LV
先通过fdisk切割出磁盘分区
查看系统上的磁盘[root@test01 Desktop]# 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 14.7G 0 part │ └─rhel-rootlv 253:0 0 14.7G 0 lvm / ├─sda3 8:3 0 2G 0 part [SWAP] ├─sda4 8:4 0 1K 0 part └─sda5 8:5 0 300M 0 part ==>这是我新建的一个分区
创建PV:
创建PV:[root@test01 Desktop]# pvcreate /dev/sda5 Physical volume "/dev/sda5" successfully created扫描PV [root@test01 Desktop]# pvscanPV /dev/sda2 VG rhel lvm2 [14.64 GiB / 0 free]PV /dev/sda5 lvm2 [300.00 MiB]显示PV的详细信息,后面不接PV名,会显示所有的PV信息 [root@test01 Desktop]# pvdisplay /dev/sda5"/dev/sda5" is a new physical volume of "300.00 MiB"--- NEW Physical volume ---PV Name /dev/sda5VG Name PV Size 300.00 MiBAllocatable NOPE Size 0 Total PE 0Free PE 0Allocated PE 0PV UUID YQbqqb-V3Wl-ot8s-SUR5-rsQL-oqdw-7fdzHa
创建VG:
创建VG[root@test01 Desktop]# vgcreate -s 16m testvg /dev/sda5Volume group "testvg" successfully created-s:是为了指定VG的PE的大小为16m,testvg是VG的名字,/dev/sda5是成为PV的磁盘分区设备名,多个磁盘可以写成/dev/sda{5,6,7}; 扫描VG [root@test01 Desktop]# vgscan Reading all physical volumes. This may take a while...Found volume group "rhel" using metadata type lvm2Found volume group "testvg" using metadata type lvm2 显示VG的详细信息,若后面不接VG名,会显示系统上所有VG的信息 [root@test01 Desktop]# vgdisplay testvg--- Volume group ---VG Name testvgSystem ID Format lvm2Metadata Areas 1Metadata Sequence No 1VG Access read/writeVG Status resizableMAX LV 0Cur LV 0Open LV 0Max PV 0Cur PV 1Act PV 1VG Size 288.00 MiBPE Size 16.00 MiB ==>PE大小:16mTotal PE 18Alloc PE / Size 0 / 0 Free PE / Size 18 / 288.00 MiBVG UUID eaUhl0-LvkR-Ebou-BXHa-ZnIb-DEza-qFZYbO
创建LV:
创建LV:方法一:-L:指定LV的大小为200M,-n:指定LV的名字为testlv ,最后指定的VG的名字[root@test01 Desktop]# lvcreate -L 200M -n testlv testvgRounding up size to full physical extent 208.00 MiBLogical volume "testlv" created 方法二:-l(小写的L):通过指定PE的个数来指定LV的大小,上面我们的设定PE是16M,这里指定10个单位的PE,则LV大小是160M [root@test01 Desktop]# lvcreate -l 10 -n testlv testvg 扫描LV [root@test01 Desktop]# lvscanACTIVE '/dev/rhel/rootlv' [14.64 GiB] inheritACTIVE '/dev/testvg/testlv' [208.00 MiB] inherit显示LV的详细信息,后面接的LV名得用绝对路径表示,不然报错找不到 [root@test01 Desktop]# lvdisplay testlvVolume group "testlv" not foundSkipping volume group testlv [root@test01 Desktop]# lvdisplay /dev/testvg/testlv --- Logical volume ---LV Path /dev/testvg/testlvLV Name testlvVG Name testvgLV UUID VpC2SC-qpos-mCWn-F44a-RE6e-XVcu-LUK1j2LV Write Access read/writeLV Creation host, time test01, 2018-12-17 14:54:58 +0800LV Status available# open 0LV Size 208.00 MiBCurrent LE 13Segments 1Allocation inheritRead ahead sectors auto- currently set to 8192Block device 253:1
格式化逻辑卷
格式化为ext4文件系统,也可以使用mkfs -t ext4[root@test01 Desktop]# mkfs.ext4 /dev/testvg/testlv mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 53248 inodes, 212992 blocks 10649 blocks (5.00%) reserved for the super user First data block=1 Maximum filesystem blocks=33816576 26 block groups 8192 blocks per group, 8192 fragments per group 2048 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729, 204801Allocating group tables: done Writing inode tables: done Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done
挂载
[root@test01 Desktop]# mkdir /mnt/test [root@test01 Desktop]# mount /dev/testvg/testlv /mnt/test [root@test01 Desktop]# df -Th Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/rhel-rootlv xfs 15G 4.3G 11G 30% / devtmpfs devtmpfs 481M 0 481M 0% /dev tmpfs tmpfs 490M 140K 490M 1% /dev/shm tmpfs tmpfs 490M 7.1M 483M 2% /run tmpfs tmpfs 490M 0 490M 0% /sys/fs/cgroup /dev/sr0 iso9660 3.5G 3.5G 0 100% /mnt/cdrom /dev/sda1 xfs 297M 109M 189M 37% /boot /dev/mapper/testvg-testlv ext4 198M 1.8M 182M 1% /mnt/test
永久挂载,编辑/etc/fstab文件最后一行编辑[root@test01 Desktop]# vim /etc/fstab /dev/testvg/testlv /mnt/test ext4 defaults 0 0
5.LVM扩容,文件系统扩容,可以在线扩容
步骤:
1.vgdispaly查看VG的磁盘空间————>2.空间足够,直接 lvresize 增加LV空间容量————>3.调整文件系统大小,ext文件系统使用 resize2fs,xfs文件系统使用xfs_growfs
若空间不够,则需要1.先创建新的PV——>2.VG扩容,使用 vgextend ——>3.再给LV扩容——>4.再调整文件系统
先通过vgdisplay 命令查看该VG是否还有空余的空间,若剩余空间可以满足需求则直接调整LV的大小,再调整文件系统的大小,如若无法满足则需要新建一个PV,加入到VG中
[root@test01 Desktop]# vgdisplay testvg --- Volume group ---VG Name testvgSystem ID Format lvm2Metadata Areas 1Metadata Sequence No 2VG Access read/writeVG Status resizableMAX LV 0Cur LV 1Open LV 0Max PV 0Cur PV 1Act PV 1VG Size 288.00 MiBPE Size 16.00 MiBTotal PE 18Alloc PE / Size 13 / 208.00 MiBFree PE / Size 5 / 80.00 MiB ==> 还有5个PE,80M的空间VG UUID eaUhl0-LvkR-Ebou-BXHa-ZnIb-DEza-qFZYbO
第一种情况:通过VG剩余的空间扩容
调整LVM的大小为250M,-L:250M[root@test01 Desktop]# lvresize -L 250M /dev/testvg/testlvRounding size to boundary between physical extents: 256.00 MiBExtending logical volume testlv to 256.00 MiBLogical volume testlv successfully resized [root@test01 Desktop]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/rhel-rootlv 15G 4.3G 11G 30% / devtmpfs 481M 0 481M 0% /dev tmpfs 490M 140K 490M 1% /dev/shm tmpfs 490M 7.1M 483M 2% /run tmpfs 490M 0 490M 0% /sys/fs/cgroup /dev/sr0 3.5G 3.5G 0 100% /mnt/cdrom /dev/sda1 297M 109M 189M 37% /boot /dev/mapper/testvg-testlv 198M 1.8M 182M 1% /mnt/test ==>文件系统并未变化该调整文件系统大小 [root@test01 Desktop]# resize2fs /dev/testvg/testlv resize2fs 1.42.9 (28-Dec-2013) Filesystem at /dev/testvg/testlv is mounted on /mnt/test; on-line resizing required old_desc_blocks = 2, new_desc_blocks = 2 The filesystem on /dev/testvg/testlv is now 262144 blocks long.[root@test01 Desktop]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/rhel-rootlv 15G 4.3G 11G 30% / devtmpfs 481M 0 481M 0% /dev tmpfs 490M 140K 490M 1% /dev/shm tmpfs 490M 7.1M 483M 2% /run tmpfs 490M 0 490M 0% /sys/fs/cgroup /dev/sr0 3.5G 3.5G 0 100% /mnt/cdrom /dev/sda1 297M 109M 189M 37% /boot /dev/mapper/testvg-testlv 244M 2.1M 226M 1% /mnt/test ==>文件系统大小已变更 [root@test01 Desktop]# lvscanACTIVE '/dev/rhel/rootlv' [14.64 GiB] inheritACTIVE '/dev/testvg/testlv' [256.00 MiB] inherit
第二种情况:新建一个PV加入到VG中
[root@test01 Desktop]# 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 14.7G 0 part │ └─rhel-rootlv 253:0 0 14.7G 0 lvm / ├─sda3 8:3 0 2G 0 part [SWAP] ├─sda4 8:4 0 1K 0 part ├─sda5 8:5 0 300M 0 part │ └─testvg-testlv 253:1 0 256M 0 lvm /mnt/test └─sda6 8:6 0 300M 0 part ==>新加的分区
新建一个PV[root@test01 Desktop]# pvcreate /dev/sda6Physical volume "/dev/sda6" successfully created把新建的PV加入到VG中 [root@test01 Desktop]# vgextend testvg /dev/sda6Volume group "testvg" successfully extended [root@test01 Desktop]# vgs testvg VG #PV #LV #SN Attr VSize VFree testvg 2 1 0 wz--n- 576.00m 320.00m [root@test01 Desktop]# vgdisplay testvg--- Volume group ---VG Name testvgSystem ID Format lvm2Metadata Areas 2Metadata Sequence No 4VG Access read/writeVG Status resizableMAX LV 0Cur LV 1Open LV 1Max PV 0Cur PV 2Act PV 2VG Size 576.00 MiBPE Size 16.00 MiBTotal PE 36Alloc PE / Size 16 / 256.00 MiBFree PE / Size 20 / 320.00 MiB ==>剩余的空间为320MVG UUID eaUhl0-LvkR-Ebou-BXHa-ZnIb-DEza-qFZYbO
LV扩容[root@test01 Desktop]# lvresize -L 480M /dev/testvg/testlvExtending logical volume testlv to 480.00 MiBLogical volume testlv successfully resized [root@test01 Desktop]# lvscanACTIVE '/dev/rhel/rootlv' [14.64 GiB] inheritACTIVE '/dev/testvg/testlv' [480.00 MiB] inherit 调整文件系统大小 [root@test01 Desktop]# resize2fs /dev/testvg/testlv resize2fs 1.42.9 (28-Dec-2013) Filesystem at /dev/testvg/testlv is mounted on /mnt/test; on-line resizing required old_desc_blocks = 2, new_desc_blocks = 4 The filesystem on /dev/testvg/testlv is now 491520 blocks long.[root@test01 Desktop]# df -Th Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/rhel-rootlv xfs 15G 4.3G 11G 30% / devtmpfs devtmpfs 481M 0 481M 0% /dev tmpfs tmpfs 490M 140K 490M 1% /dev/shm tmpfs tmpfs 490M 7.1M 483M 2% /run tmpfs tmpfs 490M 0 490M 0% /sys/fs/cgroup /dev/sr0 iso9660 3.5G 3.5G 0 100% /mnt/cdrom /dev/sda1 xfs 297M 109M 189M 37% /boot /dev/mapper/testvg-testlv ext4 461M 2.3M 434M 1% /mnt/test ==>文件系统再一次变大
若是XFS文件系统,调整文件系统的命令则是
[root@test01 Desktop]# xfs_growfs /dev/testvg/testlv
6.LVM缩减,不支持在线缩减,必须先卸载文件系统
步骤:
卸载文件系统——>(e2fsck -f )检查文件系统——>调整文件系统大小——>调整LVM——>挂载文件系统
卸载文件系统
[root@test01 Desktop]# umount /mnt/test/ [root@test01 Desktop]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/rhel-rootlv 15G 4.3G 11G 30% / devtmpfs 481M 0 481M 0% /dev tmpfs 490M 140K 490M 1% /dev/shm tmpfs 490M 7.1M 483M 2% /run tmpfs 490M 0 490M 0% /sys/fs/cgroup /dev/sr0 3.5G 3.5G 0 100% /mnt/cdrom /dev/sda1 297M 109M 189M 37% /boot
变更文件系统大小
[root@test01 Desktop]# resize2fs /dev/testvg/testlv 160M resize2fs 1.42.9 (28-Dec-2013) Please run 'e2fsck -f /dev/testvg/testlv' first. 得先强制检查一下文件系统,再调整文件系统大小 [root@test01 Desktop]# e2fsck -f /dev/testvg/testlv e2fsck 1.42.9 (28-Dec-2013) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/testvg/testlv: 11/122880 files (0.0% non-contiguous), 21922/491520 blocks调整文件系统大小为160M [root@test01 Desktop]# resize2fs /dev/testvg/testlv 160M resize2fs 1.42.9 (28-Dec-2013) Resizing the filesystem on /dev/testvg/testlv to 163840 (1k) blocks. The filesystem on /dev/testvg/testlv is now 163840 blocks long.
缩减LV
调整LVM的大小为160[root@test01 Desktop]# lvresize -L 160M /dev/testvg/testlvWARNING: Reducing active logical volume to 160.00 MiBTHIS MAY DESTROY YOUR DATA (filesystem etc.) Do you really want to reduce testlv? [y/n]: yReducing logical volume testlv to 160.00 MiBLogical volume testlv successfully resized [root@test01 Desktop]# lvscanACTIVE '/dev/rhel/rootlv' [14.64 GiB] inheritACTIVE '/dev/testvg/testlv' [160.00 MiB] inherit ==>testvg大小变为160M [root@test01 Desktop]# mount /dev/testvg/testlv /mnt/test [root@test01 Desktop]# df -Th Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/rhel-rootlv xfs 15G 4.3G 11G 30% / devtmpfs devtmpfs 481M 0 481M 0% /dev tmpfs tmpfs 490M 140K 490M 1% /dev/shm tmpfs tmpfs 490M 7.1M 483M 2% /run tmpfs tmpfs 490M 0 490M 0% /sys/fs/cgroup /dev/sr0 iso9660 3.5G 3.5G 0 100% /mnt/cdrom /dev/sda1 xfs 297M 109M 189M 37% /boot /dev/mapper/testvg-testlv ext4 151M 1.6M 140M 2% /mnt/test ==>文件系统也变成160M了
7.LVM系统快照
快照就是把当前的系统信息记录下来,快照区LV与被快照区的LV必须在同一个VG上,当建立快照区LV时,系统会预留一个区域作为数据存放处,此时快照区无任何数据,快照区与系统区共享所有的PE数据,这时快照区的内容与文件系统是一样的;当系统区的数据有变化时,快照区则会备份变更之前的数据,其他未改变的数据还是处于共享状态,因此快照占用的容量很少
若快照区给的空间已容纳不了变更的数据时,快照会失效
创建文件系统/dev/testvg/testlv的快照
先查看将被快照的lv的大小,便于设定快照区的大小[root@test01 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/rhel-rootlv 15G 4.3G 11G 30% / devtmpfs 905M 0 905M 0% /dev tmpfs 914M 140K 914M 1% /dev/shm tmpfs 914M 8.9M 905M 1% /run tmpfs 914M 0 914M 0% /sys/fs/cgroup /dev/sr0 3.5G 3.5G 0 100% /mnt/cdrom /dev/mapper/testvg-testlv 151M 9.1M 132M 7% /mnt/test ==>才9.1M /dev/sda1 297M 109M 189M 37% /boot [root@test01 ~]# ls /mnt/test/ grub2 lost+found passwd shadow 创建快照 [root@test01 ~]# lvcreate -l 5 -s -n testlv_backup /dev/testvg/testlvLogical volume "testlv_backup" created-l:给快照区的PE的个数-s:就是代表快照的意思-n:快照的名字/dev/testvg/testlv:被快照的LV的名字
查看快照信息
[root@test01 ~]# lvdisplay /dev/testvg/testlv_backup --- Logical volume ---LV Path /dev/testvg/testlv_backupLV Name testlv_backupVG Name testvgLV UUID 1WuR1d-vpav-YQ9r-X8Rr-dpjW-ohTd-ffrebnLV Write Access read/writeLV Creation host, time test01, 2018-12-18 17:02:52 +0800LV snapshot status active destination for testlvLV Status available# open 0LV Size 160.00 MiB ==>被快照的原LV的容量大小Current LE 10COW-table size 80.00 MiB ==>快照区的容量COW-table LE 5 ==>快照区的PE个数Allocated to snapshot 0.01% ==>快照的使用率,0.0.1%这是未使用Snapshot chunk size 4.00 KiBSegments 1Allocation inheritRead ahead sectors auto- currently set to 8192Block device 253:2
挂载这个快照看下内容是不是和原LV一样
[root@test01 ~]# mkdir /mnt/lvback [root@test01 ~]# mount /dev/testvg/testlv_backup /mnt/lvback/ [root@test01 ~]# ls /mnt/lvback/ grub2 lost+found passwd shadow [root@test01 ~]# ls /mnt/test/ grub2 lost+found passwd shadow [root@test01 ~]# ll /mnt/test/ total 21 drwxr-xr-x. 6 root root 1024 Dec 5 15:25 grub2 drwx------. 2 root root 12288 Dec 17 15:12 lost+found -rw-r--r--. 1 root root 2100 Dec 18 16:58 passwd ----------. 1 root root 1224 Dec 18 16:58 shadow [root@test01 ~]# ll /mnt/lvback/ total 21 drwxr-xr-x. 6 root root 1024 Dec 5 15:25 grub2 drwx------. 2 root root 12288 Dec 17 15:12 lost+found -rw-r--r--. 1 root root 2100 Dec 18 16:58 passwd ----------. 1 root root 1224 Dec 18 16:58 shadow大小、权限、属性完全一样
进入testlv的挂载目录,删除里面的grub2目录[root@test01 ~]# cd /mnt/test/ [root@test01 test]# ls grub2 lost+found passwd shadow [root@test01 test]# rm -rf grub2 可见grub2目录已被删除 [root@test01 test]# ls lost+found passwd shadow但是快照LV中依然存在grub2目录,这就是快照的功能,保存被更改数据的原数据 [root@test01 test]# ll ../lvback/ total 21 drwxr-xr-x. 6 root root 1024 Dec 5 15:25 grub2 drwx------. 2 root root 12288 Dec 17 15:12 lost+found -rw-r--r--. 1 root root 2100 Dec 18 16:58 passwd ----------. 1 root root 1224 Dec 18 16:58 shadow[root@test01 test]# lvdisplay /dev/testvg/testlv_backup --- Logical volume ---LV Path /dev/testvg/testlv_backupLV Name testlv_backupVG Name testvgLV UUID 1WuR1d-vpav-YQ9r-X8Rr-dpjW-ohTd-ffrebnLV Write Access read/writeLV Creation host, time test01, 2018-12-18 17:02:52 +0800LV snapshot status active destination for testlvLV Status available# open 1LV Size 160.00 MiBCurrent LE 10COW-table size 80.00 MiBCOW-table LE 5Allocated to snapshot 0.15% ==>快照区的使用空间变化了,从之前的0.0.1%到0.15%,说明被删除的文件已被移动给到快照区了Snapshot chunk size 4.00 KiBSegments 1Allocation inheritRead ahead sectors auto- currently set to 8192Block device 253:2
8. 利用快照备份数据,恢复数据
备份数据
创建备份目录[root@test01 lvback]# mkdri /backup进入快照LV挂载目录,备份所有数据 [root@test01 Desktop]# cd /mnt/lvback/ [root@test01 lvback]# ls grub2 lost+found passwd shadow [root@test01 lvback]# tar -jcvf /backup/testlv.tar.bz2 * [root@test01 lvback]# ll /backup/ total 2536 -rw-r--r--. 1 root root 2594327 Dec 19 11:09 testlv.tar.bz2
恢复数据
卸载需恢复的文件系统[root@test01 ~]# umount /mnt/test/格式化[root@test01 ~]# mkfs.ext4 /dev/testvg/testlv mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 40960 inodes, 163840 blocks 8192 blocks (5.00%) reserved for the super user First data block=1 Maximum filesystem blocks=33816576 20 block groups 8192 blocks per group, 8192 fragments per group 2048 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729Allocating group tables: done Writing inode tables: done Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done 重新挂载 [root@test01 ~]# mount /dev/testvg/testlv /mnt/test/ [root@test01 ~]# cd /mnt/test/ [root@test01 test]# ls lost+found把备份的数据解压到挂载目录下,可见数据已完全恢复,之前被删除的grub2目录也恢复了 [root@test01 test]# tar -jxvf /backup/testlv.tar.bz2 -C . [root@test01 test]# ls grub2 lost+found passwd shadow
9.移除LVM
步骤:
卸载文件系统——>移除LV——>使VG不具备Active标志——>移除VG——>移除PV——>修改磁盘分区ID号
卸载文件系统[root@test01 ~]# umount /mnt/test/移除快照LV [root@test01 ~]# lvremove /dev/testvg/testlv_backup Do you really want to remove active logical volume testlv_backup? [y/n]: yLogical volume "testlv_backup" successfully removed移除testlv [root@test01 ~]# lvremove /dev/testvg/testlv Do you really want to remove active logical volume testlv? [y/n]: yLogical volume "testlv" successfully removed让testvg不具有Active标志 [root@test01 ~]# vgchange -a n testvg 0 logical volume(s) in volume group "testvg" now active移除testvg [root@test01 ~]# vgremove testvg Volume group "testvg" successfully removed移除pv [root@test01 ~]# pvremove /dev/sda{5,6}Labels on physical volume "/dev/sda5" successfully wipedLabels on physical volume "/dev/sda6" successfully wiped修改磁盘分区ID号,使用t参数 [root@test01 ~]# fdisk /dev/sda Welcome to fdisk (util-linux 2.23.2).Changes will remain in memory only, until you decide to write them. Be careful before using the write command.Command (m for help): t Partition number (1-6, default 6): Hex code (type L to list all codes): 83 Changed type of partition 'Linux LVM' to 'Linux'Command (m for help): t Partition number (1-6, default 6): 5 Hex code (type L to list all codes): 83 Changed type of partition 'Linux LVM' to 'Linux'
转载于:https://www.cnblogs.com/lczz/p/10132634.html
linux逻辑卷管理(LVM)相关推荐
- linux逻辑卷管理,RAID磁盘阵列,过程管理,VDO
linux逻辑卷管理,RAID磁盘阵列,过程管理,VDO 文章目录 linux逻辑卷管理,RAID磁盘阵列,过程管理,VDO 新建一个逻辑卷 问题 方案 步骤 一:创建卷组 二:创建逻辑卷 三:格式化 ...
- 【Linux逻辑卷管理】之pvcreate、pvdisplay和pvremove
文章目录 一.逻辑卷管理(LVM)概念 1. LVM 定义 2. 物理卷(PV) 3. 卷组(VG) 4. 逻辑卷(LV) 二.创建逻辑卷 1. pvcreate命令将分区标记为物理卷,==创建物理卷 ...
- Linux 逻辑卷管理器(LVM)
为什么要使用逻辑卷? 逻辑卷管理器是Linux系统用于对硬盘分区进行管理的一种机制,为了解决硬盘设备在创建分区后不易修改分区大小的缺陷.尽管对传统的硬盘分区进行强制扩容或缩容从理论上讲是可行的.但是却 ...
- linux逻辑卷管理(LVM )
逻辑卷管理的技术可理解为,将单个或多个物理磁盘分区(PV物理卷)组成逻辑卷组(VG),再把卷组分成多个逻辑卷(LV),主要特点是,在不影响原来数据情况下可简易的扩充磁盘的大小(缩小硬盘空间可能会导至数 ...
- Android逻辑卷管理LVM,LINUX——LVM逻辑卷管理
LVM: logical volumes manager LVM逻辑卷部署 物理卷->卷组->逻辑卷 第一步:关机添加磁盘:两个磁盘可以构成一个磁盘组. 第二步:查看磁盘 # ls /de ...
- linux逻辑卷管理快照,逻辑卷管理器(LVM)以及快照(特殊逻辑卷)的用法
1.LVM基本介绍 2.PV.VG.LV关系详解(PV/VG/LV的创建.扩展逻辑卷大小.减小(减小操作很少用,仅作学习)) 3.快照的概念以及基本用法(特殊的逻辑卷) 4.总结LVM基本介绍 LVM ...
- 逻辑卷管理LVM (Logical Volume Manager)
什么是LVM? LVM(Logical Volume Manager)逻辑卷管理,是一种将一个或多个硬盘的分区在逻辑上集合,相当于一个大硬盘来使用,当硬盘的空间不够使用的时候,可以继续将其它的硬盘的 ...
- 逻辑卷管理LVM(logical volume manager)
LVM的全名是logical volume manager,中文翻译逻辑卷管理器.之所以称为卷是因为可以将文件系统像卷一样伸长和缩短,LVM的做法是将几个物理的分区(或磁盘)通过软件组合成为一块独立的 ...
- Linux17-磁盘分区、文件系统、逻辑卷管理LVM
目录 一.磁盘分区.文件系统.永久挂载 1.1.MBR分区方案 1.2.使用fdisk.mkfs.partprobe.blkid.lsblk等命令管理MBR分区 1.3.swap分区 1.4.GPT分 ...
- linux逻辑卷管理
2019独角兽企业重金招聘Python工程师标准>>> 摘要: Linux用户安装Linux操作系统时遇到的一个最常见的难以决定的问题就是如何正确地给评估各分区大小,以分配合适的硬盘 ...
最新文章
- 蚂蚁金服“刷脸”支付技术解读:错误率低于百万分之一
- MyBatisPLus3.x中代码生成器自定义数据库表字段类型转换
- 最长回文子串—leetcode5
- linux RTC 驱动模型分析
- .data()与.detach()的区别
- HttpURLConnection, Android访问网络,实用demo
- windows iis 部署 django项目
- STM32工作笔记0069---汉字显示实验
- 安全沙箱冲突:Loader.content:XX 不能访问 XX 可以通过调用 Security.allowDomain 来避免此冲突。...
- 20160601 工作总结
- nginx代理php不能跳转页面,nginx 解决首页跳转问题详解
- 阿里云企业邮箱的imap和pop3设置
- springMVC实现图片打包下载
- File.createTempFile创建临时文件
- 计算机工作原理【操作系统和进程】
- EPLAN 设备选择
- Tektronix TBS1102B 示波器
- 【夜读】2022年最后10天,致自己!
- 希腊字母书写以及发音,常用场景
- 动力电池系统介绍(一)——锂离子电池材料组成及其充放电过程