Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > alt.os.linux > #56141 > unrolled thread

Can crypsetup --type plain destroy a previous written partition?

Started byPaulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt>
First post2019-05-09 21:14 +0100
Last post2019-05-10 16:00 +0100
Articles 10 — 2 participants

Back to article view | Back to alt.os.linux


Contents

  Can crypsetup --type plain destroy a previous written partition? Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> - 2019-05-09 21:14 +0100
    Re: Can crypsetup --type plain destroy a previous written partition? "J.O. Aho" <user@example.net> - 2019-05-10 07:02 +0200
      Re: Can crypsetup --type plain destroy a previous written partition? Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> - 2019-05-10 16:10 +0100
        Re: Can crypsetup --type plain destroy a previous written partition? "J.O. Aho" <user@example.net> - 2019-05-10 18:43 +0200
          Re: Can crypsetup --type plain destroy a previous written partition? Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> - 2019-05-10 17:59 +0100
            Re: Can crypsetup --type plain destroy a previous written partition? "J.O. Aho" <user@example.net> - 2019-05-10 23:52 +0200
              Re: Can crypsetup --type plain destroy a previous written partition? Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> - 2019-05-11 04:08 +0100
                Re: Can crypsetup --type plain destroy a previous written partition? "J.O. Aho" <user@example.net> - 2019-05-11 09:40 +0200
                  Re: Can crypsetup --type plain destroy a previous written partition? Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> - 2019-05-11 18:50 +0100
    Re: Can crypsetup --type plain destroy a previous written partition? [EXLAINED] Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> - 2019-05-10 16:00 +0100

#56141 — Can crypsetup --type plain destroy a previous written partition?

FromPaulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt>
Date2019-05-09 21:14 +0100
SubjectCan crypsetup --type plain destroy a previous written partition?
Message-ID<qb21mk$eti$1@gioia.aioe.org>
Hi all!

Can crypsetup --type plain destroy a previous written partition?

Here is what happened ...

1. I had a raid1 of 2X2TiB usb disks (say A and B).
2. I wanted to replace one of the disks. There are some errors in it -
B. Disk A is fine.
3. I decided to use 2 new disks of 4TiB each (C and D) in raid1.
4. Disks A and B were encryted with --type plain.
5. I normally mounted disks A and B as usual. OK.
6. luksFormat'ed disk C.
7. Added it using btrfs dev add.
8. Deleted disk B with btrfs dev del B.
9. After 1.5 days the process ended successfully with disks A and C (I
could see it with btrfs fi show).
10. After this I unmounted the filesystem, closed the encrypted devices.
11. I physically disconnected disk B.
12. Then, wrongly, I tried to open disk A with --type=luks (it was
encrypted with --type=plain!). I got an error message.
13. After this I was no more able to make disk A recognized by btrfs.
14. I also noticed that cryptsetup with --type=plain (for disk A) didn't
cause a link creation in /dev/disk/by-uuid for the corresponding mapped
device which makes me think that the disk content was destroyed or at
least it is not being correctly unencrypted.

Any comments? Thanks.

TURN AROUND
I mounted the filesystem using only disk C as degraded.
Added disk D.
Deleted "missing".
Now it is transfering "things" to D.
Seems OK. Let's see what happens at the very end.

Regards

[toc] | [next] | [standalone]


#56159

From"J.O. Aho" <user@example.net>
Date2019-05-10 07:02 +0200
Message-ID<gjkeveFa7fmU1@mid.individual.net>
In reply to#56141
On 09/05/2019 22.14, Paulo da Silva wrote:
> Hi all!
> 
> Can crypsetup --type plain destroy a previous written partition?

If you use cryptsetup instead of cryptmount.

> Here is what happened ...
> 
> 1. I had a raid1 of 2X2TiB usb disks (say A and B).
> 2. I wanted to replace one of the disks. There are some errors in it -
> B. Disk A is fine.
> 3. I decided to use 2 new disks of 4TiB each (C and D) in raid1.
> 4. Disks A and B were encryted with --type plain.
> 5. I normally mounted disks A and B as usual. OK.
> 6. luksFormat'ed disk C.
> 7. Added it using btrfs dev add.
> 8. Deleted disk B with btrfs dev del B.
> 9. After 1.5 days the process ended successfully with disks A and C (I
> could see it with btrfs fi show).

Why not setup the new btrfs with disk C and D and then use btrfs send /
btrfs receive and you would have issues with breaking something, just 
see to change the volume on the C/D to read/write.


> 10. After this I unmounted the filesystem, closed the encrypted devices.
> 11. I physically disconnected disk B.
> 12. Then, wrongly, I tried to open disk A with --type=luks (it was
> encrypted with --type=plain!). I got an error message.
> 13. After this I was no more able to make disk A recognized by btrfs.
> 14. I also noticed that cryptsetup with --type=plain (for disk A) didn't
> cause a link creation in /dev/disk/by-uuid for the corresponding mapped
> device which makes me think that the disk content was destroyed or at
> least it is not being correctly unencrypted.
> 
> Any comments? Thanks.

As far as I remember (as I only run the system disk encrypted, this 
handled by the system mount scripts in initramfs) cryptmount should 
handle which type of encryption is used, so no need to specify that

[toc] | [prev] | [next] | [standalone]


#56167

FromPaulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt>
Date2019-05-10 16:10 +0100
Message-ID<qb449g$1ifr$1@gioia.aioe.org>
In reply to#56159
Às 06:02 de 10/05/19, J.O. Aho escreveu:
> On 09/05/2019 22.14, Paulo da Silva wrote:
>> Hi all!
>>
>> Can crypsetup --type plain destroy a previous written partition?
...

> 
> Why not setup the new btrfs with disk C and D and then use btrfs send /
> btrfs receive and you would have issues with breaking something, just
> see to change the volume on the C/D to read/write.
Because I have lots of snapshots and they share a big amount of space.
As much as I know, send/receive only work at subvol level.
I have the large majority of snapshots inside a subvol. I wonder what
happens if I apply send/receive to this subvol.
This is a very singular situation and I opted to go thru the simplest
solution (for me, of course).
...

> 
> As far as I remember (as I only run the system disk encrypted, this
> handled by the system mount scripts in initramfs) cryptmount should
> handle which type of encryption is used, so no need to specify that
> 

I never used cryptmount. I'll take a look at it. Thanks for the suggestion.

Regards
Paulo

[toc] | [prev] | [next] | [standalone]


#56168

From"J.O. Aho" <user@example.net>
Date2019-05-10 18:43 +0200
Message-ID<gjlo21FiqioU1@mid.individual.net>
In reply to#56167
On 10/05/2019 17.10, Paulo da Silva wrote:
> Às 06:02 de 10/05/19, J.O. Aho escreveu:
>> On 09/05/2019 22.14, Paulo da Silva wrote:
>>> Hi all!
>>>
>>> Can crypsetup --type plain destroy a previous written partition?
> ...
> 
>>
>> Why not setup the new btrfs with disk C and D and then use btrfs send /
>> btrfs receive and you would have issues with breaking something, just
>> see to change the volume on the C/D to read/write.
> Because I have lots of snapshots and they share a big amount of space.
> As much as I know, send/receive only work at subvol level.
> I have the large majority of snapshots inside a subvol. I wonder what
> happens if I apply send/receive to this subvol.
> This is a very singular situation and I opted to go thru the simplest
> solution (for me, of course).

Not sure, but I don't think it will send the snapshots, as if it would 
then it would have the older snapshots inside the new snapshot, if you 
want to keep all the snapshots, you have to make a send for each of them.

-- 

  //Aho

[toc] | [prev] | [next] | [standalone]


#56169

FromPaulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt>
Date2019-05-10 17:59 +0100
Message-ID<qb4akm$foe$1@gioia.aioe.org>
In reply to#56168
Às 17:43 de 10/05/19, J.O. Aho escreveu:
> On 10/05/2019 17.10, Paulo da Silva wrote:
>> Às 06:02 de 10/05/19, J.O. Aho escreveu:
>>> On 09/05/2019 22.14, Paulo da Silva wrote:
>>>> Hi all!
>>>>
>>>> Can crypsetup --type plain destroy a previous written partition?
...
>> I have the large majority of snapshots inside a subvol. I wonder what
>> happens if I apply send/receive to this subvol.
>> This is a very singular situation and I opted to go thru the simplest
>> solution (for me, of course).
> 
> Not sure, but I don't think it will send the snapshots, as if it would
> then it would have the older snapshots inside the new snapshot,
So don't I. I'll make a test using files/loop devices one of these days
to see what happens.
 if you
> want to keep all the snapshots, you have to make a send for each of them.

But then I'd get a big amount of duplicated data. Most likely it did not
fit in the new vols, even considering that they doubled the available space.

[toc] | [prev] | [next] | [standalone]


#56172

From"J.O. Aho" <user@example.net>
Date2019-05-10 23:52 +0200
Message-ID<gjma47Fmil5U1@mid.individual.net>
In reply to#56169
On 10/05/2019 18.59, Paulo da Silva wrote:
> Às 17:43 de 10/05/19, J.O. Aho escreveu:
>> On 10/05/2019 17.10, Paulo da Silva wrote:
>>> Às 06:02 de 10/05/19, J.O. Aho escreveu:
>>>> On 09/05/2019 22.14, Paulo da Silva wrote:
>>>>> Hi all!
>>>>>
>>>>> Can crypsetup --type plain destroy a previous written partition?
> ...
>>> I have the large majority of snapshots inside a subvol. I wonder what
>>> happens if I apply send/receive to this subvol.
>>> This is a very singular situation and I opted to go thru the simplest
>>> solution (for me, of course).
>>
>> Not sure, but I don't think it will send the snapshots, as if it would
>> then it would have the older snapshots inside the new snapshot,
> So don't I. I'll make a test using files/loop devices one of these days
> to see what happens.
>   if you
>> want to keep all the snapshots, you have to make a send for each of them.
> 
> But then I'd get a big amount of duplicated data. Most likely it did not
> fit in the new vols, even considering that they doubled the available space.
> 

To avoid duplication you first send your oldest snapshot


btrfs send /mnt/send/oldestsnashot | btrfs receive /mnt/recv/

and then you send the diff between the oldest and next oldest

btrfs send -p /mnt/send/oldestsnapshot /mnt/send/nextoldestsnapshot | 
btrfs receive /mnt/recv

And you do this for each snapshot, then you just get the changes, which 
leads to that less data is moved around.

This can be used if you want to make a backup of a volume. First time 
you do a full backup, you make a snapshot of the volume, you send the 
snapshot to your backup device.
Next time you make an incremental backup by making a new snapshot, you 
send the diff between the first snapshot and the new one, when finished 
you can delete the oldest snapshot. When you make the next incremental 
backup, you take a third snapshot, send the diff of the second and third 
snapshot, delete the second snapshot.

When the backup media starts to fill up, just delete the oldest 
snapshot. No data is duplicated on the backup media. This is how I do 
backups and the nice thing is that you can do it between computers too 
with help of ssh too

btrfs send /mnt/send/oldestsnapshot | ssh root@remote-server "btrfs 
receive /mnt/recv"

which IMHO is quite nice.

-- 

  //Aho

[toc] | [prev] | [next] | [standalone]


#56173

FromPaulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt>
Date2019-05-11 04:08 +0100
Message-ID<qb5eba$1ch1$1@gioia.aioe.org>
In reply to#56172
Às 22:52 de 10/05/19, J.O. Aho escreveu:
> On 10/05/2019 18.59, Paulo da Silva wrote:
>> Às 17:43 de 10/05/19, J.O. Aho escreveu:
>>> On 10/05/2019 17.10, Paulo da Silva wrote:
>>>> Às 06:02 de 10/05/19, J.O. Aho escreveu:
>>>>> On 09/05/2019 22.14, Paulo da Silva wrote:
...

