Welcome, Guest. Please login or register.
Did you miss your activation email?

Author Topic: [EN] Move encrypted partition to the beginning of the disk  (Read 5370 times)

Offline michaaa62

  • User
  • Posts: 299
[EN] Move encrypted partition to the beginning of the disk
« on: 2016/03/05, 01:40:19 »
My backup partition of an external disk is finally becoming almost full. During partitioning i reserved some space, just in case, for a NTFS partition for MS systems. Later used it for Owncloud, that now has its own disk.

This is the current setup:
Code: [Select]
root@majestix:~# fdisk -l /dev/sdb
Disk /dev/sdb: 2,7 TiB, 3000592982016 bytes, 732566646 sectors
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x000045cd

Device     Boot    Start       End   Sectors  Size Id Type
/dev/sdb1             63  24900749  24900687   95G  7 HPFS/NTFS/exFAT
/dev/sdb2       24900864 732566527 707665664  2,7T  5 Extended
/dev/sdb5       24901120 732566527 707665408  2,7T 83 Linux

root@majestix:/home/micha# lsblk /dev/sdb
NAME              MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINT
sdb                 8:16   0  2,7T  0 disk
├─sdb1              8:17   0   95G  0 part
│ └─owncloud      253:0    0   95G  0 crypt
├─sdb2              8:18   0    4K  0 part
└─sdb5              8:21   0  2,7T  0 part
  └─intenso_crypt 253:1    0  2,7T  0 crypt /media/intenso

I do not have enough storage space to scrape all the data from the disk for a clean setup.
Is it possible to dd the content of /dev/sdb5 partially to /dev/sdb1 like this:
Code: [Select]
dd if=/dev/sdb5 of=/dev/sdb1 bs=4096 count=24900687
dd if=/dev/sdb of=/dev/sdb bs=4096 count=24900687 skip=49801807 seek=24900749
dd if=/dev/sdb of=/dev/sdb bs=4096 count=24900687 skip=74702494 seek=49801436
dd if=/dev/sdb of=/dev/sdb bs=4096 count=24900687 skip=99603181 seek=74702123
dd if=/dev/sdb of=/dev/sdb bs=4096 count=24900687 skip=124503868 seek=99602810
dd if=/dev/sdb of=/dev/sdb bs=4096 count=24900687 skip=149404555 seek=124503497
dd if=/dev/sdb of=/dev/sdb bs=4096 count=24900687 skip=174305242 seek=149404184
dd if=/dev/sdb of=/dev/sdb bs=4096 count=24900687 skip=199205929 seek=174304871
dd if=/dev/sdb of=/dev/sdb bs=4096 count=24900687 skip=224107049 seek=199205558
dd if=/dev/sdb of=/dev/sdb bs=4096 count=24900687 skip=249007736 seek=224106245
dd if=/dev/sdb of=/dev/sdb bs=4096 count=24900687 skip=273,908,423 seek=249006932
dd if=/dev/sdb of=/dev/sdb bs=4096 count=24900687 skip=298,809,110 seek=273907619
dd if=/dev/sdb of=/dev/sdb bs=4096 count=24900687 skip=323,709,797 seek=298808306
dd if=/dev/sdb of=/dev/sdb bs=4096 count=24900687 skip=348,610,484 seek=323708993
dd if=/dev/sdb of=/dev/sdb bs=4096 count=24900687 skip=373,511,171 seek=348609680
dd if=/dev/sdb of=/dev/sdb bs=4096 count=24900687 skip=398,411,858 seek=373510367
dd if=/dev/sdb of=/dev/sdb bs=4096 count=24900687 skip=423,312,545 seek=398411054
dd if=/dev/sdb of=/dev/sdb bs=4096 count=24900687 skip=448,213,232 seek=423311741
dd if=/dev/sdb of=/dev/sdb bs=4096 count=24900687 skip=473,113,919 seek=448212428
dd if=/dev/sdb of=/dev/sdb bs=4096 count=24900687 skip=498,014,606 seek=473113115
dd if=/dev/sdb of=/dev/sdb bs=4096 count=24900687 skip=522,915,293 seek=498013802
dd if=/dev/sdb of=/dev/sdb bs=4096 count=24900687 skip=547,815,980 seek=522914489
dd if=/dev/sdb of=/dev/sdb bs=4096 count=24900687 skip=572,716,667 seek=547815176
dd if=/dev/sdb of=/dev/sdb bs=4096 count=24900687 skip=597,617,354 seek=572715863
dd if=/dev/sdb of=/dev/sdb bs=4096 count=24900687 skip=622,518,041 seek=597616550
dd if=/dev/sdb of=/dev/sdb bs=4096 count=24900687 skip=647,418,728 seek=622517237
dd if=/dev/sdb of=/dev/sdb bs=4096 count=24900687 skip=672,319,415 seek=647417924
dd if=/dev/sdb of=/dev/sdb bs=4096 count=24900687 skip=697,220,102 seek=672318611
dd if=/dev/sdb of=/dev/sdb bs=4096 skip=722,120,789 seek=697219298
And finally to adapt the partition table to reflect the changed setup of just one primary partition.

Later i would extend the LUKS container and the file system accordingly.

Any input is welcome!!!