sdb (SSD)# df/dev/mapper/fedora-root ext4   26G   16G  8.7G   64% /# pvsPV         VG     Fmt  Attr PSize  PFree/dev/sdb3  fedora lvm2 a--  28.62g    0# vgsVG     #PV #LV #SN Attr   VSize  VFreefedora   1   2   0 wz--n- 28.62g    0# lvsLV   VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convertroot fedora -wi-ao---- 25.63gswap fedora -wi-ao----  2.98gsda (Harddisk)/dev/sda1 is my old home.Here has a Free Space and an old swap after sda1 in sda.Q: Extend /homeCan I keep data in sda1, add sda1 to /home?Format free space and old swap, join into one PV, add to /home? Let sda1 mount to /home/xxx/yyy.My first time use LVM. Please give example, thanks.Q File safeIf I add sdax to /home, would a file be divided into two halves, saved to different partitions(SSD-sdb and HD-sda)?If I remove sdax from LV, files in sdax can safely move to /home?
Extend home in LVM and file safe
lvm
Can I keep data in sda1, add sda1 to /home?No, not like that. You can't add the data in the old disk to /home without destroying the data itself; because LVM allocates storage differently than disk partitions. With LVM you can have x number of partitions, across x' number of disks, which are lumped together into a single pool of storage, from which you can then create LVs. So yes, technically files can get split in half, and no, while you can remove a PV (such as sdax) from a VG, you'd end up with an empty sdax because LVM would shuffle the data to the remaining PVs prior to removing it from the VG.Fundamentally it sounds like you're trying to reclaim the storage capacity in your second disk. That's certainly possible --I've done it myself-- but the process depends on how much space you have available in your VG. It looks like you have minimal space left, so I'll assume your old home doesn't fit in /dev/mapper/fedora-root. The process is as follows:Back up your old home /dev/sda1, of course.Delete the old swap partition /dev/sda2 (ex. using fdisk or gdisk)Create a new sda2 to consume the free space; you should end up with a ~ 231G partition.Create a PV with the new partition: pvcreate /dev/sda2Add the new PV to your VG: vgextend fedora /dev/sda2OK, you now have an additional ~230G of storage available in your fedora VG :)Now you have a couple of options: you can either extend your root LV to a size large enough to hold your old home, or create a new LV for home. Either way, the point is to have an LV into which you can copy your data from sda1. Lets say you go with resizing the root LV to... 100GB: lvextend -r -L100G /dev/fedora/rootNow, you can copy your files from old home to /home and they'll get spread across the two disks. You can then finish it off by turning sda1 into a PV and adding it to you VG, to gain 269G or storage.Sidenote: Unless you have the capacity to store the data in sda1 elsewhere, yes, you'll end up with two PVs/partitions on sda.