You are not logged in.

#1 2013-02-16 06:59:10

synthead
Member
Registered: 2006-05-09
Posts: 1,345

Resizing a logical partition with a LUKS container

I have a logical partition that contains LUKS which holds an LVM2 schema.  My goal is to resize the existing logical partition so I can create other partitions in their own LUKS-encrypted container.  So far, the LVM2 PV is resized and I'm looking for advice on how to handle shrinking the LUKS container and the logical partition it lives on.

I heard rumors that LUKS containers don't need to be resized and that I can change the size of the block device it lives on without problems.  Is this true?  If so, it seems like I should be able to delete the logical partition and replace it with a smaller one as usual.  How can I calculate the blocks/sectors/etc for the new partition with the LUKS & LVM2 data on there?

Last edited by synthead (2013-02-16 07:42:02)

Offline

#2 2013-02-16 07:02:13

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: Resizing a logical partition with a LUKS container

We would need more information about your partitions and volumes. If the entire partition is encrypted, then you should only need to change the sizes of the logical volumes, the LUKS container shouldn't require resizing...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2013-02-16 07:21:47

synthead
Member
Registered: 2006-05-09
Posts: 1,345

Re: Resizing a logical partition with a LUKS container

Yeah, the entire logical partition is formatted as LUKS.  So I should be able to delete the partition and create a replacement with a smaller size?  How can I calculate the new size I'd need for the logical partition?

Offline

#4 2013-02-16 07:27:52

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: Resizing a logical partition with a LUKS container

Once again, without any specific information (despite having asked for it); you don't need to delete the partition-- that is the entire point of LVM on LUKS, you just resize your volumes.

Unless, and I am guessing (see first point), you want to resize the entire partition, in which case the above advice does not apply, and your thread title is completely misleading.

For someone who has been around these boards a long time, you haven't learned much about How To Ask Questions The Smart Way...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#5 2013-02-16 07:41:48

synthead
Member
Registered: 2006-05-09
Posts: 1,345

Re: Resizing a logical partition with a LUKS container

Sorry about that, I edited my original post smile  Yes, I will not be using the existing LVM2 structure for the new partitions; I'm going to create another partition, LUKS container, and whatever else when this is sorted.

Offline

#6 2013-02-16 08:43:53

synthead
Member
Registered: 2006-05-09
Posts: 1,345

Re: Resizing a logical partition with a LUKS container

Running into a new problem:

# fdisk /dev/sda
Welcome to fdisk (util-linux 2.22.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p

Disk /dev/sda: 128.0 GB, 128035676160 bytes, 250069680 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 identifier: 0x0005c24e

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      499711      248832   83  Linux
/dev/sda2          501758   250068991   124783617    5  Extended
/dev/sda5          501760   250068991   124783616   83  Linux

Command (m for help): d
Partition number (1-5): 5
Partition 5 is deleted

Command (m for help): p

Disk /dev/sda: 128.0 GB, 128035676160 bytes, 250069680 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 identifier: 0x0005c24e

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      499711      248832   83  Linux
/dev/sda2          501758   250068991   124783617    5  Extended

Command (m for help): n
Partition type:
   p   primary (1 primary, 1 extended, 2 free)
   l   logical (numbered from 5)
Select (default p): l
Adding logical partition 5
First sector (503806-250068991, default 503808): 501760
Value out of range.

Why can't I create a partition on the same starting sector as before?

Offline

Board footer

Powered by FluxBB