Streamlining disklabel...

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

Streamlining disklabel...

Implausibility
Hi.

I'm trying to add a 'block storage' disk to a an OpenBSD 6.1 VM in the cloud.

I was able to use fdisk to write an MBR, but I can't seem to get disklabel to simply allocate the entire disk (regardless of it's size) to one partition without going through the editor.

I checked /etc/disktype as per the man pages, but it only seems to have very specific / arcane definitions, and I'd like a 'catch all' solution that simply allocates all storage to one partition.

I simply want to create a single partition encompassing all of the available space.

I've searched the web, plus read searched the last 11k+ messages on misc@ -- but I can't seem to find any examples of defining a disk with disklabel non-interactively.

Can someone please provide some examples of a disklabel command that creates a partition non-interactively?  (For bonus points, a list of examples of the -w command would be great for future searchers / readers.)

Thanks.

For the record, I options like:

> # disklabel -w sd1 ffs    
> disklabel: unknown disk type: ffs
> # disklabel -w sd1 floppy
> disklabel: ioctl DIOCWDINFO: Open partition would move or shrink
> # disklabel -w sd1 hd    
> disklabel: unknown disk type: hd
> # disklabel -w sd1 sd  
> disklabel: unknown disk type: sd
> # disklabel -w sd1 SCSI
> disklabel: unknown disk type: SCSI
> # disklabel -w sd1 'disk'
> disklabel: unknown disk type: disk
> # disklabel -w sd1 0xA6  
> disklabel: unknown disk type: 0xA6
> # disklabel -w sd1 A6  
> disklabel: unknown disk type: A6
>

Reply | Threaded
Open this post in threaded view
|

Re: Streamlining disklabel...

Tom Rosso-4
On 2017-11-04 09:28, Implausibility wrote:
> I simply want to create a single partition encompassing all of the
> available space.
>
> I've searched the web, plus read searched the last 11k+ messages on
> misc@ -- but I can't seem to find any examples of defining a disk with
> disklabel non-interactively.
>
>> # disklabel -w sd1 'disk'
>> disklabel: unknown disk type: disk

You need to create an entry in /etc/disktab for the disk type "disk",
which defines all of the variables that go into the disklabel that will
be created.  man 5 disktab

It's easier to create a disklabel interactively.

Reply | Threaded
Open this post in threaded view
|

Re: Streamlining disklabel...

Implausibility

> On Nov 4, 2017, at 9:39 AM, Tom Rosso <[hidden email]> wrote:
>
> On 2017-11-04 09:28, Implausibility wrote:
>> I simply want to create a single partition encompassing all of the
>> available space.
>> I've searched the web, plus read searched the last 11k+ messages on
>> misc@ -- but I can't seem to find any examples of defining a disk with
>> disklabel non-interactively.
>>> # disklabel -w sd1 'disk'
>>> disklabel: unknown disk type: disk
>
> You need to create an entry in /etc/disktab for the disk type "disk", which defines all of the variables that go into the disklabel that will be created.  man 5 disktab
>
> It's easier to create a disklabel interactively.
>

The snag here is that I want this to work for any size disk that I connect to an OpenBSD instance.  It seems like the definitions in disktab are rather inflexible (the man page only mentions numeric sizes, not percentages or wildcards).

It seems weird that something so common critical (adding storage) is so cryptic.  I don't have to create a termcap entry for every new user, so it seems weird to have to create a similar record for every disk I want to format on the command line for OpenBSD.

Reply | Threaded
Open this post in threaded view
|

Re: Streamlining disklabel...

Otto Moerbeek
On Sat, Nov 04, 2017 at 10:51:59AM -0400, Implausibility wrote:

>
> > On Nov 4, 2017, at 9:39 AM, Tom Rosso <[hidden email]> wrote:
> >
> > On 2017-11-04 09:28, Implausibility wrote:
> >> I simply want to create a single partition encompassing all of the
> >> available space.
> >> I've searched the web, plus read searched the last 11k+ messages on
> >> misc@ -- but I can't seem to find any examples of defining a disk with
> >> disklabel non-interactively.
> >>> # disklabel -w sd1 'disk'
> >>> disklabel: unknown disk type: disk
> >
> > You need to create an entry in /etc/disktab for the disk type "disk", which defines all of the variables that go into the disklabel that will be created.  man 5 disktab
> >
> > It's easier to create a disklabel interactively.
> >
>
> The snag here is that I want this to work for any size disk that I connect to an OpenBSD instance.  It seems like the definitions in disktab are rather inflexible (the man page only mentions numeric sizes, not percentages or wildcards).
>
> It seems weird that something so common critical (adding storage) is so cryptic.  I don't have to create a termcap entry for every new user, so it seems weird to have to create a similar record for every disk I want to format on the command line for OpenBSD.

