LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-24-2023, 03:49 PM   #1
Janus84
Member
 
Registered: Sep 2019
Location: New Zealand
Distribution: Debian, Mint
Posts: 61

Rep: Reputation: Disabled
How to resize encrypted partition after SSD upgrade


Thanks for looking,
I have upgraded M.2 drive in my Debian laptop from 500G to 1TB using CloneZilla.
Now I have 500G unallocated and would like to extend my main LUKS partition to the remaining space.
Searching around I found rather confusing info, but understand the main concept.

Code:
$ lsblk
NAME                                          MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
loop0                                           7:0    0   1.6M  1 loop  /snap/modem-manager/426
loop1                                           7:1    0 116.8M  1 loop  /snap/core/14946
loop2                                           7:2    0 116.8M  1 loop  /snap/core/14784
loop3                                           7:3    0   1.6M  1 loop  /snap/modem-manager/516
nvme0n1                                       259:0    0 931.5G  0 disk  
├─nvme0n1p1                                   259:1    0   300M  0 part  /boot/efi
├─nvme0n1p2                                   259:2    0 459.8G  0 part  
│ └─luks-b933ced7-96d3-4f5b-87cd-780e5664aca4 254:0    0 459.8G  0 crypt /
└─nvme0n1p3                                   259:3    0  16.9G  0 part  
  └─luks-ad6d69c9-02a8-47a8-ba1e-6ee6132f3c51 254:1    0  16.9G  0 crypt [SWAP]
Code:
$ blkid /dev/nvme0n1 
/dev/nvme0n1: PTUUID="e93ed2ae-43e8-45b0-bc67-ec75b4918706" PTTYPE="gpt"
Code:
cat /etc/fstab
# <file system>             <mount point>  <type>  <options>  <dump>  <pass>
UUID=5A15-FFC1                            /boot/efi      vfat    defaults,noatime 0 2
/dev/mapper/luks-b933ced7-96d3-4f5b-87cd-780e5664aca4 /              ext4    defaults,noatime 0 1
/dev/mapper/luks-ad6d69c9-02a8-47a8-ba1e-6ee6132f3c51 swap           swap    defaults,noatime 0 2
 
Old 04-24-2023, 05:37 PM   #2
jamison20000e
Senior Member
 
Registered: Nov 2005
Location: ...uncanny valley... infinity\1975; (randomly born:) Milwaukee, WI, US( + travel,) Earth&Mars (I wish,) END BORDER$!◣◢┌∩┐ Fe26-E,e...
Distribution: any GPL that work on freest-HW; has been KDE, CLI, Novena-SBC but open.. http://goo.gl/NqgqJx &c ;-)
Posts: 4,888
Blog Entries: 2

Rep: Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567
I've never done it but what links did you find searching, maybe: resize encrypted Linux partition? The first one's outdated but definitely gives you some good starts to cross reference. Here's another example: https://unix.stackexchange.com/quest...etup-resize-do
also old but anyone who's (or not) done it, is just gonna show you what the manuals and searches told them?

Switching drives I'm sure you've backed up data, if you needed to... I'd just go for it and then come back if need be.

Last edited by jamison20000e; 04-25-2023 at 09:22 PM.
 
Old 04-24-2023, 06:54 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,125

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
For all those that continually bleat that LVM isn't appropriate for home users, take note. This is a piece of cake were LVM in place.

Regardless, the steps are basically the same as for a non-LUKS setup - and much easier than shrinking let it be known. Enlarge the partition, close and open the container, resize the filesystem. Add a few fsck for sanity.
In your case you'll have to get that swap out of the way - is it used for hibernation ?.
 
Old 04-25-2023, 03:38 PM   #4
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Fedora, OpenSUSE, FreeBSD, OpenBSD, macOS (hack). Past: Debian, Arch, RedHat (pre-RHEL).
Posts: 1,335
Blog Entries: 7

Rep: Reputation: 402Reputation: 402Reputation: 402Reputation: 402Reputation: 402
I would boot from a live distro, or a rescue system.

With the container *closed*, resize the partition, then the filesystem. Open the container (do *not* mount) and run fsck on the container device (/dev/mapper/luks-b933ced7-96d3-4f5b-87cd-780e5664aca4).

Using something like parted you could simply move that swap partition (warning: math will be involved), or any other tool delete and recreate it. Deleting and recreating will change the UUID and involve editing /etc/crypttab (or you may find you can no longer boot until it's fixed).

Last edited by goumba; 04-25-2023 at 03:39 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I copy encrypted files from my usb to an already encrypted partition? jackx2023 Linux - Newbie 3 03-19-2023 05:34 PM
Encrypted partition or file for running a virtual machine on am SSD? taylorkh Linux - Hardware 10 01-18-2017 10:15 AM
Access To Encrypted SSD Partition With Native Password in SSD>SATA Enclosure skidvicious Linux - Hardware 5 12-03-2015 04:40 PM
Shrink partition (LVM encrypted PVs + encrypted LVs) gedaj Linux - Newbie 2 05-22-2013 03:44 AM
LVM Resize - After logical resize, FS size does not match physical size. spectra Linux - Software 6 11-01-2006 11:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration