I have installed elementaryOS in the entire disk of my girlfriend's netbook using LVM. Now I want to install Manjaro XFCE instead of eOS, but I have come to the problem that the auto LVM partitioning that I use when installing eOS makes use of all the space in the disk, instead of separating the /home and / (I guess Fedora installer does something like that automatically). What I want to do is create a LV/partition of 25Gb using the free space on that LV and leave the rest to the /home itself, so I don't have to format the entire disk and lose all the important data.

This is my output of pvdisplay:

--- Physical volume ---
PV Name               /dev/sda5
VG Name               elementary-vg
PV Size               148.81 GiB / not usable 2.00 MiB
Allocatable           yes (but full)
PE Size               4.00 MiB
Total PE              38095
Free PE               0
Allocated PE          38095
PV UUID               E6FkuA-qK2X-1lP5-XCRX-t4x3-U2xn-EqjSBg


--- Volume group ---
VG Name               elementary-vg
System ID             
Format                lvm2
Metadata Areas        1
Metadata Sequence No  3
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                2
Open LV               0
Max PV                0
Cur PV                1
Act PV                1
VG Size               148.81 GiB
PE Size               4.00 MiB
Total PE              38095
Alloc PE / Size       38095 / 148.81 GiB
Free  PE / Size       0 / 0   
VG UUID               wfV8tN-uvVa-ARcS-3MWU-9gBr-vzMd-Tgp5Av


--- Logical volume ---
LV Path                /dev/elementary-vg/root
LV Name                root
VG Name                elementary-vg
LV UUID                pAyHGC-e8J3-AdWM-uwPX-cP5j-0qZt-RsVPtl
LV Write Access        read/write
LV Creation host, time elementary, 2016-05-15 19:33:59 +0000
LV Status              available
# open                 0
LV Size                147.82 GiB
Current LE             37841
Segments               1
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           254:0

--- Logical volume ---
LV Path                /dev/elementary-vg/swap_1
LV Name                swap_1
VG Name                elementary-vg
LV UUID                PDkMDH-z6GN-CDHW-5jv9-JnF3-XIoZ-NnFNnX
LV Write Access        read/write
LV Creation host, time elementary, 2016-05-15 19:34:00 +0000
LV Status              available
# open                 0
LV Size                1016.00 MiB
Current LE             254
Segments               1
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           254:1

Is this possible?

  • I'd recommend just doing this with gparted (there are bootable CD's available for this). If I understand the question correctly, then yes, this is possible. It's just kinda painful to do disk management via a command line in my experience. I'd like to ask why you can't just use primary partitions since you don't need more than four. – Wyatt8740 Jul 29 '16 at 17:17
  • Hi. I want to use LVM because i think is more flexible due to the small size of a root partition (25 gb or so) maybe in a future i'll need to grow up that partition. Sorry about my english, is not my native language. I'm currently on manjaro live USB, but Gparted doesn't let me reduce the LVM size. imgur.com/a/FAnip – gabo Jul 29 '16 at 17:33
  • I'd just delete the partition table and go from the ground up. But that screenshot certainly DOES show that it'll let you shrink it. – Wyatt8740 Jul 29 '16 at 17:48

Metaphor time: you have boxes (logical volumes) on a shelf (disk). You have a small box and a big box and together they take up all the shelf space. You want to put a third box on the shelf. The big box is almost empty. Well, you can't just use the space inside the big box to put another box next to it. But you can transfer the content of the big box into a smaller box, and with that smaller box on the shelf you'll have room for a third box.

LVM makes things easier: its boxes can be resized. You can shrink the root logical volume to make space for another volume.

But before you do that, you need to shrink the filesystem inside the volume. Shrink the filesystem before you shrink the volume! Otherwise the filesystem will be irretrievably corrupted.

As far as I know, elementary OS uses the ext4 filesystem by default. You can shrink an ext4 filesystem, but only while it isn't mounted. So you need to boot from some recovery media to run resize2fs:

resize2fs /dev/elementary-vg/root 25G

Now you can shrink the logical volume to the same size. Beware that in LVM, G means 109 bytes, you need a lowercase g to mean 2^30 like with resize2fs.

lvreduce -L 25g elementary-vg/root

There is now free space on the volume group to create a new logical volume. I suggest leaving a bit of free space on the disk for now, this way you can decide later to use it for / or /home depending on which one gets filled faster.

lvcreate -L 80g -n home elementary-vg
mkfs.ext4 /dev/elementary-vg/home

Now move the data that you already have in /home to the new volume. It's easiest to do this still from the recovery system.

mkdir /mnt/root /mnt/home
mount /dev/elementary-vg/home /mnt/home
mount /dev/elementary-vg/root /mnt/root
mv /mnt/root/home/* /mnt/home/
echo '/dev/elementary-vg/home /home ext4 errors=remount-ro 0 2' >>/mnt/root/etc/fstab

Voilà, you can reboot into your system.

  • you rock! That's a well elaborated response, also very didactic examples right there. – gabo Jul 30 '16 at 4:24

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.