> 
> To avoid duplication you first send your oldest snapshot
> 
> 
> btrfs send /mnt/send/oldestsnashot | btrfs receive /mnt/recv/
> 
> and then you send the diff between the oldest and next oldest
> 
> btrfs send -p /mnt/send/oldestsnapshot /mnt/send/nextoldestsnapshot |
> btrfs receive /mnt/recv
> 
> And you do this for each snapshot, then you just get the changes, which
> leads to that less data is moved around.
> 
> This can be used if you want to make a backup of a volume. First time
> you do a full backup, you make a snapshot of the volume, you send the
> snapshot to your backup device.
> Next time you make an incremental backup by making a new snapshot, you
> send the diff between the first snapshot and the new one, when finished
> you can delete the oldest snapshot. When you make the next incremental
> backup, you take a third snapshot, send the diff of the second and third
> snapshot, delete the second snapshot.
> 
> When the backup media starts to fill up, just delete the oldest
> snapshot. No data is duplicated on the backup media. This is how I do
> backups and the nice thing is that you can do it between computers too
> with help of ssh too
> 
> btrfs send /mnt/send/oldestsnapshot | ssh root@remote-server "btrfs
> receive /mnt/recv"

I thought of doing something like that but using rsync.
I.e.: rsync, snapshot, rsync, ...
I didn't do it because I needed to write a script for that. It's in my
agenda, however.
Does that incremental backup "work" at block level or file level?
rsync --inplace seems to just update the changed blocks.

In general I have scripts for everything and when things are working I
tend to be a little conservative :-)
But I really need to look at send/receive as future solution especially
for backups.

> 
> which IMHO is quite nice.
> 
Not only IYO! It is nice.
I'm keeping your post for reference.
Thank you very much.

[toc] | [prev] | [next] | [standalone]


#56175

From"J.O. Aho" <user@example.net>
Date2019-05-11 09:40 +0200
Message-ID<gjncjmFtfb4U1@mid.individual.net>
In reply to#56173
On 11/05/2019 05.08, Paulo da Silva wrote:
> Às 22:52 de 10/05/19, J.O. Aho escreveu:
>> On 10/05/2019 18.59, Paulo da Silva wrote:
>>> Às 17:43 de 10/05/19, J.O. Aho escreveu:
>>>> On 10/05/2019 17.10, Paulo da Silva wrote:
>>>>> Às 06:02 de 10/05/19, J.O. Aho escreveu:
>>>>>> On 09/05/2019 22.14, Paulo da Silva wrote:
> ...
> 
>>
>> To avoid duplication you first send your oldest snapshot
>>
>>
>> btrfs send /mnt/send/oldestsnashot | btrfs receive /mnt/recv/
>>
>> and then you send the diff between the oldest and next oldest
>>
>> btrfs send -p /mnt/send/oldestsnapshot /mnt/send/nextoldestsnapshot |
>> btrfs receive /mnt/recv
>>
>> And you do this for each snapshot, then you just get the changes, which
>> leads to that less data is moved around.
>>
>> This can be used if you want to make a backup of a volume. First time
>> you do a full backup, you make a snapshot of the volume, you send the
>> snapshot to your backup device.
>> Next time you make an incremental backup by making a new snapshot, you
>> send the diff between the first snapshot and the new one, when finished
>> you can delete the oldest snapshot. When you make the next incremental
>> backup, you take a third snapshot, send the diff of the second and third
>> snapshot, delete the second snapshot.
>>
>> When the backup media starts to fill up, just delete the oldest
>> snapshot. No data is duplicated on the backup media. This is how I do
>> backups and the nice thing is that you can do it between computers too
>> with help of ssh too
>>
>> btrfs send /mnt/send/oldestsnapshot | ssh root@remote-server "btrfs
>> receive /mnt/recv"
> 
> I thought of doing something like that but using rsync.
> I.e.: rsync, snapshot, rsync, ...
> I didn't do it because I needed to write a script for that. It's in my
> agenda, however.
> Does that incremental backup "work" at block level or file level?
> rsync --inplace seems to just update the changed blocks.

