Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Kernel & Hardware
  • Search

Growing a LUKS partition into preceding free disk space?

Kernel not recognizing your hardware? Problems with power management or PCMCIA? What hardware is compatible with Gentoo? See here. (Only for kernels supported by Gentoo.)
Post Reply
Advanced search
6 posts • Page 1 of 1
Author
Message
leyvi
l33t
l33t
Posts: 719
Joined: Fri Sep 08, 2023 1:22 pm

Growing a LUKS partition into preceding free disk space?

  • Quote

Post by leyvi » Tue Sep 30, 2025 9:55 am

I created a swap partition, but later decided to use btrfs swap features instead, and deleted my swap partition. I want to merge the free space into an existing LUKS partition, only the free space is before the root partition, not after, so I don't know what to do.
Top
NeddySeagoon
Administrator
Administrator
User avatar
Posts: 56087
Joined: Sat Jul 05, 2003 9:37 am
Location: 56N 3W

  • Quote

Post by NeddySeagoon » Tue Sep 30, 2025 10:10 am

leyvi,

A word of advice. Don't.
If you really made a LUKS volume on the partition, you need to back up your data , verify the backup. Make and veryify another copy.
Now you can destroy the partiton and its content, fix it and restore your data.

There are tools that claim to move partition content forward but if they hit problems or get interupted your filesystem is gone, so you need the backup anyway.

If you put LUKS inside a LVM volume group, LVM can add the space before the partition start to the Volume Group.

Have you thought about using what was the swap partition for another filesystem?
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Top
Hu
Administrator
Administrator
Posts: 24391
Joined: Tue Mar 06, 2007 5:38 am

  • Quote

Post by Hu » Tue Sep 30, 2025 12:53 pm

This is a follow-on to Resize a LUKS partition?. OP decided to repost the question when [post]8871003[/post] was not answered quickly.
Top
leyvi
l33t
l33t
Posts: 719
Joined: Fri Sep 08, 2023 1:22 pm

  • Quote

Post by leyvi » Tue Sep 30, 2025 5:35 pm

NeddySeagoon wrote:If you really made a LUKS volume on the partition, you need to back up your data , verify the backup. Make and veryify another copy.
Now you can destroy the partiton and its content, fix it and restore your data.
Would I use dd for this? Or some specialized tool for backing up a LUKS partition? Or should I use btrfs snapshotting to make a backup of the filesystem, move it to an external drive, rework the partitions, copy the filesystem back, and GNU shred the external drive? What do you reccomend?
Top
NeddySeagoon
Administrator
Administrator
User avatar
Posts: 56087
Joined: Sat Jul 05, 2003 9:37 am
Location: 56N 3W

  • Quote

Post by NeddySeagoon » Fri Oct 03, 2025 11:02 am

leyvi,

Back up the files on the filesystem after it has been unlocked.
I don't know if LUKS uses any absolute sector addresses. If so, dd cannot work as they would need to be updated to be correct in their new home.
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Top
leyvi
l33t
l33t
Posts: 719
Joined: Fri Sep 08, 2023 1:22 pm

  • Quote

Post by leyvi » Sun Oct 05, 2025 1:05 pm

I dug a bit deeper, and found this. It worked perfectly first try. If you're reading this thread for informative purposes, I recommend making heavy use of sfdisk's --list and --list-free options as well, and triple-checking the values you pass to sfdisk before you run it. Also, I did back up my data beforehand (I just tarballed the etc directory and scp'd it onto my phone, since that's all I really cared about).
Top
Post Reply

6 posts • Page 1 of 1

Return to “Kernel & Hardware”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic