util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* fdisk request for functionality (or info)
@ 2017-10-03 16:57 Bruce Dubbs
  2017-10-04  8:27 ` Karel Zak
  0 siblings, 1 reply; 8+ messages in thread
From: Bruce Dubbs @ 2017-10-03 16:57 UTC (permalink / raw)
  To: Util-Linux

I have been having a problem with fdisk on old computers.

What I am doing is installing Debian, but dropping to the command line and 
creating a GPT manually because Debian seems to want to always create a 
msdos partition table.

After creating the GPT and partitioning, the install proceeds normally, 
but upon reboot the old bios tells me "No bootable disk".

I can fix this by going into rescue mode and setting the pmbr_boot flag 
using parted.

My question is whether this can be done in fdisk.  If not, can it be added?

I did try going into expert mode and selecting "toggle the legacy BIOS 
bootable flag", but does not seem to work.  I did not see any change to 
the boot sector when using 'd: print the raw data of the first sector from 
the device'.

Advice appreciated.

   -- Bruce Dubbs

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: fdisk request for functionality (or info)
  2017-10-03 16:57 fdisk request for functionality (or info) Bruce Dubbs
@ 2017-10-04  8:27 ` Karel Zak
  2017-10-04  8:59   ` Peter Cordes
  2017-10-04 14:41   ` Bruce Dubbs
  0 siblings, 2 replies; 8+ messages in thread
From: Karel Zak @ 2017-10-04  8:27 UTC (permalink / raw)
  To: Bruce Dubbs; +Cc: Util-Linux

On Tue, Oct 03, 2017 at 11:57:06AM -0500, Bruce Dubbs wrote:
> I have been having a problem with fdisk on old computers.
> 
> What I am doing is installing Debian, but dropping to the command line and
> creating a GPT manually because Debian seems to want to always create a
> msdos partition table.
> 
> After creating the GPT and partitioning, the install proceeds normally, but
> upon reboot the old bios tells me "No bootable disk".
> 
> I can fix this by going into rescue mode and setting the pmbr_boot flag
> using parted.
> 
> My question is whether this can be done in fdisk.  If not, can it be added?
> 
> I did try going into expert mode and selecting "toggle the legacy BIOS
> bootable flag", but does not seem to work.  I did not see any change to the
> boot sector when using 'd: print the raw data of the first sector from the
> device'.

The tricky thing is that fdisks by default see GPT partition, so you
have to force the tools to ignore GPT and use PMBR. There is more
ways:

1) you can force fdisk to see only MBR and ignore GPT

     fdisk --type dos <device>

   than you can use fdisk as usually for MBR.

2) start fdisk as usually
    - go to expert mode ('r')
    - see help ('m')
    - switch to nested label ('M')
    - go to main menu ('r')
    - toggle boot flag ('a')
    - write ('w')

 3) use sfdisk:

      sfdisk --label-nested dos --activate /dev/sda 1

   to set boot flag on the first partition.


 IMHO 3) is your friend if you have sfdisk :-)

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: fdisk request for functionality (or info)
  2017-10-04  8:27 ` Karel Zak
@ 2017-10-04  8:59   ` Peter Cordes
  2017-10-04  9:47     ` Karel Zak
  2017-10-04 14:41   ` Bruce Dubbs
  1 sibling, 1 reply; 8+ messages in thread
From: Peter Cordes @ 2017-10-04  8:59 UTC (permalink / raw)
  To: Karel Zak; +Cc: Bruce Dubbs, Util-Linux

On Wed, Oct 04, 2017 at 10:27:28AM +0200, Karel Zak wrote:
> The tricky thing is that fdisks by default see GPT partition, so you
> have to force the tools to ignore GPT and use PMBR.

 Would it be possible to add a more user-friendly way to present this
to the user?

Maybe a special command to toggle the PMBR bootable flag while looking
at the GPT?  That would make the complexity / existence of the PMBR more
discoverable for users, because it would show up in the built-in help
command output while looking at the GPT.  Toggling bootable is just
about the only useful thing you can do with the PMBR on a GPT disk,
and by far the most common, so "hiding" that functionality / status when
looking at the bootability of GPT isn't ideal.

>  3) use sfdisk:
> 
>       sfdisk --label-nested dos --activate /dev/sda 1

That's pretty non-obvious.  I don't think many people would come up
with that on their own if they aren't partitioning / sfdisk experts.
Of course it makes a good recipe, so hopefully people will find it
with google.

-- 
#define X(x,y) x##y
Peter Cordes ;  e-mail: X(peter@cor , des.ca)

"The gods confound the man who first found out how to distinguish the hours!
 Confound him, too, who in this place set up a sundial, to cut and hack
 my day so wretchedly into small pieces!" -- Plautus, 200 BC

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: fdisk request for functionality (or info)
  2017-10-04  8:59   ` Peter Cordes
@ 2017-10-04  9:47     ` Karel Zak
  2017-11-02 12:52       ` Karel Zak
  0 siblings, 1 reply; 8+ messages in thread
From: Karel Zak @ 2017-10-04  9:47 UTC (permalink / raw)
  To: Peter Cordes; +Cc: Bruce Dubbs, Util-Linux

On Wed, Oct 04, 2017 at 05:59:26AM -0300, Peter Cordes wrote:
> On Wed, Oct 04, 2017 at 10:27:28AM +0200, Karel Zak wrote:
> > The tricky thing is that fdisks by default see GPT partition, so you
> > have to force the tools to ignore GPT and use PMBR.
> 
>  Would it be possible to add a more user-friendly way to present this
> to the user?

Good point. Added to our TODO (probably v2.32):

  * fdisk: add "Print PMBR" and "Toggle PMBR boot flag" to main menu for GPT
  * sfdisk: make "--activate" usable also for GPT, in this case set PMBR boot flag


 Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: fdisk request for functionality (or info)
  2017-10-04  8:27 ` Karel Zak
  2017-10-04  8:59   ` Peter Cordes
@ 2017-10-04 14:41   ` Bruce Dubbs
  2017-10-05 10:59     ` Karel Zak
  1 sibling, 1 reply; 8+ messages in thread
From: Bruce Dubbs @ 2017-10-04 14:41 UTC (permalink / raw)
  To: Karel Zak; +Cc: Util-Linux

Karel Zak wrote:
> On Tue, Oct 03, 2017 at 11:57:06AM -0500, Bruce Dubbs wrote:
>> I have been having a problem with fdisk on old computers.
>>
>> What I am doing is installing Debian, but dropping to the command line and
>> creating a GPT manually because Debian seems to want to always create a
>> msdos partition table.
>>
>> After creating the GPT and partitioning, the install proceeds normally, but
>> upon reboot the old bios tells me "No bootable disk".
>>
>> I can fix this by going into rescue mode and setting the pmbr_boot flag
>> using parted.
>>
>> My question is whether this can be done in fdisk.  If not, can it be added?
>>
>> I did try going into expert mode and selecting "toggle the legacy BIOS
>> bootable flag", but does not seem to work.  I did not see any change to the
>> boot sector when using 'd: print the raw data of the first sector from the
>> device'.
>
> The tricky thing is that fdisks by default see GPT partition, so you
> have to force the tools to ignore GPT and use PMBR. There is more
> ways:

> 2) start fdisk as usually
>      - go to expert mode ('r')

There is not an 'r' mode, only 'x' when the current table is gpt.

>      - see help ('m')
>      - switch to nested label ('M')
>      - go to main menu ('r')
>      - toggle boot flag ('a')
>      - write ('w')

I wasn't sure if the 'pmbr_boot' flag was just the standard mbr boot flag 
for partition 1 or not.  Would it be reasonable to set that flag by 
default when 'g create a new empty GPT partition table' is selected?

   -- Bruce

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: fdisk request for functionality (or info)
  2017-10-04 14:41   ` Bruce Dubbs
@ 2017-10-05 10:59     ` Karel Zak
  2017-10-05 16:04       ` Bruce Dubbs
  0 siblings, 1 reply; 8+ messages in thread
From: Karel Zak @ 2017-10-05 10:59 UTC (permalink / raw)
  To: Bruce Dubbs; +Cc: Util-Linux

On Wed, Oct 04, 2017 at 09:41:38AM -0500, Bruce Dubbs wrote:
> Karel Zak wrote:
> > On Tue, Oct 03, 2017 at 11:57:06AM -0500, Bruce Dubbs wrote:
> > > I have been having a problem with fdisk on old computers.
> > > 
> > > What I am doing is installing Debian, but dropping to the command line and
> > > creating a GPT manually because Debian seems to want to always create a
> > > msdos partition table.
> > > 
> > > After creating the GPT and partitioning, the install proceeds normally, but
> > > upon reboot the old bios tells me "No bootable disk".
> > > 
> > > I can fix this by going into rescue mode and setting the pmbr_boot flag
> > > using parted.
> > > 
> > > My question is whether this can be done in fdisk.  If not, can it be added?
> > > 
> > > I did try going into expert mode and selecting "toggle the legacy BIOS
> > > bootable flag", but does not seem to work.  I did not see any change to the
> > > boot sector when using 'd: print the raw data of the first sector from the
> > > device'.
> > 
> > The tricky thing is that fdisks by default see GPT partition, so you
> > have to force the tools to ignore GPT and use PMBR. There is more
> > ways:
> 
> > 2) start fdisk as usually
> >      - go to expert mode ('r')
> 
> There is not an 'r' mode, only 'x' when the current table is gpt.
> 
> >      - see help ('m')
> >      - switch to nested label ('M')
> >      - go to main menu ('r')
> >      - toggle boot flag ('a')
> >      - write ('w')
> 
> I wasn't sure if the 'pmbr_boot' flag was just the standard mbr boot flag

>From parted code it seems that the default is

    gpt_disk_data->pmbr_boot = 0;

> for partition 1 or not.  Would it be reasonable to set that flag by default
> when 'g create a new empty GPT partition table' is selected?

Not sure, according to UEFI standard the boot flag should be ignored
by EFI boot loaders and for non-EFI systems the behavior is undefined.

The first partition on protective MBR covers all disk and the start
offset of the partition is the place where is GPT header. So, the
partition is useless as source for boot. 

The question is what your old BIOS expects and why does it parses MBR
at all :) It should be enough for BIOS to read boot-bits (begin of the
disk) where is boot loader rather than try to be smart and parse any
PT...)

If you want to boot from the MBR than it's probably some kind of crazy
hybrid MBR and it's completely out of fdisk/parted interest. 

fdisk and sfdisk allows to manually work with (hybrid)MBR, but it's
under user's control and fdisk does not do anything by default in this
case.

So, from my point of view all we need is to make changes to fdisk main
menu to make PMBR/HybridMBR easy to access for creative users with
legacy BIOS.


BTW, what returns:

    # fdisk  /dev/sda --type dos --list

for standard PMBR on EFI system it's:

        Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128 sectors
        Units: sectors of 1 * 512 = 512 bytes
        Sector size (logical/physical): 512 bytes / 512 bytes
        I/O size (minimum/optimal): 512 bytes / 512 bytes
        Disklabel type: dos
        Disk identifier: 0x00000000

        Device     Boot Start       End   Sectors   Size Id Type
        /dev/sda1           1 468862127 468862127 223.6G ee GPT


-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: fdisk request for functionality (or info)
  2017-10-05 10:59     ` Karel Zak
@ 2017-10-05 16:04       ` Bruce Dubbs
  0 siblings, 0 replies; 8+ messages in thread
From: Bruce Dubbs @ 2017-10-05 16:04 UTC (permalink / raw)
  To: Karel Zak; +Cc: Util-Linux

Karel Zak wrote:
> On Wed, Oct 04, 2017 at 09:41:38AM -0500, Bruce Dubbs wrote:

>> Would it be reasonable to set that flag by default
>> when 'g create a new empty GPT partition table' is selected?
>
> Not sure, according to UEFI standard the boot flag should be ignored
> by EFI boot loaders and for non-EFI systems the behavior is undefined.
>
> The first partition on protective MBR covers all disk and the start
> offset of the partition is the place where is GPT header. So, the
> partition is useless as source for boot.

