当前位置: 代码迷 >> 综合 >> How to rename a logical coupon of type swap in LVM
  详细解决方案

How to rename a logical coupon of type swap in LVM

热度:93   发布时间:2023-12-14 23:33:29.0

今天,我们给大家介绍一下,如何重新命名一个类型为swap的逻辑券。

首先,我们先来看一下,系统中的券。

lwk@qwfys:~$ sudo lsblk -l
NAME            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
mint--vg-root   253:0    0 475.5G  0 lvm  /
mint--vg-swap_1 253:1    0   980M  0 lvm  [SWAP]
nvme0n1         259:0    0   477G  0 disk 
nvme0n1p1       259:1    0   512M  0 part /boot/efi
nvme0n1p2       259:2    0 476.4G  0 part 
lwk@qwfys:~$ sudo pvdisplay --- Physical volume ---PV Name               /dev/nvme0n1p2VG Name               mint-vgPV Size               <476.44 GiB / not usable 0   Allocatable           yes (but full)PE Size               4.00 MiBTotal PE              121968Free PE               0Allocated PE          121968PV UUID               njLf5d-c2k8-4gwQ-HrwG-yb8j-S3CH-293PnQlwk@qwfys:~$ sudo vgdisplay   --- Volume group ---VG Name               mint-vgSystem ID             Format                lvm2Metadata Areas        1Metadata Sequence No  7VG Access             read/writeVG Status             resizableMAX LV                0Cur LV                2Open LV               1Max PV                0Cur PV                1Act PV                1VG Size               <476.44 GiBPE Size               4.00 MiBTotal PE              121968Alloc PE / Size       121968 / <476.44 GiBFree  PE / Size       0 / 0   VG UUID               gbIrR2-xW4a-4zr3-18md-eo9q-BXBw-1tWRD3lwk@qwfys:~$ sudo lvdisplay     --- Logical volume ---LV Path                /dev/mint-vg/rootLV Name                rootVG Name                mint-vgLV UUID                1jZgWZ-y3b4-LoTP-H32i-nz5H-A2xh-tYUTMbLV Write Access        read/writeLV Creation host, time mint, 2020-05-24 23:39:52 +0800LV Status              available# open 1LV Size                475.48 GiBCurrent LE             121723Segments               1Allocation             inheritRead ahead sectors     auto- currently set to     256Block device           253:0--- Logical volume ---LV Path                /dev/mint-vg/swap_1LV Name                swap_1VG Name                mint-vgLV UUID                1SkgwJ-DTZe-XD77-Enlg-CoZz-FX1l-Gz2b3eLV Write Access        read/writeLV Creation host, time mint, 2020-05-24 23:39:52 +0800LV Status              available# open 2LV Size                980.00 MiBCurrent LE             245Segments               1Allocation             inheritRead ahead sectors     auto- currently set to     256Block device           253:1lwk@qwfys:~$

上面是我们系统中整个lvm的具体情况,现在我们要做的事就是希望将逻辑券/dev/mint-vg/swap_1重新命名为/dev/mint-vg/swap

lwk@qwfys:~$ sudo lvremove /dev/mint-vg/swap_1Logical volume mint-vg/swap_1 in use.
lwk@qwfys:~$ sudo swapoff /dev/mint-vg/swap_1
lwk@qwfys:~$ sudo lvremove /dev/mint-vg/swap_1
Do you really want to remove and DISCARD active logical volume mint-vg/swap_1? [y/n]: yLogical volume "swap_1" successfully removed
lwk@qwfys:~$ lsblk -l
NAME          MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
mint--vg-root 253:0    0 475.5G  0 lvm  /
nvme0n1       259:0    0   477G  0 disk 
nvme0n1p1     259:1    0   512M  0 part /boot/efi
nvme0n1p2     259:2    0 476.4G  0 part 
lwk@qwfys:~$
lwk@qwfys:~$ sudo lvcreate -L 8G -n mint-vg-swap mint-vgVolume group "mint-vg" has insufficient free space (245 extents): 2048 required.
lwk@qwfys:~$ sudo lvcreate -L 980M -n mint-vg-swap mint-vg
[sudo] password for lwk:       Logical volume "mint-vg-swap" created.
lwk@qwfys:~$
lwk@qwfys:~$ sudo lsblk -l
[sudo] password for lwk:       
NAME          MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
mint--vg-root 253:0    0 475.5G  0 lvm  /
mint--vg-swap 253:1    0   980M  0 lvm  
nvme0n1       259:0    0   477G  0 disk 
nvme0n1p1     259:1    0   512M  0 part /boot/efi
nvme0n1p2     259:2    0 476.4G  0 part 
lwk@qwfys:~$ 
lwk@qwfys:~$ sudo mkswap /dev/mint-vg/swap 
Setting up swapspace version 1, size = 980 MiB (1027600384 bytes)
no label, UUID=aa89b812-bf49-4109-acd1-c66251d12f02
lwk@qwfys:~$ 
  相关解决方案