You are not logged in.

#1 2014-04-22 17:55:30

rand_x0r
Member
Registered: 2014-04-22
Posts: 17

Moving and resizing LVM on LUKS

Hello, this is my first thread here, so don't be too hard on me please smile.
So i've installed Arch on LVM in a LUKS container, but now I want to resize my home.
The layout is as follows:
├─sda4                 8:4    0   174G  0 part 
└─sda5                 8:5    0 171.7G  0 part 
  └─main             254:0    0 171.7G  0 crypt
    ├─lvm_crgrp-base 254:1    0  53.1G  0 lvm   /
    ├─lvm_crgrp-swap 254:2    0   7.7G  0 lvm   [SWAP]
    ├─lvm_crgrp-tmp  254:3    0   3.8G  0 lvm   /tmp
    ├─lvm_crgrp-var  254:4    0    14G  0 lvm   /var
    └─lvm_crgrp-home 254:5    0  93.1G  0 lvm   /home

sda5 is an logical volume of sda3 which is an extended partition.

https://i.imgur.com/6qpbN2z.png

I want to use the space in sda4 to enlarge my home partition.
I am thinking of perhaps copying sda5 to sda4 with just dd without touching the partition table,
then deleting sda5, setting the new UUID, resizing sda4, then resizing the main group and then the home volume, then its ext4.

Will that work?
Also is there a better/faster/cleaner way to do it?

Also in an LVM does the order matter?
For example if I enlarge the main group, can I enlarge whatever volume I want in it or does it matter where the free space is physically?

I know I can use crypttab to mount sda4 in home as for example /home/x0r/storage but I'd rather enlarge my lvm smile



-- mod edit: read the Forum Etiquette and only post thumbnails http://wiki.archlinux.org/index.php/For … s_and_Code [jwr] --

Last edited by rand_x0r (2014-04-22 19:21:19)

Offline

#2 2014-04-23 05:43:09

Gcool
Member
Registered: 2011-08-16
Posts: 1,456

Re: Moving and resizing LVM on LUKS

Welcome to the forums.

Give this a read.


Burninate!

Offline

#3 2014-04-23 11:16:08

clfarron4
Member
From: London, UK
Registered: 2013-06-28
Posts: 2,162
Website

Re: Moving and resizing LVM on LUKS

Gcool wrote:

Welcome to the forums.

Give this a read.

That's not going to work because all 171GB of the LUKS partitions are all ready used, unless you can grow LUKS partitions themselves.

@rand_x0r: My guess is that you want /home to be encrypted as well, right?


Claire is fine.
Problems? I have dysgraphia, so clear and concise please.
My public GPG key for package signing
My x86_64 package repository

Offline

#4 2014-04-23 13:03:47

ANOKNUSA
Member
Registered: 2010-10-22
Posts: 2,141

Re: Moving and resizing LVM on LUKS

clfarron4 wrote:

That's not going to work because all 171GB of the LUKS partitions are all ready used, unless you can grow LUKS partitions themselves.

https://duckduckgo.com/?q=resize+luks+lvm

It's totally possible, but it's tedious and involves a fairly large risk of destroying data and/or leaving a filesystem improperly encrypted. You should always back up your data when doing something like this; it's probably easier (and possibly faster) to just make a full-system backup, then boot into a LiveCD, go through the LUKS + LVM setup again, mount the logical volumes and restore the backup.

Out of curiosity, how did you partition your drive? Did you follow a guide somewhere? By default, /tmp is mounted as a ramdisk, and I don't see the point in having a separate /tmp partition in any case. A separate /var partition seems unnecessary to me, to, though you might have a reason for it.

Offline

#5 2014-04-23 13:53:31

frostschutz
Member
Registered: 2013-11-15
Posts: 429

Re: Moving and resizing LVM on LUKS

rand_x0r wrote:

I want to use the space in sda4 to enlarge my home partition.

luksFormat sda4, then pvcreate the sda4luks, then vgextend, lvextend with the sda4luks PV.

That would be the simplest solution (in terms of no data need be moved), except you end up with two distinct LUKS containers, both of which have to be opened at boot time.

That is a configuration issue (do some background reading in the Wiki https://wiki.archlinux.org/index.php/Dm-crypt). There are various solutions to choose, ranging from simply entering multiple passphrases at boot, to decrypt_derived (using the master key of one container as the password for another), or keyfiles stored somewhere, and possibly encrypting the keyfiles themselves.


If you do want to move the data though, the dd should work fine, since sda4 seems to be larger than sda5. You'd have to do that from a livecd where nothing is mounted.

Last edited by frostschutz (2014-04-23 13:57:15)

Offline

#6 2014-04-23 20:45:26

rand_x0r
Member
Registered: 2014-04-22
Posts: 17

Re: Moving and resizing LVM on LUKS

Hello all,
regarding what I asked about, I've found this https://help.ubuntu.com/community/Resiz … Partitions
So the question now is about moving. If I dd sda5 to sda4 will I have to set something up for it work? Like some offsets/adresses?
If I am able to move sda5 to sda4, the rest will be fairly easy. Any about my partitiong layout - it's manual, I've used fdisk, cryptsetup, mkfs and the lvm tools that come with the arch install iso.
Also some have misunderstood - currently everything but the boot partition, which is on another drive, is encrypted - in one LUKS partition and inside it there is an LVM with the different partitions.

I've tested on a virtual machine by doing the following:
unmount partitions
move the luks partition by using dd with opts bs=4096 conv=notrunc,noerror,sync
after that follow https://help.ubuntu.com/community/Resiz … Partitions
Worked like a charm(if you need to remove mappers use dmsetup).
After that: the uuid's of the lvm's are the same so that's cool. Just need to get the UUID of the new luks partition and set it in grub's cryptroot parameter.
That's all smile
Still I think I will backup everything first, then I will try this.

Last edited by rand_x0r (2014-04-23 22:20:00)

Offline

Board footer

Powered by FluxBB