The incremental backup with btrfs is on "block level", as the same file 
will occupy the same block regardless of snapshot. The only issue with 
btrfs as I see it today is when you balance a volume, then the blocks 
won't change for the snapshots and you suddenly have duplicated your 
data. I hope they will go back to how it was before.

> In general I have scripts for everything and when things are working I
> tend to be a little conservative :-)

Yeah, if it works don't break :)


> But I really need to look at send/receive as future solution especially
> for backups.

Another thing you can look at is snappy, opensuse's script to make it 
simpler to handle snapshots, don't use it at home, but at work it saves 
me from remembering the btrfs syntax.

-- 

  //Aho

[toc] | [prev] | [next] | [standalone]


#56177

FromPaulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt>
Date2019-05-11 18:50 +0100
Message-ID<qb721v$gj1$1@gioia.aioe.org>
In reply to#56175
Às 08:40 de 11/05/19, J.O. Aho escreveu:
> On 11/05/2019 05.08, Paulo da Silva wrote:
>> Às 22:52 de 10/05/19, J.O. Aho escreveu:
...

> The only issue with
> btrfs as I see it today is when you balance a volume, then the blocks
> won't change for the snapshots and you suddenly have duplicated your
> data. I hope they will go back to how it was before.
>
I didn't notice! At least for k 4.15 (kubuntu 18.04).
I often use for ex. this:
btrfs fi balance start -dusage=50 -dlimit=2 -musage=50 -mlimit=4 /home
home has more than 1000 rw snapshots and it tends to sometimes "recover"
a couple of GB. Never increased the space used.

I have a script to create home snapshots named with a prefix followed by
a timestamp and a seq. number. Its purpose is to work as a fast "work
copy" when I make changes to anything. It's very useful when I
jeopardize a program, spreadsheet, db, or others.
There is no significant overhead except when booting, or doing some
massive deletions.

[toc] | [prev] | [next] | [standalone]


#56166 — Re: Can crypsetup --type plain destroy a previous written partition? [EXLAINED]

FromPaulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt>
Date2019-05-10 16:00 +0100
SubjectRe: Can crypsetup --type plain destroy a previous written partition? [EXLAINED]
Message-ID<qb43na$1fop$1@gioia.aioe.org>
In reply to#56141
Às 21:14 de 09/05/19, Paulo da Silva escreveu:
> Hi all!
> 
> Can crypsetup --type plain destroy a previous written partition?
> 
> Here is what happened ...
> 
> 1. I had a raid1 of 2X2TiB usb disks (say A and B).
> 2. I wanted to replace one of the disks. There are some errors in it -
> B. Disk A is fine.
> 3. I decided to use 2 new disks of 4TiB each (C and D) in raid1.
> 4. Disks A and B were encryted with --type plain.
> 5. I normally mounted disks A and B as usual. OK.
Here I made a mistake!!!
When using cryptseup I named the mapped devices B as A and A as B :-(
So disk A was discarded after the transfer, instead of B, and I was
trying to use it.
...

> 
> TURN AROUND
> I mounted the filesystem using only disk C as degraded.
> Added disk D.
> Deleted "missing".
> Now it is transfering "things" to D.
> Seems OK. Let's see what happens at the very end.
Now it is taking a lot of time. Sometimes there is a lot of I/O without
significant progress. Hopefully it will end up in the next 20h :-)

Thank you all who read this post.

[toc] | [prev] | [standalone]


Back to top | Article view | alt.os.linux


csiph-web