From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from v6.tansi.org (mail.tansi.org [87.118.116.4]) by mail.server123.net (Postfix) with ESMTP for ; Tue, 19 Apr 2016 22:06:36 +0200 (CEST) Received: from gatewagner.dyndns.org (77-57-36-72.dclient.hispeed.ch [77.57.36.72]) by v6.tansi.org (Postfix) with ESMTPA id 6638120DC1FD for ; Tue, 19 Apr 2016 22:06:35 +0200 (CEST) Date: Tue, 19 Apr 2016 22:06:34 +0200 From: Arno Wagner Message-ID: <20160419200634.GA4043@tansi.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: Subject: Re: [dm-crypt] LUKS is written to a device with no partition table. Is it possible to add a partition table? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: dm-crypt@saout.de First, please do not post HTML email to the list.=20 Second, while it is possible to add a partition table without backup, it is an extremely dangerous operation,=20 dangerous enough that your chances of doing so successfully=20 are near zero if you have to ask how to do it. I strongly recommend against trying.=20 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=20 of the device. Create LUKS container and in it a=20 filesystem in that partition. 4. Mount LUKS container in 2nd half of disk (using offset) and LUKS conteiner in partition.=20 5. Copy all data from filesystem in LUKS container in 2nd half=20 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=20 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. > =C2 =C2 =C2 # dd if=3D/dev/sdd | hexdump -C | head -1 > =C2 =C2 =C2 00000000=C2 4c 55 4b 53 ba be 00 01=C2 61 65 73 00 00 0= 0 00 00=C2 > |LUKS....aes.....| > =C2 =C2 =C2 # parted /dev/sdd > =C2 =C2 =C2 GNU Parted 3.2 > =C2 =C2 =C2 Using /dev/sdd > =C2 =C2 =C2 Welcome to GNU Parted! Type 'help' to view a list of comm= ands. > =C2 =C2 =C2 (parted) > print=C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 = =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 > =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 = =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 > =C2 =C2 =C2 Error: /dev/sdd: unrecognised disk label > =C2 =C2 =C2 Model: ORICO H/ W RAID5 > (scsi)=C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 = =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 > =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 =C2 > =C2 =C2 =C2 Disk /dev/sdd: 12.0TB > =C2 =C2 =C2 Sector size (logical/physical): 512B/4096B > =C2 =C2 =C2 Partition Table: unknown > =C2 =C2 =C2 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. > =C2 =C2 =C2 # cryptsetup status fatty > =C2 =C2 =C2 /dev/mapper/fatty is active. > =C2 =C2 =C2 =C2 =C2 type:=C2 =C2 =C2 LUKS1 > =C2 =C2 =C2 =C2 =C2 cipher:=C2 aes-xts-plain64 > =C2 =C2 =C2 =C2 =C2 keysize: 256 bits > =C2 =C2 =C2 =C2 =C2 device:=C2 /dev/sdd > =C2 =C2 =C2 =C2 =C2 offset:=C2 4096 sectors > =C2 =C2 =C2 =C2 =C2 size:=C2 =C2 =C2 23441764352 sectors > =C2 =C2 =C2 =C2 =C2 mode:=C2 =C2 =C2 read/write > =C2 =C2 =C2 # btrfs filesystem show /dev/mapper/fatty > =C2 =C2 =C2 Label: 'fatty'=C2 uuid: XXX-XX-XX-XX-XXXXXXXXX > =C2 =C2 =C2 =C2 =C2 =C2 =C2 Total devices 1 FS bytes used 2.75TiB > =C2 =C2 =C2 =C2 =C2 =C2 =C2 devid=C2 =C2 =C2 1 size 4.00TiB used 2.8= 0TiB 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? >=20 > References >=20 > 1. https://gitlab.com/cryptsetup/cryptsetup/issues/292 > _______________________________________________ > dm-crypt mailing list > dm-crypt@saout.de > http://www.saout.de/mailman/listinfo/dm-crypt --=20 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=20 "news" is "something that hardly ever happens." -- Bruce Schneier