0

I have a laptop with Arch on it, and I sized the root partition too small. Now I want to expand the partition by taking some from the home partition. I will put the details of the specifics below. My question(s) to you is

1) Am I just expanding the root? Or shrinking the home? Or is it both? If both then does order matter? I see several online tuts that sort of do them different ways. So it's confusing to me.

2) Should I follow the arch documentation exactly? It's not like other tuts I've seen which may not be distro specific. Also asking because it mentions things like make a new partition under expand, but never says anything about what to do with the old one. It would be great if you could explain this if the answer is yes.

3) Do I need to update my fstab afterwards?

4) If all goes well, I should still have my data on these partitions right? Obviously I'm backing up just to be sure.

Here are my specific details:

> df -h
Filesystem               Size  Used Avail Use% Mounted on
dev                      7.7G     0  7.7G   0% /dev
run                      7.7G  1.2M  7.7G   1% /run
/dev/mapper/archvg-root  9.8G  9.3G     0 100% /
tmpfs                    7.7G  723M  7.0G  10% /dev/shm
tmpfs                    7.7G     0  7.7G   0% /sys/fs/cgroup
tmpfs                    7.7G   16K  7.7G   1% /tmp
/dev/nvme0n1p1           749M   62M  688M   9% /boot
/dev/mapper/archvg-home  456G  3.0G  430G   1% /home
tmpfs                    1.6G   16K  1.6G   1% /run/user/1000
/dev/fuse                250G   78M  250G   1% /run/user/1000/keybase/kbfs

> lsblk
NAME              MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
nvme0n1           259:0    0   477G  0 disk
├─nvme0n1p1       259:1    0   750M  0 part  /boot
└─nvme0n1p2       259:2    0 476.2G  0 part
  └─archlv        254:0    0 476.2G  0 crypt
    ├─archvg-swap 254:1    0     2G  0 lvm   [SWAP]
    ├─archvg-root 254:2    0    10G  0 lvm   /
    └─archvg-home 254:3    0 464.2G  0 lvm   /home

> sudo pvdisplay -m
  --- Physical volume ---
  PV Name               /dev/mapper/archlv
  VG Name               archvg
  PV Size               476.20 GiB / not usable <1.32 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              121908
  Free PE               0
  Allocated PE          121908
  PV UUID               m11dPA-mPYo-6dLS-mXPF-V1Ww-jXuO-QXfB8e

  --- Physical Segments ---
  Physical extent 0 to 511:
    Logical volume      /dev/archvg/swap
    Logical extents     0 to 511
  Physical extent 512 to 3071:
    Logical volume      /dev/archvg/root
    Logical extents     0 to 2559
  Physical extent 3072 to 121907:
    Logical volume      /dev/archvg/home
Logical extents 0 to 118835

> sudo cat /etc/crypttab
# Configuration for encrypted block devices.
# See crypttab(5) for details.

# NOTE: Do not list your root (/) partition here, it must be set up
#       beforehand by the initramfs (/etc/mkinitcpio.conf).

# <name>       <device>                                     <password>              <options>
# home         UUID=b8ad5c18-f445-495d-9095-c9ec4f9d2f37    /etc/mypassword1
# data1        /dev/sda3                                    /etc/mypassword2
# data2        /dev/sda5                                    /etc/cryptfs.key
# swap         /dev/sdx4                                    /dev/urandom            swap,cipher=aes-cbc-essiv:sha256,size=256
# vol          /dev/sdb7                                    none

> sudo cat /etc/fstab
# Static information about the filesystems.
# See fstab(5) for details.

# <file system> <dir> <type> <options> <dump> <pass>
# UUID=8ab13737-d7f1-4f2c-b67b-ad15f7374978
/dev/mapper/archvg-root /               ext4            rw,relatime     0 1

# UUID=dc591a00-12d4-49fa-a81e-e80fa71e7aca
/dev/mapper/archvg-home /home           ext4            rw,relatime     0 2

# UUID=5A10-D12E
/dev/nvme0n1p1          /boot           vfat            rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro       0 2

# UUID=492bf365-32de-4756-86da-7fc335dba3dd
/dev/mapper/archvg-swap none            swap            defaults,pri=-2 0 0

