Skip to contentSkip to conversation

moving/resizing a dm-crypt partition

dm-crypt Louis-David Mitterrand 4 participants 8 messages Jan 30, 2014 – Jan 31, 2014

lore
Share & tools
lore
#0 lore raw

Hi,

My linux system is on a dm-crypt volume with btrfs on /dev/sda6. As I just recovered 100GB from windows (/dev/sda5) I'd like to merge 5 and 6 to have a larger dm-crypt volume. Here is the disk layout:

   1            2048         2050047   1000.0 MiB  2700  Basic data partition
   2         2050048         2582527   260.0 MiB   EF00  EFI system partition
   3         2582528         4630527   1000.0 MiB  8300  Basic data partition
   4         4630528         4892671   128.0 MiB   0C01  Microsoft reserved part
   5         4892672       218167295   101.7 GiB   8300  Basic data partition
   6       464865280      1000215182   255.3 GiB   8300  Linux filesystem

What is the best strategy to acheive that? I'm thinking of booting a live cd, creating a new dm-crypt volume on 5, copy the system from 6 to 5, remove 6, resize partition 5, cryptfs resize 5, btrfs resize 5.

Is there a better way?

Thanks,

#1 lore raw

Hi,

potentially you could 'keep' your old luks header and copy it over (backup+restore) to the new partition, if you plan on keeping masterkey, passwords, uuid.

Is there a better way? Depends on what you call better?

faster/safer?

