☰
Current Page
Main Menu
Home
Home
Editing
ResizeLUKS
Edit
Preview
h1
h2
h3
Keybinding
default
vim
emacs
Markup
Markdown
Plain Text
Pod
RDoc
reStructuredText
AsciiDoc
BibTeX
Creole
MediaWiki
Org-mode
Textile
Help 1
Help 1
Help 1
Help 2
Help 3
Help 4
Help 5
Help 6
Help 7
Help 8
Autosaved text is available. Click the button to restore it.
Restore Text
--- title: ResizeLUKS --- Resizing LUKS+LVM2+ext3 after replacing the harddisk with a larger one. [[_TOC_]] ## 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" ### New hardware * 160GB HDD (Seagate ST9160821A 5400rpm) ## Partition Maps To display: parted /dev/hda unit s p ### Old Partitions on old 80GB disk | # | name | Start | End | #Sectors | Size | Comment | |:-- | --------------- | --------- | --------- | -------- | ------- | ------------------------------- | | 1 | Apple | 1 | 63 | 63 | 31.5K | Apple partition map | | 2 | Macintosh | 64 | 119 | 56 | 28K | Apple_Driver43 | | 3 | Macintosh | 120 | 175 | 56 | 28K | Apple_Driver43 | | 4 | Macintosh | 176 | 231 | 56 | 28K | Apple\_Driver\_ATA | | 5 | Macintosh | 232 | 287 | 56 | 28K | Apple\_Driver\_ATA | | 6 | Macintosh | 288 | 799 | 512 | 256K | Apple_FWDriver | | 7 | Macintosh | 800 | 1311 | 512 | 256K | Apple\_Driver\_IOKit | | 8 | Patch Partition | 1312 | 1823 | 512 | 256K | Apple patch partition | | 9 | Untitled | 1824 | 41945088 | 41943265 | 20G | OS X root | | 10 | Shared | 41945089 | 111151104 | 69206016 | 33G | Shared ext3 | | 11 | bootstrap | 111151105 | 111152704 | 1600 | 800K | NewWorld bootblock | | 12 | boot | 111152705 | 111314943 | 162239 | 79.22M | /boot | | 13 | swap | 111314944 | 113282623 | 1967680 | 960.78M | swap | | 14 | linux | 113282624 | 156301487 | 43018864 | 20.51G | root, LUKS, LVM2 | ### Intermediate Old partitions on new 160GB disk with gaps for expansion | # | name | Start | End | #Sectors | Size | Comment | |:-- | --------------- | --------- | --------- | -------- | --------- | -------- | | 1 | Apple | 1 | 63 | 63 | 31.5K | | | 2 | Macintosh | 64 | 119 | 56 | 28K | | | 3 | Macintosh | 120 | 175 | 56 | 28K | | | 4 | Macintosh | 176 | 231 | 56 | 28K | | | 5 | Macintosh | 232 | 287 | 56 | 28K | | | 6 | Macintosh | 288 | 799 | 512 | 256K | | | 7 | Macintosh | 800 | 1311 | 512 | 256K | | | 8 | Patch Partition | 1312 | 1823 | 512 | 256K | | | 9 | OSX | 1824 | 41945088 | 41943265 | 20480.11M | | | | FREE | 41945089 | 83887903 | 41942815 | 20479.89M | | | 10 | Shared | 83887904 | 153093919 | 69206016 | 33792M | | | | FREE | 153093920 | 209717023 | 56623104 | 27648M | | | 11 | bootstrap | 209717024 | 209718623 | 1600 | 800K | | | 12 | boot | 209718624 | 209880862 | 162239 | 79.22M | | | | FREE | 209880863 | 209980767 | 99905 | 48.78M | | | 13 | swap | 209980768 | 212077919 | 2097152 | 1024.0M | new size | | 14 | linux | 212077920 | 255096783 | 43018864 | 21005.3M | | | | FREE | 255096784 | 312581807 | 57485024 | 28068.86M | | ### New New expanded partitions on new disk. | # | name | Start | End | #Sectors | Size | Comment | |:-- | --------------- | --------- | --------- | --------- | -------- | ------- | | 1 | Apple | 1 | 63 | 63 | 31.5K | | | 2 | Macintosh | 64 | 119 | 56 | 28.0K | | | 3 | Macintosh | 120 | 175 | 56 | 28.0K | | | 4 | Macintosh | 176 | 231 | 56 | 28.0K | | | 5 | Macintosh | 232 | 287 | 56 | 28.0K | | | 6 | Macintosh | 288 | 799 | 512 | 256.0K | | | 7 | Macintosh | 800 | 1311 | 512 | 256.0K | | | 8 | Patch Partition | 1312 | 1823 | 512 | 256.0K | | | 9 | OSX | 1824 | 41945088 | 41943265 | 20480.1M | | | 10 | OSX-2 | 41945089 | 83887903 | 41942815 | 20479.9M | | | 11 | Shared | 83887904 | 209717023 | 125829120 | 60.0M | | | 12 | bootstrap | 209717024 | 209718623 | 1600 | 800.0K | | | 13 | boot | 209718624 | 209980767 | 262144 | 128.0M | | | 14 | swap | 209980768 | 212077919 | 2097152 | 1024.0M | | | 15 | linux | 212077920 | 312581807 | 100503888 | 47.9M | | In moving from 80GB to 160GB: * OSX is expanding[1][21] 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 ## Process ### 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. ### 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 ### 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 ### Enlarge shared Use parted to extend the ext3 partition and fs `parted /dev/hda unit s resize 10 83887904 209717023` ### Enlarge boot Use parted to extend the ext3 partition and fs `parted /dev/hda unit s resize 12 209718624 209980767` That was easy. ### Enlarge swap Nothing to do, the encrypted swap gets recreated on each boot. So just resize the partition. ### 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` ### 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. [21]: #fn1_1 <!-- vim: filetype=markdown -->
Uploading file...
Sidebar
# SideBar * [Home][1] * [Projects][2] * * * <!-- --> * [Code][3] * [Tech][4] * [Network][5] * [MediaCentre][6] * [UAV][7] * * * <!-- --> * [Travel][8] * [Music][9] * [Horse Riding][10] * [Study][11] * [Games][12] * [Other Activities][13] * * * <!-- --> * [Car][14] * [House][15] * [Watch][16] * [Clothing][17] * [Miscellany][18] * * * [1]: /Home [2]: /Projects [3]: /Code/Code [4]: /Tech/Tech [5]: /Network/Network [6]: /MediaCentre/MediaCentre [7]: /UAV/UAV [8]: /Travel/Travel [9]: /Music/Music [10]: /HorseRiding/HorseRiding [11]: /Study/Study [12]: /Games/Games [13]: /Do/Do [14]: /Car/Car [15]: /House/House [16]: /Watch/Watch [17]: /Clothing/Clothing [18]: /Miscellany/Miscellany <!-- vim: filetype=markdown -->
Edit message:
Cancel