> findmnt
TARGET                                SOURCE         FSTYPE      OPTIONS
/                                     /dev/mapper/archvg-root
│                                                    ext4        rw,relatime
├─/proc                               proc           proc        rw,nosuid,nodev,noexec,relatime
│ └─/proc/sys/fs/binfmt_misc          systemd-1      autofs      rw,relatime,fd=30,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=13001
│   └─/proc/sys/fs/binfmt_misc        binfmt_misc    binfmt_misc rw,relatime
├─/sys                                sys            sysfs       rw,nosuid,nodev,noexec,relatime
│ ├─/sys/firmware/efi/efivars         efivarfs       efivarfs    rw,nosuid,nodev,noexec,relatime
│ ├─/sys/kernel/security              securityfs     securityfs  rw,nosuid,nodev,noexec,relatime
│ ├─/sys/fs/cgroup                    tmpfs          tmpfs       ro,nosuid,nodev,noexec,mode=755
│ │ ├─/sys/fs/cgroup/unified          cgroup2        cgroup2     rw,nosuid,nodev,noexec,relatime,nsdelegate
│ │ ├─/sys/fs/cgroup/systemd          cgroup         cgroup      rw,nosuid,nodev,noexec,relatime,xattr,name=systemd
│ │ ├─/sys/fs/cgroup/cpu,cpuacct      cgroup         cgroup      rw,nosuid,nodev,noexec,relatime,cpu,cpuacct
│ │ ├─/sys/fs/cgroup/perf_event       cgroup         cgroup      rw,nosuid,nodev,noexec,relatime,perf_event
│ │ ├─/sys/fs/cgroup/rdma             cgroup         cgroup      rw,nosuid,nodev,noexec,relatime,rdma
│ │ ├─/sys/fs/cgroup/devices          cgroup         cgroup      rw,nosuid,nodev,noexec,relatime,devices
│ │ ├─/sys/fs/cgroup/net_cls,net_prio cgroup         cgroup      rw,nosuid,nodev,noexec,relatime,net_cls,net_prio
│ │ ├─/sys/fs/cgroup/blkio            cgroup         cgroup      rw,nosuid,nodev,noexec,relatime,blkio
│ │ ├─/sys/fs/cgroup/pids             cgroup         cgroup      rw,nosuid,nodev,noexec,relatime,pids
│ │ ├─/sys/fs/cgroup/memory           cgroup         cgroup      rw,nosuid,nodev,noexec,relatime,memory
│ │ ├─/sys/fs/cgroup/cpuset           cgroup         cgroup      rw,nosuid,nodev,noexec,relatime,cpuset
│ │ ├─/sys/fs/cgroup/hugetlb          cgroup         cgroup      rw,nosuid,nodev,noexec,relatime,hugetlb
│ │ └─/sys/fs/cgroup/freezer          cgroup         cgroup      rw,nosuid,nodev,noexec,relatime,freezer
│ ├─/sys/fs/pstore                    pstore         pstore      rw,nosuid,nodev,noexec,relatime
│ ├─/sys/fs/bpf                       bpf            bpf         rw,nosuid,nodev,noexec,relatime,mode=700
│ ├─/sys/kernel/debug                 debugfs        debugfs     rw,relatime
│ ├─/sys/kernel/config                configfs       configfs    rw,relatime
│ └─/sys/fs/fuse/connections          fusectl        fusectl     rw,relatime
├─/dev                                dev            devtmpfs    rw,nosuid,relatime,size=8054652k,nr_inodes=2013663,mode=755
│ ├─/dev/shm                          tmpfs          tmpfs       rw,nosuid,nodev
│ ├─/dev/pts                          devpts         devpts      rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000
│ ├─/dev/mqueue                       mqueue         mqueue      rw,relatime
│ └─/dev/hugepages                    hugetlbfs      hugetlbfs   rw,relatime,pagesize=2M
├─/run                                run            tmpfs       rw,nosuid,nodev,relatime,mode=755
│ ├─/run/user/1000                    tmpfs          tmpfs       rw,nosuid,nodev,relatime,size=1613400k,mode=700,uid=1000,gid=985
│ │ └─/run/user/1000/keybase/kbfs     /dev/fuse      fuse        rw,nosuid,nodev,relatime,user_id=1000,group_id=985
│ └─/run/docker/netns/07a9a88abf83    nsfs[net:[4026532513]]
│                                                    nsfs        rw
├─/tmp                                tmpfs          tmpfs       rw,nosuid,nodev
├─/boot                               /dev/nvme0n1p1 vfat        rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro
├─/home                               /dev/mapper/archvg-home
│                                                    ext4        rw,relatime
├─/var/lib/docker/overlay2/a375c9d741cdc4a028b45432bbf717fcab31e455020fd9a35caa33d3d091b86d/merged
│                                     overlay        overlay     rw,relatime,lowerdir=/var/lib/docker/overlay2/l/YKROXQXIMTM5ZON4Q4IHFNJPCC:/var/lib/docker/overlay2/l/KHHAHRA7VX4L6KOXOW44IYDHPS:/var/li
├─/var/lib/docker/containers/6b2b84ce263a25e24dd50b239a14947e55e70843e9b31fe53ac830f73f8584f7/mounts/shm
│                                     shm            tmpfs       rw,nosuid,nodev,noexec,relatime,size=65536k
└─/keybase                            keybase-redirector
                                                     fuse        ro,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other

