Daniel Hiller

Geek, programmer, father
Set up multiple JDKs with jenv and AdoptOpenJDK
All posts
Switch to console tty on Fedora

Resize encrypted file systems for lvm

2020-02-13

linux fedora filesystem lvm encryption 

How to reduce Fedora home partition and increase root in an encrypted luks container

CAVEAT: I am not responsible for you losing your data trying this! Please backup your data before doing this! If anything goes wrong, data will be lost!!!

I’ve been in the situation where either root or home partition have been low on free disk space, while the other partition had lots of free space available. Therefore the idea is to first shrink the space on the partition where space is available and then give that space to the other partition. With that said, I’ve done this a couple of times already and the filesystems were healthy afterwards.

Initial situation:

What you need:

Note: In the bash commands that follow I resize the home partition to 40GB, you should adjust the disk space to something reasonable that fits your need.

How to resize partitions:

  1. Boot Fedora Live CD/USB
  2. open LUKS container
    • open application Disks
    • Select luks partition
    • Select lock symbol
    • Enter password for partition
    • now partitions inside container should be visible in GUI
  3. Open terminal window - get root
    • sudo su -
  4. Important: after each of the following steps you should run e2fsck and correct any errors you get
    • either e2fsck -f /dev/mapper/fedora_localhost--live-home
    • or e2fsck -f /dev/mapper/fedora_localhost--live-root
  5. shrink home by first resizing the filesystem and then resizing the partition
    • resize2fs /dev/mapper/fedora_localhost--live-home 40G
    • lvreduce -L 40G /dev/mapper/fedora_localhost--live-home
  6. resize the root partition to take the free space
    • lvextend -l +100%FREE /dev/mapper/fedora_localhost--live-root
    • resize2fs /dev/mapper/fedora_localhost--live-root

See also:

Related posts:

Set up multiple JDKs with jenv and AdoptOpenJDK
All posts
Switch to console tty on Fedora

Creative Commons License This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. Last update on 2020-02-13. Built by dhiller using Atom (editor), Jekyll (site builder), OneDark vivid (syntax highlighting theme), Webjeda (related posts), Disqus (discussions), Github Pages (hosting), Cloudflare (DNS).