Agree.  The problem is the BIOS on fairly old Core2Duo systems.  These 
systems are in a classroom with 16 identical computers.  I've complained 
for a couple of years now that the computers are slow and way out of date 
for what is supposed to be a class teaching technology.

> The question is what your old BIOS expects and why does it parses MBR
> at all :) It should be enough for BIOS to read boot-bits (begin of the
> disk) where is boot loader rather than try to be smart and parse any
> PT...)

What the BIOS should do and what is does are different.  In a different 
classroom with better systems there is no problem.

> If you want to boot from the MBR than it's probably some kind of crazy
> hybrid MBR and it's completely out of fdisk/parted interest.

No, I do not want to boot from the MBR.  I am trying to instruct the 
students how to install and use a GPT.  It seems that the Debian expert 
installer has no option to create a GPT, although it will use it if found. 
  What I have the students do during install is to drop to the command 
line and run fdisk manually, creating a new, empty GPT and new partitions 
for the installer.  It is a good learning exercise.

The problem then, after install, is that the BIOS returns "No bootable 
disk found".  Using a rescue disk and setting the pmbr boot flag allows 
the system to boot properly.

> fdisk and sfdisk allows to manually work with (hybrid)MBR, but it's
> under user's control and fdisk does not do anything by default in this
> case.
>
> So, from my point of view all we need is to make changes to fdisk main
> menu to make PMBR/HybridMBR easy to access for creative users with
> legacy BIOS.

Even an entry in the expert menu would be OK for me. This is probably
a rare enough situation that it does not need to be in the main menu.

> BTW, what returns:
>
>      # fdisk  /dev/sda --type dos --list
>
> for standard PMBR on EFI system it's:
>
>          Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128 sectors
>          Units: sectors of 1 * 512 = 512 bytes
>          Sector size (logical/physical): 512 bytes / 512 bytes
>          I/O size (minimum/optimal): 512 bytes / 512 bytes
>          Disklabel type: dos
>          Disk identifier: 0x00000000
>
>          Device     Boot Start       End   Sectors   Size Id Type
>          /dev/sda1           1 468862127 468862127 223.6G ee GPT

Yes, that's what I get too.  Setting the pmbr boot bit adds an asterisk 
under boot.

   -- Bruce



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: fdisk request for functionality (or info)
  2017-10-04  9:47     ` Karel Zak
@ 2017-11-02 12:52       ` Karel Zak
  0 siblings, 0 replies; 8+ messages in thread
From: Karel Zak @ 2017-11-02 12:52 UTC (permalink / raw)
  To: Peter Cordes; +Cc: Bruce Dubbs, Util-Linux

On Wed, Oct 04, 2017 at 11:47:52AM +0200, Karel Zak wrote:
> On Wed, Oct 04, 2017 at 05:59:26AM -0300, Peter Cordes wrote:
> > On Wed, Oct 04, 2017 at 10:27:28AM +0200, Karel Zak wrote:
> > > The tricky thing is that fdisks by default see GPT partition, so you
> > > have to force the tools to ignore GPT and use PMBR.
> > 
> >  Would it be possible to add a more user-friendly way to present this
> > to the user?
> 
> Good point. Added to our TODO (probably v2.32):
> 
>   * fdisk: add "Print PMBR" and "Toggle PMBR boot flag" to main menu for GPT

I have added 'M' command to the main menu to enter/leave PMBR. It's
more obvious now, and users do not have to enter expert menu.

>   * sfdisk: make "--activate" usable also for GPT, in this case set PMBR boot flag

Implemented.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-11-02 12:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-03 16:57 fdisk request for functionality (or info) Bruce Dubbs
2017-10-04  8:27 ` Karel Zak
2017-10-04  8:59   ` Peter Cordes
2017-10-04  9:47     ` Karel Zak
2017-11-02 12:52       ` Karel Zak
2017-10-04 14:41   ` Bruce Dubbs
2017-10-05 10:59     ` Karel Zak
2017-10-05 16:04       ` Bruce Dubbs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).