DM-Crypt Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Arno Wagner <arno@wagner.name>
To: dm-crypt@saout.de
Subject: Re: [dm-crypt] LUKS is written to a device with no partition table. Is it possible to add a partition table?
Date: Tue, 19 Apr 2016 22:06:34 +0200	[thread overview]
Message-ID: <20160419200634.GA4043@tansi.org> (raw)
In-Reply-To: <CANJQ5C5qMZbamuJ+_CQn9gWW+orPuiZAN+y61jgW6QiYtUt+4A@mail.gmail.com>

First,

please do not post HTML email to the list. 

Second, while it is possible to add a partition table
without backup, it is an extremely dangerous operation, 
dangerous enough that your chances of doing so successfully 
are near zero if you have to ask how to do it. I strongly
recommend against trying. 

Now, if you want to lose all data, here is what you can try:
1. Resize filesystem in LUKS container to half device size.
2. Move LUKS container to end
3. Create partition table and a partition that covers 1st half 
   of the device. Create LUKS container and in it a 
   filesystem in that partition.
4. Mount LUKS container in 2nd half of disk (using offset)
   and LUKS conteiner in partition. 
5. Copy all data from filesystem in LUKS container in 2nd half 
   of disk to filesystem in LUKS conteiner in 1st half.
6. Unmap container in 2nd half of disk.
7. Create 2nd partition covering 2nd half of disk and
   put filesystem in there.

If you make one tiny mistake anywhere, chances are your 
data is gone. Do not try this without full, current backup.

Regards,
Arno


On Tue, Apr 19, 2016 at 21:08:37 CEST, Joe Hillenbrand wrote:
>    I posted this to [1]https://gitlab.com/cryptsetup/cryptsetup/issues/292
>    but now I'm worried that might not be the appropriate place to ask
>    questions.
>    I have a 12TB hardware RAID5 external hard drive array.
>    I had initially planned to only ever encrypt data to the device, but
>    now I need about half encrypted and half not.
>    The device is `/dev/sdd`. It mounts as `fatty`.
>    There is no partition table.
>    Â Â Â  # dd if=/dev/sdd | hexdump -C | head -1
>    Â Â Â  00000000Â  4c 55 4b 53 ba be 00 01Â  61 65 73 00 00 00 00 00Â
>    |LUKS....aes.....|
>    Â Â Â  # parted /dev/sdd
>    Â Â Â  GNU Parted 3.2
>    Â Â Â  Using /dev/sdd
>    Â Â Â  Welcome to GNU Parted! Type 'help' to view a list of commands.
>    Â Â Â  (parted)
>    print                                Â
>    Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â
>    Â Â Â  Error: /dev/sdd: unrecognised disk label
>    Â Â Â  Model: ORICO H/ W RAID5
>    (scsi)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
>     Â Â Â Â Â Â Â Â  Â
>    Â Â Â  Disk /dev/sdd: 12.0TB
>    Â Â Â  Sector size (logical/physical): 512B/4096B
>    Â Â Â  Partition Table: unknown
>    Â Â Â  Disk Flags:
>    As you can see LUKS starts at the first byte of the device.
>    There is a btrfs filesystem on the LUKS device and I resized it down to
>    4TB.
>    Â Â Â  # cryptsetup status fatty
>    Â Â Â  /dev/mapper/fatty is active.
>    Â Â Â Â Â  type:Â Â Â  LUKS1
>    Â Â Â Â Â  cipher:Â  aes-xts-plain64
>    Â Â Â Â Â  keysize: 256 bits
>    Â Â Â Â Â  device:Â  /dev/sdd
>    Â Â Â Â Â  offset:Â  4096 sectors
>    Â Â Â Â Â  size:Â Â Â  23441764352 sectors
>    Â Â Â Â Â  mode:Â Â Â  read/write
>    Â Â Â  # btrfs filesystem show /dev/mapper/fatty
>    Â Â Â  Label: 'fatty'Â  uuid: XXX-XX-XX-XX-XXXXXXXXX
>    Â Â Â Â Â Â Â  Total devices 1 FS bytes used 2.75TiB
>            devid    1 size 4.00TiB used 2.80TiB path
>    /dev/mapper/fatty
>    I can't really move the data anywhere, because it's too big and would
>    require buying more hardware.
>    Is it possible to add a partition table without losing the data?
> 
> References
> 
>    1. https://gitlab.com/cryptsetup/cryptsetup/issues/292

> _______________________________________________
> dm-crypt mailing list
> dm-crypt@saout.de
> http://www.saout.de/mailman/listinfo/dm-crypt


-- 
Arno Wagner,     Dr. sc. techn., Dipl. Inform.,    Email: arno@wagner.name
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

If it's in the news, don't worry about it.  The very definition of 
"news" is "something that hardly ever happens." -- Bruce Schneier

  reply	other threads:[~2016-04-19 20:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-19 19:08 [dm-crypt] LUKS is written to a device with no partition table. Is it possible to add a partition table? Joe Hillenbrand
2016-04-19 20:06 ` Arno Wagner [this message]
2016-04-19 20:20   ` Ralf Ramsauer
2016-04-19 21:15     ` Michael Kjörling
2016-04-19 20:14 ` Ralf Ramsauer
2016-04-19 21:02 ` Joe Hillenbrand
2016-04-20  2:28   ` f-dm-c
2016-04-20 19:26   ` Joe Hillenbrand
2016-04-20 19:43     ` Joe Hillenbrand
2016-04-20 19:54       ` Joe Hillenbrand
2016-04-21  2:54         ` David Christensen
2016-04-21  9:02         ` Arno Wagner
2016-04-20  4:14 ` David Christensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160419200634.GA4043@tansi.org \
    --to=arno@wagner.name \
    --cc=dm-crypt@saout.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox