Ask Your Question
4

How can I resize root and home partitions on a encrypted system to give root more space?

asked 2014-05-30 01:55:52 -0600

updated 2014-09-29 00:10:08 -0600

mether gravatar image

I have a Fedora 20 system. Which I installed allot of software on the last few months and I need to resize the / (root) partition to give it more space. The drive is encrypted with LUKS. Gparted doesn't support LUKS so I can't use that.

How can this be done?

Here is:
    ]# df -h
    Filesystem                       Size  Used Avail Use% Mounted on
    /dev/dm-3                         50G   46G  874M  99% /
    devtmpfs                         1.9G     0  1.9G   0% /dev
    tmpfs                            1.9G  3.0M  1.9G   1% /dev/shm
    tmpfs                            1.9G  944K  1.9G   1% /run
    tmpfs                            1.9G     0  1.9G   0% /sys/fs/cgroup
    tmpfs                            1.9G   59M  1.9G   4% /tmp
    /dev/sda2                        477M  131M  317M  30% /boot
    /dev/sda1                        200M  9.6M  191M   5% /boot/efi
    /dev/mapper/fedora_hostname-home  405G  202G  183G  53% /home

Here is:

~]$ df -i
Filesystem                        Inodes   IUsed    IFree IUse% Mounted on
/dev/dm-3                        3276800 1772040  1504760   55% /
devtmpfs                          488149     468   487681    1% /dev
tmpfs                             490792       7   490785    1% /dev/shm
tmpfs                             490792     659   490133    1% /run
tmpfs                             490792      13   490779    1% /sys/fs/cgroup
tmpfs                             490792      55   490737    1% /tmp
/dev/sda2                         128016      80   127936    1% /boot
/dev/sda1                              0       0        0     - /boot/efi
/dev/mapper/fedora_hostname-home 26959872  182663 26777209    1% /home

Here is:

]$ sudo fdisk -l

Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 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
Disklabel type: gpt
Disk identifier: 7AE6E531-9898-4C7C-8C35-41B4FDB9374A

Device           Start          End   Size Type
/dev/sda1         2048       411647   200M EFI System
/dev/sda2       411648      1435647   500M Microsoft basic data
/dev/sda3      1435648    976773119 465.1G Microsoft basic data


Disk /dev/mapper/luks-e69b0b4c-a8e0-425f-988d-8c635729503b: 465.1 GiB, 499370688512 bytes, 975333376 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

Disk /dev/mapper/fedora_hostname-swap: 3.8 GiB, 4043309056 bytes, 7897088 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

Disk /dev/mapper/fedora_hostname-root: 50 GiB, 53687091200 bytes, 104857600 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

Disk /dev/mapper/luks-b7af1bce-82c4-4921-aac1-bce701e30256: 50 GiB, 53684994048 bytes, 104853504 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

Disk /dev/mapper/fedora_hostname-home: 411.3 GiB, 441639239680 bytes, 862576640 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

Here is:

~]$ sudo lvdisplay
  --- Logical volume ---
  LV Path                /dev/fedora_hostname/swap
  LV Name                swap
  VG Name                fedora_hostname
  LV UUID                qQQRVR-toXX-J0M7-lTH5-d8Lr-AUq3-EHJ6A4
  LV Write Access        read/write
  LV Creation host, time hostname.lan, 2014-03-24 15:51:10 +0000
  LV Status              available
  # open                 2
  LV Size                3 ...
(more)
edit retag flag offensive close merge delete

Comments

@randomuser , as the user updated and changed the question to something else, I have removed my answer all together :-)

NickTux gravatar imageNickTux ( 2014-06-02 15:27:12 -0600 )edit

Thanks @NikTh - it was a good answer, just not for this question :)

randomuser gravatar imagerandomuser ( 2014-06-02 15:28:42 -0600 )edit

3 Answers

Sort by » oldest newest most voted
2

answered 2014-06-03 13:56:10 -0600

hedayat gravatar image

updated 2014-06-03 15:47:32 -0600