The interactive editor does support percentages:

     Quantities are rounded to the nearest cylinder when units are specified
     for sizes (or offsets).  At prompts that request a size, `*' may be
     entered to indicate the rest of the available space, `%' for percentage
     of total, and `&' for percentage free.

Default is to use the whole disk anyway. There is also a section
called AUTOMATIC DISK ALLOCATION that can use a templkate file.

        -Otto

Reply | Threaded
Open this post in threaded view
|

Re: Streamlining disklabel...

Implausibility
Again, the interactive editor is way too many steps, too many opportunities for screw-ups, and does nothing to streamline the process of adding a new disk for me.

So this is what I've come up with...

fdisk -i sd1
echo "/disk2    1M-*     100%" >/tmp/disktab.new
disklabel -w -dv  -A -T /tmp/disktab.new sd1 && rm /tmp/disktab.new
newfs /dev/rsd1a
mkdir /disk2
mount /dev/sd1a /disk2

This seems kludgy, but it is more automated / flexible, and best of all, it works.

I'm still curious to know if this is really the most efficient way of doing this.

Thanks.

> On Nov 4, 2017, at 11:16 AM, Otto Moerbeek <[hidden email]> wrote:
>
> On Sat, Nov 04, 2017 at 10:51:59AM -0400, Implausibility wrote:
>
>>
>>> On Nov 4, 2017, at 9:39 AM, Tom Rosso <[hidden email]> wrote:
>>>
>>> On 2017-11-04 09:28, Implausibility wrote:
>>>> I simply want to create a single partition encompassing all of the
>>>> available space.
>>>> I've searched the web, plus read searched the last 11k+ messages on
>>>> misc@ -- but I can't seem to find any examples of defining a disk with
>>>> disklabel non-interactively.
>>>>> # disklabel -w sd1 'disk'
>>>>> disklabel: unknown disk type: disk
>>>
>>> You need to create an entry in /etc/disktab for the disk type "disk", which defines all of the variables that go into the disklabel that will be created.  man 5 disktab
>>>
>>> It's easier to create a disklabel interactively.
>>>
>>
>> The snag here is that I want this to work for any size disk that I connect to an OpenBSD instance.  It seems like the definitions in disktab are rather inflexible (the man page only mentions numeric sizes, not percentages or wildcards).
>>
>> It seems weird that something so common critical (adding storage) is so cryptic.  I don't have to create a termcap entry for every new user, so it seems weird to have to create a similar record for every disk I want to format on the command line for OpenBSD.
>
> The interactive editor does support percentages:
>
>     Quantities are rounded to the nearest cylinder when units are specified
>     for sizes (or offsets).  At prompts that request a size, `*' may be
>     entered to indicate the rest of the available space, `%' for percentage
>     of total, and `&' for percentage free.
>
> Default is to use the whole disk anyway. There is also a section
> called AUTOMATIC DISK ALLOCATION that can use a templkate file.
>
> -Otto
>

Reply | Threaded
Open this post in threaded view
|

Re: Streamlining disklabel...

trondd-2
On Sat, November 4, 2017 5:09 pm, Implausibility wrote:

> Again, the interactive editor is way too many steps, too many
> opportunities for screw-ups, and does nothing to streamline the process of
> adding a new disk for me.
>
> So this is what I've come up with...
>
> fdisk -i sd1
> echo "/disk2    1M-*     100%" >/tmp/disktab.new
> disklabel -w -dv  -A -T /tmp/disktab.new sd1 && rm /tmp/disktab.new
> newfs /dev/rsd1a
> mkdir /disk2
> mount /dev/sd1a /disk2
>
> This seems kludgy, but it is more automated / flexible, and best of all,
> it works.
>
> I'm still curious to know if this is really the most efficient way of
> doing this.
>
> Thanks.
>

That's the way I do it.  That's the way the automated installer does it...