Here is the steps I plan on taking

Boot from a live USB

# Step 1: Clone the current partition to a new partition
> dd if=/dev/mapper/archvg-root of=/dev/mapper/archvg2-root bs=4M

# Step 2: Extend the new partition
> cryptsetup open /dev/mapper/archvg2-root archlv

# Step 3: Enlarge the PV to use all the available remaining space of the partition
> pvresize /dev/mapper/archlv

## Review
> pvdisplay -m

# Step 4: Resize /home Logical Volume (trying to make it 100G)
> lvresize -L +90.2G /dev/CryptVolumeGroup/root

## Review
> pvdisplay -m

# Step 5: Resize encrypted volume (Trying to give it some space)
> resize2fs -p /dev/CryptVolumeGroup/root 101G

# Reboot

Here are other references of other's doing this differently which I'm still looking into if they have better methods or not.

  • 1
    It looks like your steps contain a mix of instructions from various sources. In short, it doesn't make sense. Please add the output of findmnt so we can get more information about your filesystems. – Emmanuel Rosa Mar 9 at 12:59
  • I updated my post with findmnt @EmmanuelRosa – Byron Mansfield Mar 9 at 19:40
3

clarify terminology

Firstly, your rootfs, home, and swap are on logical volumes not partitions. I'm bringing this up because logical volumes and partitions are different animals. The instructions for one do no necessarily apply to the other. In addition, your volume group is inside a LUKS container. This is an advanced Arch configuration, but luckily the steps for what you want to accomplish are not too difficult :)

steps

  1. Log out all users, and log in as root from a terminal (ex. CTRL+ALT+F1) NOT from within Xorg.
  2. Switch to single-user mode to avoid the use of /home: systemctl rescue
  3. umount /home
  4. Shrink the /home logical volume and filesystem: lvreduce -r -L -100G archvg/home
  5. mount /home
  6. Enlarge the rootfs logical volume. No need to un-mount since ext4 and be enlarged while mounted: lvresize -r -L +100G archvg/home
  7. Switch back to multi-user mode: systemctl default

Q&A

  1. Am I just expanding the root? Or shrinking the home? Or is it both? If both then does order matter? Both, and yes the order matters because in order to enlarge root you need free space. Thus home must be shrunk first.
  2. Should I follow the arch documentation exactly? Probably not. Advanced setups like yours demand an understanding of each component. In your case, that would be LVM2, LUKS, and ext4. This is because there's no way to write a one-size-fits all procedure; Every setup is unique. The Arch documentation can give you guide posts, but is unlikely to provide a step-by-step procedure that will Just Work (TM).
  3. Do I need to update my fstab afterwards? No.
  4. If all goes well, I should still have my data on these partitions right? Obviously I'm backing up just to be sure. Yes, your data should remain. However, as you stated, please, for the love of Linux, make a backup first!
  • Thank you @Emmanual Rose. This helped settle my concerns. And yes, you are totally right. My terminalogy was off. Thank you for clarifying for me. It helped me in searching how to solve my problem greatly. In short how I ended up resolving my issue for anyone else who stumbles onto this thread looking to solve a similar issue; Boot from a liveUSB, open the luks device with cryptsetup, shrink the home fs resize2fs, reduce the logical volume lvreduce, grow the root lvextend, check the fs fsck, grow the root fs resize2fs, reboot. – Byron Mansfield Mar 16 at 17:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.