大网数据广告活动
服务器运维问答

Remove physical volume from LVM volume group without erasing data

· 52CE 我爱测

I have a volume group: $ vgdisplay --- Volume group --- VG Name Ethan-PC System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 19 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 1 Max PV 0 Cur PV 2 Act PV…

问题原文

原帖链接 · etnguyen03 · CC BY-SA 4.0

I have a volume group:

$ vgdisplay
  --- Volume group ---
  VG Name               Ethan-PC
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  19
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               1
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               <3.86 TiB
  PE Size               4.00 MiB
  Total PE              1010969
  Alloc PE / Size       1004569 / 3.83 TiB
  Free  PE / Size       6400 / 25.00 GiB
  VG UUID               ixrl2q-Alsc-UvxQ-q55x-7M3G-S2vq-fNr1wC

two logical volumes:

$ sudo lvdisplay
  --- Logical volume ---
  LV Path                /dev/Ethan-PC/root
  LV Name                root
  VG Name                Ethan-PC
  LV UUID                Mde88v-pIYX-ubVw-dYgY-IuaJ-K59r-xHEtXP
  LV Write Access        read/write
  LV Creation host, time archiso, 2018-12-15 10:04:22 -0600
  LV Status              available
  # open                 1
  LV Size                200.00 GiB
  Current LE             51200
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:0
   
  --- Logical volume ---
  LV Path                /dev/Ethan-PC/home
  LV Name                home
  VG Name                Ethan-PC
  LV UUID                Q4m5VI-QH2q-J0oK-XT3z-Ip7c-dk4f-KLCGAs
  LV Write Access        read/write
  LV Creation host, time Ethan-PC, 2018-12-15 17:50:50 -0600
  LV Status              available
  # open                 0
  LV Size                <3.64 TiB
  Current LE             953369
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:1

and two physical volumes:

pvdisplay                                                                      
  --- Physical volume ---
  PV Name               /dev/nvme0n1p2
  VG Name               Ethan-PC
  PV Size               223.08 GiB / not usable <3.57 MiB
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              57108
  Free PE               5908
  Allocated PE          51200
  PV UUID               XeW7X2-OKDy-D4aG-clfq-db7N-1g3X-5cJLXP
   
  --- Physical volume ---
  PV Name               /dev/sda1
  VG Name               Ethan-PC
  PV Size               <3.64 TiB / not usable <2.82 MiB
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              953861
  Free PE               492
  Allocated PE          953369
  PV UUID               g0OSPs-AXTd-6YuE-tEAM-fkmy-O2Ke-ieFXnN

All the data on the home LV is on /dev/sda1 and all the data on root is on /dev/nvme0n1p2.

# note: irrelevant entries have been removed
$ lsblk
NAME               MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINTS
sda                  8:0    0   3.6T  0 disk  
└─sda1               8:1    0   3.6T  0 part  
  └─Ethan--PC-home 254:1    0   3.6T  0 lvm   
nvme0n1            259:2    0 476.9G  0 disk  
└─nvme0n1p2        259:4    0 223.1G  0 part  
  └─Ethan--PC-root 254:0    0   200G  0 lvm   /

I want to remove /dev/sda1 from the volume group. I can do this easily, but that procedure involves losing the data stored on the home LV. I want to keep the data on the drive in case I need to refer to it later. How would I remove /dev/sda1 from the VG without erasing the data?

Thank you!

已采纳解答

原帖链接 · Chaoxiang N · CC BY-SA 4.0

I would do the following:

  • umount /home
  • vgsplit Ethan-PC homevg /dev/sda1

You would get 2 differents VGs:

  • Ethan-PC with pv /dev/nvme0n1p2
  • homevg with pv /dev/sda1

After that you still have to rebuild and mount a /home, either from /dev/homevg/home, or from /dev/Ethan-PC/home (need to be created and formatted)

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2022-11-20)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。