You are not logged in.

#1 2024-03-03 02:03:57

5vr
Member
Registered: 2024-03-03
Posts: 4

Need help merging `/` & `/home` directories

Problem

  • Space keeps running out in /home despite having abundant on disk

  • I wish to merge the / & /home directories which are inside logical volumes but don't know how to.

  • I cannot afford the time to reinstall the system.

Relevant information

Things prepared

  • A backup of /home

  • An Arch ISO live boot

Outputs

Output of lsblk:

$ lsblk
NAME                 MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda                    8:0    0 119.2G  0 disk 
├─sda1                 8:1    0   579M  0 part 
├─sda4                 8:4    0  87.3G  0 part 
│ ├─archlinux-system 254:0    0    50G  0 lvm  /
│ └─archlinux-home   254:1    0  68.7G  0 lvm  /home
└─sda5                 8:5    0  31.3G  0 part 
  ├─archlinux-system 254:0    0    50G  0 lvm  /
  └─archlinux-home   254:1    0  68.7G  0 lvm  /home

Output of lvdisplay:

# lvdisplay
  --- Logical volume ---
  LV Path                /dev/archlinux/system
  LV Name                system
  VG Name                archlinux
  LV UUID                lkfin3-xMzr-4vN5-e9WQ-qQfv-ifde-3YDnfQ
  LV Write Access        read/write
  LV Creation host, time archiso, 2023-05-01 21:12:56 +0530
  LV Status              available
  # open                 1
  LV Size                50.00 GiB
  Current LE             12800
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:0
   
  --- Logical volume ---
  LV Path                /dev/archlinux/home
  LV Name                home
  VG Name                archlinux
  LV UUID                Wg60vs-XDbn-8gIh-irop-eSlQ-C3Jq-3O7UH0
  LV Write Access        read/write
  LV Creation host, time archiso, 2023-05-01 21:19:23 +0530
  LV Status              available
  # open                 1
  LV Size                68.67 GiB
  Current LE             17580
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:1

Output of vgdisplay:

# vgdisplay
  --- Volume group ---
  VG Name               archlinux
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               118.67 GiB
  PE Size               4.00 MiB
  Total PE              30380
  Alloc PE / Size       30380 / 118.67 GiB
  Free  PE / Size       0 / 0   
  VG UUID               VfxLpw-L66i-pseM-8Ne1-a7Kd-GboR-Nct70K

Output of pvdisplay:

# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda4
  VG Name               archlinux
  PV Size               87.33 GiB / not usable 0   
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              22357
  Free PE               0
  Allocated PE          22357
  PV UUID               e98xAh-y5dZ-2hps-yKVR-nnpL-v2u2-HeRT3L
   
  --- Physical volume ---
  PV Name               /dev/sda5
  VG Name               archlinux
  PV Size               31.34 GiB / not usable 2.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              8023
  Free PE               0
  Allocated PE          8023
  PV UUID               02OqgG-jDW9-Z3L8-Mtkq-3hEe-qhdm-WAGJvg

Output of df -h:

$ df -h
Filesystem                    Size  Used Avail Use% Mounted on
dev                           3.9G     0  3.9G   0% /dev
run                           3.9G  1.4M  3.9G   1% /run
efivarfs                      128K   64K   60K  52% /sys/firmware/efi/efivars
/dev/mapper/archlinux-system   50G   24G   26G  48% /
tmpfs                         3.9G  5.4M  3.9G   1% /dev/shm
tmpfs                         3.9G  5.8M  3.9G   1% /tmp
/dev/mapper/archlinux-home     69G  9.7G   57G  15% /home
tmpfs                         786M  172K  785M   1% /run/user/1000

Offline

#2 2024-03-03 02:23:15

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,459
Website

Re: Need help merging `/` & `/home` directories

5vr wrote:

Space keeps running out in /home ...

What exactly does this mean?  The data you posted shows it is only 15% full.  Are you running out of inodes?  Or what's the actual problem?


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2024-03-03 02:32:09

ZLima12
Member
Registered: 2016-01-24
Posts: 11

Re: Need help merging `/` & `/home` directories

Why do you have two PVs on the same disk?

Offline

#4 2024-03-03 08:14:07

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,010

Re: Need help merging `/` & `/home` directories

And both hold logical volumes exceeding the size of the underlying partition.
Something really bad has happened here.

I cannot afford the time to reinstall the system.

You'll probably have to if you want to get out of this mess.
https://wiki.archlinux.org/title/Migrat … d_packages
or
https://wiki.archlinux.org/title/Rsync# … tem_backup

You've illegal LVs on across two PVs
Iff. IFFFF. IFFFF!!!! You're only using the  PV on sda4 so far, you could try to simply remove sda5 and grow sda4 to span the remainder of the disk (you'll have to do this offline, ie. from the iso or grml or a gparted live system or whatever)
Since you somehow managed to get the illegal PVs in place, that ***might*** be just about it.

But approaching this w/o backups and preparation for the forementioned restorage of the installed system bares the risk that you're gonna hate yourself tomorrow.

Offline

#5 2024-03-19 19:09:34

5vr
Member
Registered: 2024-03-03
Posts: 4

Re: Need help merging `/` & `/home` directories

I ended up doing a clean install.

Offline

#6 2024-03-21 02:55:18

