-1

I found many related questions and answers like this or guides like this but most of them didn't want to do exactly what I want and I am feeling quite insecure and am afraid of doing something wrong.

This is my setup (running lsblk):

sdb               8:16   0 111.8G  0 disk  
├─sdb1            8:17   0   300M  0 part  /boot
└─sdb2            8:18   0 111.5G  0 part  
  └─main        254:0    0 111.5G  0 crypt 
    ├─main-root 254:1    0    25G  0 lvm   /
    ├─main-swap 254:2    0     6G  0 lvm   [SWAP]
    └─main-home 254:3    0  80.5G  0 lvm   /home

What I want to achieve: I want to reduce the main-home partition by 15GB and enlarge the main-root partition by these 15GB. So I don't need to change the size of the crypt main. I just want to change the two underlying root and home partitions.

Can anyone give tell me what steps I need to do, to achieve this?

Additional Info: I don't think that it is relevant, but I got two other HDD's that get encrypted on boot. fdisk says about them:

Disk /dev/sda: 931.53 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: ST31000333AS    
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 94BFBB4A-0DC9-4D29-8EB4-E0F5FB6E3CF5

Disk /dev/mapper/data: 931.52 GiB, 1000200994816 bytes, 1953517568 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/sdd: 1.84 TiB, 2000398934016 bytes, 3907029168 sectors Disk model: WDC WD20EZRZ-00Z Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/mapper/data2: 1.84 TiB, 2000382156800 bytes, 3906996400 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes

  • 1
    Since it looks to me that easy methods wouldn't work with your current layout, here's my only advice: do backups before doing anything. – A.B Aug 12 '20 at 20:55

1 Answers1

2

Assuming you're using a filesytem which can be reduced in size (such as ext4), you can take space from /home and reallocate it to / as follows:

  1. Unmount /home. This means you'll need to log out all users and log in as root: umount /home
  2. Resize /home: lvreduce -L -50G -r main/home
  3. Resize /: lvresize -L +50G -r main/root
  4. Re-mount /home: mount /home
  • Thank you for your answer! Yes, I am using ext4, sorry for not mentioning that. I don't need to umount root?

    As my LV paths are /dev/main/root and /dev/main/home I need to use them when executing lvresize right? (I mean isntead of main/home and main/root)

    – linuxNewbie Aug 13 '20 at 12:12
  • 2
    An ext4 filesystem can be extended on-line, i.e. without unmounting, but shrinking the filesystem requires unmounting it. Any reasonably modern versions of the LVM commands may accept the device names both with and without the /dev/ prefix. – telcoM Aug 13 '20 at 13:50