Last active
March 16, 2019 17:58
-
-
Save byronmansfield/d67d7d66fb7c82874a805756a6ac7731 to your computer and use it in GitHub Desktop.
Modify size of Logical Volumes on Dell XPS with Arch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Resize Logical Volume | |
# | |
# | |
# For reference https://wiki.archlinux.org/index.php/Resizing_LVM-on-LUKS#Enlarge_LVM_on_LUKS | |
# | |
# Stackexchange Thread: https://unix.stackexchange.com/questions/505241/resize-luks-volumes | |
# Reddit Thread: https://old.reddit.com/r/linuxquestions/comments/az6cgw/resize_my_luks_volumes/ | |
# | |
# Originally set up from this: https://gist.github.com/byronmansfield/9e0797c89866c520f4a6b7b9c0f26421 | |
# | |
# Goals | |
- Expand root | |
- Use left over free space for home | |
- avoid any data loss or corruption | |
# Overview | |
I am reducing my /home logical volume and giving the extra space to root | |
# Current setup (helpful so you can understand how the arguments and values to the commands run are applicable) | |
> 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 | |
# Notes | |
Do all of this from a live USB. Practice from a Virtual Box to get comfortable with this first. | |
# Tools needed | |
- cryptsetup | |
- lvresize | |
- resize2fs | |
## Boot from a liveUSB | |
## Step 1: Open the encrypted device (review how i setup luks and compare to /dev/path in these steps) | |
> cryptsetup luksOpen /dev/nvme0n1p2 archlv | |
## Step 2: Reduce home file system (change this to M not G) | |
> resize2fs -p /dev/archlv/archvg-home 374.2G | |
## Step 3: Reduce home logical volume (change this to M not G) | |
> lvreduce -L -90G /dev/archlv/archvg-home (I like this better, you don't have to be so sure of the exact size) | |
or | |
> lvresize --size -100G /dev/archlv/archvg-home | |
## Step 4: Extend the root logical volume (change this to M not G) | |
> lvextend -L +90G /dev/archlv/archvg-root (I like this better, you don't have to be so sure of the exact size) | |
or | |
> lvresize --size +374.2G /dev/archlv/archvg-root | |
### It should automatically grow the files system to max, if for some reason it doesn't | |
## Step 5: Check the fs for errors | |
> fsck /dev/archlv/archvg-root | |
## Step 6: Extend the root file system (change this to M not G) | |
> resize2fs -p /dev/archlv/archvg-root 100G | |
# Reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment