Resize keydisk (softraid) partition...

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Resize keydisk (softraid) partition...

Zbyszek Żółkiewski
Hi,

So i did something stupid: during creation of keydisk (https://www.openbsd.org/faq/faq14.html#softraid), i was in hurry and I allocated whole 14GB partition a for keydisk…
Now i would like to shrink it somehow, what’s the best and safest way to do it… ?

_
Zbyszek Żółkiewski

Reply | Threaded
Open this post in threaded view
|

Re: Resize keydisk (softraid) partition...

Alexander Hall


On September 7, 2018 12:16:03 PM GMT+02:00, "Zbyszek Żółkiewski" <[hidden email]> wrote:
>Hi,
>
>So i did something stupid: during creation of keydisk
>(https://www.openbsd.org/faq/faq14.html#softraid), i was in hurry and I
>allocated whole 14GB partition a for keydisk…
>Now i would like to shrink it somehow, what’s the best and safest way
>to do it… ?

I'd take a disk with some unpartitioned space, create a small(er) RAID partition, and dd as much as possible of the 14GB keydisk into it. Then test if the new keydisk works.

/Alexander

>
>_
>Zbyszek Żółkiewski

Reply | Threaded
Open this post in threaded view
|

Re: Resize keydisk (softraid) partition...

Marcus MERIGHI
[hidden email] (Alexander Hall), 2018.09.07 (Fri) 16:56 (CEST):

> On September 7, 2018 12:16:03 PM GMT+02:00, "Zbyszek Żółkiewski"
> <[hidden email]> wrote:
> >Hi,
> >
> >So i did something stupid: during creation of keydisk
> >(https://www.openbsd.org/faq/faq14.html#softraid), i was in hurry and I
> >allocated whole 14GB partition a for keydisk…
> >Now i would like to shrink it somehow, what’s the best and safest way
> >to do it… ?
>
> I'd take a disk with some unpartitioned space, create a small(er) RAID
> partition, and dd as much as possible of the 14GB keydisk into it.
> Then test if the new keydisk works.
> /Alexander

I once noted (and have used various times) the following for
backup/restore of keydisks. It was mentioned on one of theses
lists, unfortunately I cannot find the source atm:

$ dd bs=8192 skip=1 if=/dev/rsd99z of=backup-keydisk.img
$ dd bs=8192 seek=1 if=backup-keydisk.img of=/dev/rsd99z

Marcus

Reply | Threaded
Open this post in threaded view
|

Re: Resize keydisk (softraid) partition...

Zbyszek Żółkiewski

> Wiadomość napisana przez Marcus MERIGHI <[hidden email]> w dniu 07.09.2018, o godz. 18:09:
>
> $ dd bs=8192 skip=1 if=/dev/rsd99z of=backup-keydisk.img
> $ dd bs=8192 seek=1 if=backup-keydisk.img of=/dev/rsd99z

thanks for answers but that will make dump of whole 14GB - i would like to shrink it to reasonable size…
_
Zbyszek Żółkiewski

Reply | Threaded
Open this post in threaded view
|

Re: Resize keydisk (softraid) partition...

Benjamin Baier
On Fri, 7 Sep 2018 21:00:58 +0200
Zbyszek Żółkiewski <[hidden email]> wrote:

>
> > Wiadomość napisana przez Marcus MERIGHI <[hidden email]> w dniu 07.09.2018, o godz. 18:09:
> >
> > $ dd bs=8192 skip=1 if=/dev/rsd99z of=backup-keydisk.img
> > $ dd bs=8192 seek=1 if=backup-keydisk.img of=/dev/rsd99z
>
> thanks for answers but that will make dump of whole 14GB - i would like to shrink it to reasonable size…

Well, from reading the code a little seems the keydisk metadata is at offset
SR_META_OFFSET = 8192 bytes and is SR_META_SIZE (64) * DEV_BSIZE (512 bytes) = 32768 bytes long.

Time ran out so do what you will with it. This is untested and always keep a good backup.

Reply | Threaded
Open this post in threaded view
|

Re: Resize keydisk (softraid) partition...

Thomas Bohl-2
In reply to this post by Zbyszek Żółkiewski
Hi,

> Now i would like to shrink it somehow, what’s the best and safest way to do it… ?

Like the FAQ says, make a backup of the key with
# dd bs=8192 skip=1 if=/dev/rsd1a of=backup-keydisk.img

Verify that backup-keydisk.img start with the string "marcCRAM".

Reformat sd1 or whatever to your likings (with size 960 for example).
Restore the key with
# dd bs=8192 seek=1 if=backup-keydisk.img of=/dev/rsd1a

Reply | Threaded
Open this post in threaded view
|

Re: Resize keydisk (softraid) partition...

Marcus MERIGHI
In reply to this post by Benjamin Baier
[hidden email] (Benjamin Baier), 2018.09.08 (Sat) 00:08 (CEST):

> On Fri, 7 Sep 2018 21:00:58 +0200
> Zbyszek Żółkiewski <[hidden email]> wrote:
>
> >
> > > Wiadomość napisana przez Marcus MERIGHI <[hidden email]> w dniu 07.09.2018, o godz. 18:09:
> > >
> > > $ dd bs=8192 skip=1 if=/dev/rsd99z of=backup-keydisk.img
> > > $ dd bs=8192 seek=1 if=backup-keydisk.img of=/dev/rsd99z
> >
> > thanks for answers but that will make dump of whole 14GB - i would
> > like to shrink it to reasonable size…

I never realized that since my keydisks were always set up a la FAQ!

> Well, from reading the code a little seems the keydisk metadata is at
> offset
> SR_META_OFFSET = 8192 bytes and is SR_META_SIZE (64) * DEV_BSIZE (512
> bytes) = 32768 bytes long.
>
> Time ran out so do what you will with it. This is untested and always
> keep a good backup.

Thanks for reading the code! this would do, then

$ dd bs=8192 skip=1 count=4 if=/dev/rsd99z of=backup-keydisk.img
                    ^^^^^^^
though I am going to test this:

$ dd bs=8192 skip=1 count=5 if=/dev/rsd99z of=backup-keydisk.img
                    ^^^^^^^

Thanks, Marcus

Reply | Threaded
Open this post in threaded view
|

Re: Resize keydisk (softraid) partition...

Zbyszek Żółkiewski
In reply to this post by Thomas Bohl-2

> Wiadomość napisana przez Thomas Bohl <[hidden email]> w dniu 08.09.2018, o godz. 03:41:
>
> Like the FAQ says, make a backup of the key with
> # dd bs=8192 skip=1 if=/dev/rsd1a of=backup-keydisk.img
>
> Verify that backup-keydisk.img start with the string "marcCRAM".
>
> Reformat sd1 or whatever to your likings (with size 960 for example).
> Restore the key with
> # dd bs=8192 seek=1 if=backup-keydisk.img of=/dev/rsd1a

thanks for the tips, I will test that and let you know
_
Zbyszek Żółkiewski