Tech /

Resize LUKS





edit SideBar

Resize LUKS

Resizing LUKS+LVM2?+ext3 after replacing the harddisk with a larger one.

1.  Setup

  • Aluminium Powerbook 1.25GHz 15" (Powerboook5,2)
  • 80GB HDD (Fujitsu MHT2080AT? 4200rpm)
  • /dev/hda14 LUKS partition "cryptroot"
  • LVM2? volume group "vgroot" on "cryptroot"
  • LVM2? logical volumes "lvroot" "lvhome" "lvtmp" "lvusr" "lvvar" on "vgroot"

1.1  New hardware

2.  Partition Maps

To display:

  parted /dev/hda unit s p 

2.1  Old

Partitions on old 80GB disk

#nameStartEnd#SectorsSizeComment
1Apple1636331.5KApple partition map
2Macintosh641195628KApple_Driver43
3Macintosh1201755628KApple_Driver43
4Macintosh1762315628KApple_Driver_ATA
5Macintosh2322875628KApple_Driver_ATA
6Macintosh288799512256KApple_FWDriver
7Macintosh8001311512256KApple_Driver_IOKit
8Patch Partition13121823512256KApple patch partition
9Untitled1824419450884194326520GOS X root
10Shared419450891111511046920601633GShared ext3
11bootstrap1111511051111527041600800KNewWorld? bootblock
12boot11115270511131494316223979.22M/boot
13swap1113149441132826231967680960.78Mswap
14linux1132826241563014874301886420.51Groot, LUKS, LVM2?

2.2  Intermediate

Old partitions on new 160GB disk with gaps for expansion

#nameStartEnd#SectorsSizeComment
1Apple1636331.5K 
2Macintosh641195628K 
3Macintosh1201755628K 
4Macintosh1762315628K 
5Macintosh2322875628K 
6Macintosh288799512256K 
7Macintosh8001311512256K 
8Patch Partition13121823512256K 
9OSX1824419450884194326520480.11M 
 FREE41945089838879034194281520479.89M 
10Shared838879041530939196920601633792M 
 FREE1530939202097170235662310427648M 
11bootstrap2097170242097186231600800K 
12boot20971862420988086216223979.22M 
 FREE2098808632099807679990548.78M 
13swap20998076821207791920971521024.0Mnew size
14linux2120779202550967834301886421005.3M 
 FREE2550967843125818075748502428068.86M 

2.3  New

New expanded partitions on new disk.

#nameStartEnd#SectorsSizeComment
1Apple1636331.5K 
2Macintosh641195628.0K 
3Macintosh1201755628.0K 
4Macintosh1762315628.0K 
5Macintosh2322875628.0K 
6Macintosh288799512256.0K 
7Macintosh8001311512256.0K 
8Patch Partition13121823512256.0K 
9OSX1824419450884194326520480.1M 
10OSX-241945089838879034194281520479.9M 
11Shared8388790420971702312582912060.0M 
12bootstrap2097170242097186231600800.0K 
13boot209718624209980767262144128.0M 
14swap20998076821207791920971521024.0M 
15linux21207792031258180710050388847.9M 

In moving from 80GB to 160GB:

  • OSX is expanding1 from 20GiB to 40GiB
  • Shared is expanding from 33GiB to 60GiB
  • /boot is expanding from 80MiB to 128MiB
  • swap is expanding from 960MiB to 1024MiB
  • root is expanding from 20GiB to ~50GiB

3.  Process

3.1  Overview

Migrate data from dying 80GB disk to new 160GB disk, keeping data intact including LUKS partition with LVM2? inside. Resize partitions to take advantage of the bigger disk.

3.2  Download Finnix

http://www.finnix.org/

Burn to CD and boot.

wget http://www.finnix.org/releases/90.0/finnix-ppc-90.0.iso
cdrecord -v dev=/dev/cdrw ./finnix-ppc-90.0.iso

3.3  Create partitions

Create partitions of the same size (but not necessarily at the same start sector) on new disk manually with parted.

Creating a new partition:

# parted /dev/hda
(parted) unit s
(parted) mkpart root START_SECTOR END_SECTOR

START_SECTOR and END_SECTOR same as old partition map

"unit s" tells parted to work in sector-sized units

Sectors are 512 bytes

3.4  Enlarge shared

Use parted to extend the ext3 partition and fs

parted /dev/hda unit s resize 10 83887904 209717023

3.5  Enlarge boot

Use parted to extend the ext3 partition and fs

parted /dev/hda unit s resize 12 209718624 209980767

That was easy.

3.6  Enlarge swap

Nothing to do, the encrypted swap gets recreated on each boot. So just resize the partition.

3.7  Enlarge root

Decrypt

cryptsetup luksOpen /dev/hda14 cryptroot

Activate volume group and logical volumes

vgchange -a y

Resize the physical volume

pvresize /dev/mapper/cryptroot

Enlarge the logical volumes

lvextend -L +10G vgroot/lvhome

3.8  Enlarge OS X

HFS+ can't be enlarged without a third-party utility.

So create a new partition instead. To be used as an encrypted Home partition through FileVault?.

parted /dev/hda unit s mkpart 41945089 83887903

Did this last because I wasn't sure if it would shift all the partition numbers off.

It didn't. The new OSX partition became /dev/hda15.

Recent Changes (All) | Edit SideBar Page last modified on 03 November 2008, at 12:02 PM UTC Edit Page | Page History
Powered by PmWiki