mpboden
Member
Registered: 2024-03-14
Posts: 2

Re: Need help merging `/` & `/home` directories

I personally wouldn't define the OP's setup with Logical Volumes across two Physical Volumes as illegal. This is actually how LVM works. However, it's generally not recommended to define Physical Volumes as multiple partitions on the same hard drive. It can technically be done, but it's not best practice.

If you look at the LVM HOWTO at Linux Documentation Project, 12.1. Multiple partitions on the same disk, this is specifically allowed and demonstrated since they're block devices.

tldp.org wrote:

LVM allows you to create PVs (physical volumes) out of almost any block device so, for example, the following are all valid commands and will work quite happily in an LVM environment:

# pvcreate /dev/sda1
# pvcreate /dev/sdf
# pvcreate /dev/hda8
# pvcreate /dev/hda6
# pvcreate /dev/md1
 

But again, this isn't recommended as shown below:

tldp.org wrote:

In a "normal" production system it is recommended that only one PV exists on a single real disk, for the following reasons:
   

  • Administrative convenience

        It's easier to keep track of the hardware in a system if each real disk only appears once. This becomes particularly true if a disk fails.

       

  • To avoid striping performance problems

        LVM can't tell that two PVs are on the same physical disk, so if you create a striped LV then the stripes could be on different partitions on the same disk resulting in a decrease in performance rather than an increase.

--------------

Now despite the current configuration going against general recommendations, this is a valid setup with the Logical Volumes matching the size of the underlying Physical Volumes.

There are two partitions defined as Physical Volumes:

  • /dev/sda4 is 87.33GiB using all 22357 Physical Extents. There are zero Free Extents.

  • /dev/sda5 is 31.34GiB using all 8023 Physical Extents. There are zero Free Extents.

There is one Volume Group named 'archlinux' with both Physical Volumes attached for a total of 30380 Physical Extents. This calculates to a total size of 118.67GiB, which is equal to 87.33GiB + 31.34GiB.

Two Logical Volumes were created:

  • /dev/archlinux/system at 50GiB using 12800 Logical Extents.

  • /dev/archlinux/home at 68.7GiB using 17580 Logical Extents.

Total Logical Extents are 30380, which matches total Physical Extents of 30380.

The Logical Volumes span both Physical Volumes, which is expected. The Physical Volumes are abstracted within the Volume Group and Logical Volumes are created on top, thus spanning the Physical Volumes.

The OP's output of `df -h` shows that the OP isn't even close to filling either of the Logical Volumes:

  • /dev/mapper/archlinux-system   50G   24G   26G  48% /

  • /dev/mapper/archlinux-home     69G  9.7G   57G  15% /home

--------------

Anyway, I'm confused as to what the original problem is and wonder how/why this setup was created in the first place.

If the OP was concerned about running out of space, then additional Physical Volumes could have been added to the Volume Group allowing either one of the Logical Volumes to be extended. Alternatively, a new Volume Group could have been created with a new larger Physical Volume added to it and one of the current Logical Volumes moved to this new Volume Group.

Last edited by mpboden (2024-03-21 03:12:12)

Offline

#7 2024-03-21 07:09:47

5vr
Member
Registered: 2024-03-03
Posts: 4

Re: Need help merging `/` & `/home` directories

mpboden wrote:

Anyway, I'm confused as to what the original problem is and wonder how/why this setup was created in the first place.

I received this laptop from my father with Windows pre-installed on it. The Windows installation occupied the disk space from the middle to the end. Initially, unsure about committing entirely to Arch Linux, I opted for a dual-boot setup, allocating partitions for Arch on either side of the Windows partitions. This was the initial configuration I had.

As I transitioned to using Arch Linux as my primary operating system, I encountered storage constraints. Consequently, I removed all Windows partitions and unintentionally merged the root partition with the resultant free space. This action prompted me to reach out for assistance, hence this post.

Offline

#8 2024-03-21 09:02:29

frostschutz
Member
Registered: 2013-11-15
Posts: 1,647

Re: Need help merging `/` & `/home` directories

mpboden wrote:

The Logical Volumes span both Physical Volumes, which is expected.

Probably both volumes were grown at some point. Otherwise whichever volume was created first, should have been on a single PV and not span across two PVs.

"Growing as needed" is a good way to use LVM, even if it causes some fragmentation and spanning. Allocating 100% of the space directly makes it a lot less flexible to change sizes later on. (No online shrinking for most filesystems). You also lose the ability to create snapshots.

This isn't bad or illegal in any way. It's just normal — whole point of LVM is to be flexible about these things. In an ideal setup, where you know the partition sizes you're going to have, you wouldn't need LVM at all.

The only real reason not to use multiple PV on a single disk is striping/raid since it harms performance, and more importantly there's no redundancy. Same goes for mdadm, you should not use the same disk multiple times in a single array. Otherwise a single drive failure would translate to double, triple failure in the RAID.

But this is a special use case. It doesn't matter at all if you use it for simple linear volumes only. If you do intend to use RAID, you better know what you're doing, and specify the PVs to be used on lvcreate. LVM does zero hand-holding. Checking whether PVs share the same physical drives is easy. LVM just doesn't do it.

Last edited by frostschutz (2024-03-21 10:37:51)

Offline

Board footer

Powered by FluxBB