It turned out that your LVM partitions are created on top of a LUKS partitions, and your / partition is created on top of a LUKS partition which is created in an LVM logical volume. Also, I assume that you want to shrink /home partition and enlarge /. Therefore, the steps would be like this:

  1. Shrink the /home "filesystem". (e.g. if it is ext4, it should be resized using resize2fs).
  2. Shrink the /home LVM partition (/dev/mapper/fedora_hostname-home) size so that it completely includes /home shrinked filesystem using lvreduce
  3. If the shrinked filesystem is smaller than /home LVM partition, you can resize the filesystem again to fill LVM logical volume completely. I usually use this method so that I don't need to calculate sizes accurately! :P

(After each of the above steps, you can mount /home to see if it mounts correctly, and data is there. If not (for example because of wrong parameters), you can revert that problematic step).

The steps for enlarging / partition would be like this:

  1. Enlarge / LVM partition (/dev/mapper/fedora_hostname-root) to fill the free space (using lvextend)
  2. Enlarge / LUKS partition to fill /dev/mapper/fedora_hostname-root LVM partition (using cryptsetup resize)
  3. Enlarge / filesystem to fill / LUKS partition (e.g. using resize2fs if ext2/3/4)

    Sorry if the answer is not detailed enough. You can find some more deails here: http://unix.stackexchange.com/questions/41091/how-can-i-shrink-a-luks-partition-what-does-cryptsetup-resize-do

edit flag offensive delete link more

Comments

@hedayat It's probably important, that it's / and the whole drive that are encrypted, or am I wrong? Are /home and / both encrypted. I only remember encrypting the whole drive and the root.

somethingSomething gravatar imagesomethingSomething ( 2014-06-03 15:02:48 -0600 )edit

Oh, you are right. Would you please provide the output of sudo pvdisplay? Also note that you are using GPT and so fdisk output is useless. you should use gdisk instead.

OK, so if I understood correctly:

  1. Your whole LVM partitions are created on top of an encrypted LUKS partition (therefore, your swap, /home and / are encrypted) (so we have LVM on LUKS).
  2. In LVM you have three partitions. Your root partition is a LUKS partition again! (LUKS on LVM partition). Actually, your / is encrypted twice; is it intentional?

OK, I will edit my answer with the new information.

hedayat gravatar imagehedayat ( 2014-06-03 15:40:46 -0600 )edit

@hedayat I really can't remember how it was done, the encryption. But I remember that first I had a system with the whole drive encrypted, then I made a fresh re-install of the system and used the old /home partition on the new install. I recall choosing encryption for the / so that's encrypted, but I would think that the whole drive is also encrypted. When I boot the computer I get prompted for encryption password twice. Isn't there a way to be sure, there must be some commands that make this clear. I'll update my question with the output from "pvdisplay". Thank's for your time.

somethingSomething gravatar imagesomethingSomething ( 2014-06-03 16:11:57 -0600 )edit

Yes, the pvdisplay output confirms my assumption (And your / partition is encrypted twice). Your LVM is on /dev/mapper/luks-e69b0b4c-a8e0-425f-988d-8c635729503b which is the 465GiB LUKS partition. So, my updated answer applies to your system.

hedayat gravatar imagehedayat ( 2014-06-03 16:40:18 -0600 )edit

@hedayat Success!!! Thank's a bunch

somethingSomething gravatar imagesomethingSomething ( 2014-06-04 10:29:11 -0600 )edit
1

answered 2018-09-21 09:07:24 -0600

bob323 gravatar image

updated 2018-09-21 09:08:45 -0600

I know this is an old question, but since it's one of the first search results for "Fedora resize root partition" I wanted to put in my 2¢. I was able to shrink my home partition and enlarge my root partition using KDE Partition Manager much more easily than manually mounting and decrypting would have been (which I have had to do in the past). It requires a flash drive or live CD with Fedora KDE spin on it.

Boot into the live system, launch KDE Partition Manager, decrypt the LVM partition, then close and relaunch KDE Partition Manager. It should detect all of the LVM partitions. Do your resizing operations, apply them, then deactivate the LVM partition and reboot. I'm not sure how well this process is supported in similar graphical partition managers like gparted. Hopefully this saves future users some time when going through this process.

edit flag offensive delete link more
0

answered 2018-09-23 01:43:51 -0600

cmurf gravatar image

blivet-gui should be able to handle both LUKS and LVM.

edit flag offensive delete link more

Question Tools

3 followers

Stats

Asked: 2014-05-30 01:55:52 -0600

Seen: 9,163 times

Last updated: Sep 23 '18