服务器卸载磁盘流程
卸载磁盘流程
温馨提示:
谨慎操作,卸载前请备份!
目录
1.简述lv vg pv
在Linux中,LV(Logical Volume)、VG(Volume Group)和PV(Physical Volume)是与逻辑卷管理和LVM(Logical Volume Manager)相关的术语,用于管理磁盘分区和逻辑卷的层次结构。以下是它们的区别:
PV(Physical Volume):
定义:物理卷是硬盘或硬盘分区,它们是LVM存储的基本构建块。每个PV都是实际的物理硬盘或硬盘分区。
用途:PV用于提供磁盘空间,这些空间可以被分配给VG创建逻辑卷。
特点:PV通常包含文件系统、分区表等数据。在创建PV之前,您需要格式化它并将其配置为LVM PV,以便LVM可以识别和使用它。
VG(Volume Group):
定义:卷组是PV的集合,它们用于汇总物理磁盘或分区的存储空间。VG是LVM中的逻辑单元,可以看作是一个逻辑容器,可以容纳多个PV。
用途:VG允许将多个PV的存储空间合并成一个大的逻辑池,然后从这个池中创建逻辑卷(LV)。
特点:VG具有名称和属性,可以根据需求添加或删除PV。VG的大小是PV的总和,您可以将其用于创建逻辑卷。
LV(Logical Volume):
定义:逻辑卷是从VG中分配的存储区域,它类似于传统磁盘分区,但具有更灵活的大小和管理。
用途:LV用于创建文件系统、存储数据或提供分区,它们是用户和应用程序直接访问的存储单元。
特点:LV的大小不受物理硬盘的限制,可以根据需要动态调整大小。LV可以轻松地在VG之间移动,从一个VG移到另一个VG。
总结起来,PV是实际的硬盘或硬盘分区,VG是将多个PV组合成一个逻辑存储池的容器,而LV是从VG中分配的逻辑存储区域,用于存储数据或创建文件系统。LVM提供了更灵活的存储管理,使您可以在运行时调整存储空间,而不需要重新分区或重新格式化硬盘。
lvdisplay
vgdisplay
pvdisplay
fdisk -l
lvremove /dev/ceph-3d312ae2-62cb-4227-84db-b62645a2e8bf/osd-block-cf553a24-3e51-4d47-b4d8-a33ec0e844dc
vgremove ceph-3d312ae2-62cb-4227-84db-b62645a2e8bf
pvremove /dev/sdb
#从块设备(例如硬盘或分区)上删除文件系统和签名的命令
#这通常在准备重新分区或重新格式化磁盘时使用,以确保磁盘上不包含旧的文件系统或签名,从而避免潜在的冲突或数据丢失。请谨慎使用此命令,因为它会擦除磁盘上的数据。在操作前请务必确保您已备份了重要数据。
wipefs -a /dev/sdb
2.操作详情
--- Logical volume ---
LV Path /dev/ceph-3d312ae2-62cb-4227-84db-b62645a2e8bf/osd-block-cf553a24-3e51-4d47-b4d8-a33ec0e844dc
LV Name osd-block-cf553a24-3e51-4d47-b4d8-a33ec0e844dc
VG Name ceph-3d312ae2-62cb-4227-84db-b62645a2e8bf
LV UUID c7KTwX-QAue-9dnI-6ckt-nAtc-5DH3-DmzY3s
LV Write Access read/write
LV Creation host, time node1, 2023-09-07 11:50:26 +0800
LV Status available
# open 0
LV Size 16.37 TiB
Current LE 4291455
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
2.1lvremove删除逻辑卷(Logical Volume)
[root@node1 ~]# lvdisplay
--- Logical volume ---
LV Path /dev/ceph-1dcdea8c-241b-44d3-a81b-8db87258d022/osd-block-d336d028-4142-456f-b87e-9a0ff0f1fd23
LV Name osd-block-d336d028-4142-456f-b87e-9a0ff0f1fd23
VG Name ceph-1dcdea8c-241b-44d3-a81b-8db87258d022
LV UUID ohtYGG-K79v-SleN-dAoL-WTKN-P8W6-gMXiP1
LV Write Access read/write
LV Creation host, time node1, 2023-08-24 19:28:20 +0800
LV Status available
# open 24
LV Size <7.28 TiB
Current LE 1907583
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:3
--- Logical volume ---
LV Path /dev/ceph-3d312ae2-62cb-4227-84db-b62645a2e8bf/osd-block-cf553a24-3e51-4d47-b4d8-a33ec0e844dc
LV Name osd-block-cf553a24-3e51-4d47-b4d8-a33ec0e844dc
VG Name ceph-3d312ae2-62cb-4227-84db-b62645a2e8bf
LV UUID c7KTwX-QAue-9dnI-6ckt-nAtc-5DH3-DmzY3s
LV Write Access read/write
LV Creation host, time node1, 2023-09-07 11:50:26 +0800
LV Status available
# open 0
LV Size 16.37 TiB
Current LE 4291455
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
--- Logical volume ---
LV Path /dev/cl/root
LV Name root
VG Name cl
LV UUID PwQOZG-p4Rp-HvD8-fvlM-0aWj-XU98-zYJRUY
LV Write Access read/write
LV Creation host, time localhost, 2020-06-30 15:33:17 +0800
LV Status available
# open 1
LV Size 1.74 TiB
Current LE 456168
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
--- Logical volume ---
LV Path /dev/cl/swap
LV Name swap
VG Name cl
LV UUID 5MNNhk-fGqS-wdsG-OrHs-JlTw-CMVD-BF841G
LV Write Access read/write
LV Creation host, time localhost, 2020-06-30 15:33:17 +0800
LV Status available
# open 2
LV Size 4.00 GiB
Current LE 1024
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:1
[root@node1 ~]# lvremove /dev/ceph-3d312ae2-62cb-4227-84db-b62645a2e8bf/osd-block-cf553a24-3e51-4d47-b4d8-a33ec0e844dc
Do you really want to remove active logical volume ceph-3d312ae2-62cb-4227-84db-b62645a2e8bf/osd-block-cf553a24-3e51-4d47-b4d8-a33ec0e844dc? [y/n]: y
Logical volume "osd-block-cf553a24-3e51-4d47-b4d8-a33ec0e844dc" successfully removed.
[root@node1 ~]# lvdisplay
--- Logical volume ---
LV Path /dev/ceph-1dcdea8c-241b-44d3-a81b-8db87258d022/osd-block-d336d028-4142-456f-b87e-9a0ff0f1fd23
LV Name osd-block-d336d028-4142-456f-b87e-9a0ff0f1fd23
VG Name ceph-1dcdea8c-241b-44d3-a81b-8db87258d022
LV UUID ohtYGG-K79v-SleN-dAoL-WTKN-P8W6-gMXiP1
LV Write Access read/write
LV Creation host, time node1, 2023-08-24 19:28:20 +0800
LV Status available
# open 24
LV Size <7.28 TiB
Current LE 1907583
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:3
--- Logical volume ---
LV Path /dev/cl/root
LV Name root
VG Name cl
LV UUID PwQOZG-p4Rp-HvD8-fvlM-0aWj-XU98-zYJRUY
LV Write Access read/write
LV Creation host, time localhost, 2020-06-30 15:33:17 +0800
LV Status available
# open 1
LV Size 1.74 TiB
Current LE 456168
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
--- Logical volume ---
LV Path /dev/cl/swap
LV Name swap
VG Name cl
LV UUID 5MNNhk-fGqS-wdsG-OrHs-JlTw-CMVD-BF841G
LV Write Access read/write
LV Creation host, time localhost, 2020-06-30 15:33:17 +0800
LV Status available
# open 2
LV Size 4.00 GiB
Current LE 1024
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:1
[root@node1 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 1.8T 0 disk
├─sda1 8:1 0 600M 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 1.8T 0 part
├─cl-root 253:0 0 1.8T 0 lvm /
└─cl-swap 253:1 0 4G 0 lvm [SWAP]
sdb 8:16 0 16.4T 0 disk
sdc 8:32 0 7.3T 0 disk
└─ceph--1dcdea8c--241b--44d3--a81b--8db87258d022-osd--block--d336d028--4142--456f--b87e--9a0ff0f1fd23 253:3 0 7.3T 0 lvm
[root@node1 ~]# fdisk -l
Disk /dev/sda: 1.8 TiB, 1919313510400 bytes, 3748659200 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 2EBB132C-05B8-475D-AD49-3789637103B9
Device Start End Sectors Size Type
/dev/sda1 2048 1230847 1228800 600M EFI System
/dev/sda2 1230848 3327999 2097152 1G Linux filesystem
/dev/sda3 3328000 3748657151 3745329152 1.8T Linux LVM
Disk /dev/mapper/cl-root: 1.8 TiB, 1913307267072 bytes, 3736928256 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/cl-swap: 4 GiB, 4294967296 bytes, 8388608 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/sdc: 7.3 TiB, 8000987201536 bytes, 15626928128 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/ceph--1dcdea8c--241b--44d3--a81b--8db87258d022-osd--block--d336d028--4142--456f--b87e--9a0ff0f1fd23: 7.3 TiB, 8000983007232 bytes, 15626919936 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/sdb: 16.4 TiB, 17999671066624 bytes, 35155607552 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
2.2vgremove从 LVM(Logical Volume Manager)中删除卷组(Volume Group)
[root@node1 ~]# vgdisplay
--- Volume group ---
VG Name ceph-1dcdea8c-241b-44d3-a81b-8db87258d022
System ID
Format lvm2
Metadata Areas 1
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 1
Act PV 1
VG Size <7.28 TiB
PE Size 4.00 MiB
Total PE 1907583
Alloc PE / Size 1907583 / <7.28 TiB
Free PE / Size 0 / 0
VG UUID tvP59b-1xxg-fY2U-Oqvf-VcHm-GgyC-AG2im1
--- Volume group ---
VG Name ceph-3d312ae2-62cb-4227-84db-b62645a2e8bf
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 6
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 16.37 TiB
PE Size 4.00 MiB
Total PE 4291455
Alloc PE / Size 0 / 0
Free PE / Size 4291455 / 16.37 TiB
VG UUID QIkt8M-5VLj-ANjJ-4vep-dbRC-7vd6-se4RhM
--- Volume group ---
VG Name cl
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 1.74 TiB
PE Size 4.00 MiB
Total PE 457193
Alloc PE / Size 457192 / 1.74 TiB
Free PE / Size 1 / 4.00 MiB
VG UUID yc179Y-mYHi-yD00-4Mcs-ycY8-eJSJ-0fqKUl
[root@node1 ~]# ^C
[root@node1 ~]# vgremove ceph-3d312ae2-62cb-4227-84db-b62645a2e8bf
Volume group "ceph-3d312ae2-62cb-4227-84db-b62645a2e8bf" successfully removed
[root@node1 ~]# vgdisplay
--- Volume group ---
VG Name ceph-1dcdea8c-241b-44d3-a81b-8db87258d022
System ID
Format lvm2
Metadata Areas 1
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 1
Act PV 1
VG Size <7.28 TiB
PE Size 4.00 MiB
Total PE 1907583
Alloc PE / Size 1907583 / <7.28 TiB
Free PE / Size 0 / 0
VG UUID tvP59b-1xxg-fY2U-Oqvf-VcHm-GgyC-AG2im1
--- Volume group ---
VG Name cl
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 1.74 TiB
PE Size 4.00 MiB
Total PE 457193
Alloc PE / Size 457192 / 1.74 TiB
Free PE / Size 1 / 4.00 MiB
VG UUID yc179Y-mYHi-yD00-4Mcs-ycY8-eJSJ-0fqKUl
2.3pvremove 命令从 LVM 系统中删除物理卷
[root@node1 ~]# fdisk -l
Disk /dev/sda: 1.8 TiB, 1919313510400 bytes, 3748659200 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 2EBB132C-05B8-475D-AD49-3789637103B9
Device Start End Sectors Size Type
/dev/sda1 2048 1230847 1228800 600M EFI System
/dev/sda2 1230848 3327999 2097152 1G Linux filesystem
/dev/sda3 3328000 3748657151 3745329152 1.8T Linux LVM
Disk /dev/mapper/cl-root: 1.8 TiB, 1913307267072 bytes, 3736928256 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/cl-swap: 4 GiB, 4294967296 bytes, 8388608 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/sdc: 7.3 TiB, 8000987201536 bytes, 15626928128 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/ceph--1dcdea8c--241b--44d3--a81b--8db87258d022-osd--block--d336d028--4142--456f--b87e--9a0ff0f1fd23: 7.3 TiB, 8000983007232 bytes, 15626919936 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/sdb: 16.4 TiB, 17999671066624 bytes, 35155607552 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
[root@node1 ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sdc
VG Name ceph-1dcdea8c-241b-44d3-a81b-8db87258d022
PV Size <7.28 TiB / not usable 4.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 1907583
Free PE 0
Allocated PE 1907583
PV UUID gBnSXr-3xdO-RejL-xtP5-mubY-siye-70u3ny
--- Physical volume ---
PV Name /dev/sdb
VG Name ceph-d3303c7f-9dfe-40ea-a1fa-14d5dda75c92
PV Size 16.37 TiB / not usable 4.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 4291455
Free PE 0
Allocated PE 4291455
PV UUID noA3Il-Da34-XbE9-UYfi-ztYq-SY16-UD3CnS
--- Physical volume ---
PV Name /dev/sda3
VG Name cl
PV Size 1.74 TiB / not usable 2.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 457193
Free PE 1
Allocated PE 457192
PV UUID 8Dvn3C-5379-6GsA-b7YS-3CSf-woOr-ISOgOf
[root@node1 ~]# pvremove /dev/sdb
PV /dev/sdb is used by VG ceph-d3303c7f-9dfe-40ea-a1fa-14d5dda75c92 so please use vgreduce first.
(If you are certain you need pvremove, then confirm by using --force twice.)
/dev/sdb: physical volume label not removed.
#这里是由于ceph-osd 插入磁盘自动拉起造成的
# wipefs -a /dev/sdc
wipefs 命令用于清除磁盘上的文件系统、分区表或签名等信息,以便重新使用这个磁盘。
-a 选项表示清除所有的签名和文件系统信息
/dev/sdc 是要清除信息的设备路径,这里假设 /dev/sdc 是一个磁盘或分区
3.设置状态未不在线后播出磁盘即可
/opt/MegaRAID/perccli/perccli64 /c0/e32/s4 set offline
/opt/MegaRAID/perccli/perccli64 /c0/e32/s5 set offline