Imho your plan should be the safest version and that's probably what you want, esp. if part. 5 has enough space to hold what's on part 6 (So you would have your data twice just to make sure everythink is okay.

If you want to be safer: Make another backup on an extra storage device before resizing part5. I am not sure how stable btrfs is.

Regards

-Sven

Quoted 30 lines · Louis-David Mitterrand

Hi,

My linux system is on a dm-crypt volume with btrfs on /dev/sda6. As I just recovered 100GB from windows (/dev/sda5) I'd like to merge 5 and 6 to have a larger dm-crypt volume. Here is the disk layout:

   1            2048         2050047   1000.0 MiB  2700  Basic data

partition
2 2050048 2582527 260.0 MiB EF00 EFI system
partition
3 2582528 4630527 1000.0 MiB 8300 Basic data
partition
4 4630528 4892671 128.0 MiB 0C01 Microsoft
reserved part
5 4892672 218167295 101.7 GiB 8300 Basic data
partition
6 464865280 1000215182 255.3 GiB 8300 Linux filesystem

What is the best strategy to acheive that? I'm thinking of booting a live cd, creating a new dm-crypt volume on 5, copy the system from 6 to 5, remove 6, resize partition 5, cryptfs resize 5, btrfs resize 5.

Is there a better way?

Thanks,
_______________________________________________
dm-crypt mailing list
[email protected]
http://www.saout.de/mailman/listinfo/dm-crypt

#2 lore raw
In reply to Louis-David Mitterrand
Quoted 13 lines · Louis-David Mitterrand

Hi,

My linux system is on a dm-crypt volume with btrfs on /dev/sda6. As I just recovered 100GB from windows (/dev/sda5) I'd like to merge 5 and 6 to have a larger dm-crypt volume. Here is the disk layout:

   1            2048         2050047   1000.0 MiB  2700  Basic data partition
   2         2050048         2582527   260.0 MiB   EF00  EFI system partition
   3         2582528         4630527   1000.0 MiB  8300  Basic data partition
   4         4630528         4892671   128.0 MiB   0C01  Microsoft reserved part
   5         4892672       218167295   101.7 GiB   8300  Basic data partition
   6       464865280      1000215182   255.3 GiB   8300  Linux filesystem
Quoted 3 lines

What is the best strategy to acheive that? I'm thinking of booting a live cd, creating a new dm-crypt volume on 5, copy the system from 6 to 5, remove 6, resize partition 5, cryptfs resize 5, btrfs resize 5.

As it is BTRFS, just create a second dm-crypt volume and add that to the existing BTRFS. As BTRFS can span several physical volumes, creating one big partition isn't strictly necessary.
If you use the same password and have "luck" that your dm-crypt setup-script in initrd/initramsfs opens both dm-crypt devices in one go, there shouldn't even be any discomfort by that solution.

Signature · 1 line
Matthias
#3 lore raw
Quoted 7 lines · Matthias Schniedermeyer

As it is BTRFS, just create a second dm-crypt volume and add that to the existing BTRFS. As BTRFS can span several physical volumes, creating one big partition isn't strictly necessary.
If you use the same password and have "luck" that your dm-crypt setup-script in initrd/initramsfs opens both dm-crypt devices in one go, there shouldn't even be any discomfort by that solution.

Hi,

This is an interesting solution, I didn't know about btrfs's spanning capabilities.

As you point out the key is having initrd unlock both partitions and I'm not sure how to do it. So in the end I chose the "hard" solution of merging both partitions (with a backup), which went well.

Thanks,

#4 lore raw
Quoted 9 lines · Louis-David Mitterrand
Quoted 7 lines · Matthias Schniedermeyer

As it is BTRFS, just create a second dm-crypt volume and add that to the existing BTRFS. As BTRFS can span several physical volumes, creating one big partition isn't strictly necessary.
If you use the same password and have "luck" that your dm-crypt setup-script in initrd/initramsfs opens both dm-crypt devices in one go, there shouldn't even be any discomfort by that solution.

Quoted 4 lines

Hi,

This is an interesting solution, I didn't know about btrfs's spanning capabilities.

BTRFS is like ZFS in that regard, it supports what someone described as:
"blatant layering violations".

But that has also some nice site-effects. You can for e.g. set RAID-level either per subvolume (BTRFS has it's own LVM implementation) or down to per file. I'm not quite sure what it was (or will be). And that can be changed at run-time and BTRFS will perform the necessary "rebalancing" to achieve want you told it you wanted (either now or in the future).

And if you ever read the description of Microsoft's latest filesystem "ReFS" you feel like reading a description of the feature-set of BTRFS or ZFS.

Quoted 3 lines

As you point out the key is having initrd unlock both partitions and I'm not sure how to do it. So in the end I chose the "hard" solution of merging both partitions (with a backup), which went well.

Which is the better solution, less "historic cruft" to drag around.

Signature · 1 line
Matthias
#5 lore raw
In reply to Louis-David Mitterrand
Quoted 13 lines · Louis-David Mitterrand

Hi,

My linux system is on a dm-crypt volume with btrfs on /dev/sda6. As I just recovered 100GB from windows (/dev/sda5) I'd like to merge 5 and 6 to have a larger dm-crypt volume. Here is the disk layout:

   1            2048         2050047   1000.0 MiB  2700  Basic data partition
   2         2050048         2582527   260.0 MiB   EF00  EFI system partition
   3         2582528         4630527   1000.0 MiB  8300  Basic data partition
   4         4630528         4892671   128.0 MiB   0C01  Microsoft reserved part
   5         4892672       218167295   101.7 GiB   8300  Basic data partition
   6       464865280      1000215182   255.3 GiB   8300  Linux filesystem
Quoted 5 lines

What is the best strategy to acheive that? I'm thinking of booting a live cd, creating a new dm-crypt volume on 5, copy the system from 6 to 5, remove 6, resize partition 5, cryptfs resize 5, btrfs resize 5.

Is there a better way?

Yes, most decidedly: Make a full backup of everything you want to keep on 6, remove 5 and 6, create what you want in its place and restore the backup.
You may also do a full backup of the rest of the disk, mistakes and error happen.

As backup is mandatory anyways, this shoud not cause much more trouble than an ordinary backup.

You are running a pretty high risk of losing everything on 6 with your approach.

Arno

Signature · 4 lines
Arno Wagner,     Dr. sc. techn., Dipl. Inform.,    Email: [email protected]
GnuPG: ID: CB5D9718  FP: 12D6 C03B 1B30 33BB 13CF  B774 E35C 5FA1 CB5D 9718
----
A good decision is based on knowledge and not on numbers. -  Plato
#6 lore raw
Quoted 7 lines · Arno Wagner

Yes, most decidedly: Make a full backup of everything you want to keep on 6, remove 5 and 6, create what you want in its place and restore the backup.
You may also do a full backup of the rest of the disk, mistakes and error happen.

Quoted 5 lines

As backup is mandatory anyways, this shoud not cause much more trouble than an ordinary backup.

You are running a pretty high risk of losing everything on 6 with your approach.

Hi Arno,

I did a tar.gz backup before proceeding but in the end all went well. The hairy part (I guess) is deleting both partitions to create a new, larger one without damaging the dm-crypt volume.

I resized the dm-crypt volume offline, without mounting the fs, but is it possible to do it on a live, mounted system?

Thanks,

#7 lore raw
Quoted 14 lines · Louis-David Mitterrand
Quoted 7 lines · Arno Wagner

Yes, most decidedly: Make a full backup of everything you want to keep on 6, remove 5 and 6, create what you want in its place and restore the backup.
You may also do a full backup of the rest of the disk, mistakes and error happen.

Quoted 5 lines

As backup is mandatory anyways, this shoud not cause much more trouble than an ordinary backup.

You are running a pretty high risk of losing everything on 6 with your approach.

Quoted 8 lines

Hi Arno,

I did a tar.gz backup before proceeding but in the end all went well. The hairy part (I guess) is deleting both partitions to create a new, larger one without damaging the dm-crypt volume.

I resized the dm-crypt volume offline, without mounting the fs, but is it possible to do it on a live, mounted system?

Only in the case where you don't change the start of the partition. So in your case: No

And i'm not sure if it is fixed/changed, but at least historically Linux doesn't reread a changed partition table if any partition is currently "in use". If that is still unchanged, you could change the MBR, but Linux wouldn't change the in-memory representation. So you couldn't enlarge the underlaying partition(/block-device), without making the whole block-device "unused" first, which is kind of hard for a device with the root-partition. :-)

Signature · 1 line
Matthias