Re: Creating a GPT tab
On 1/24/21 11:52 PM, Brook Milligan wrote: The drive I am trying to replicate manually is from an evbmips (octeon) system that is working fine and was (more or less) created by NetBSD tools for a release. This is key information. I'm guessing, in the past, that the hpcmips boot loader (u-boot) didn't recognize the GPT MSDOS partition that contained bootefi. I wonder if that's still the case. You could try deleting the the msdos partition from the MBR (I'd back the MBR up first) and see if the machine still boots. If so then you should make the GPT protective partition in the MBR cover the entire disk. If the MBR MSDOS partition is needed then you should have the GPT protective partition start at 196608 (32768 + 163840) and cover the remainder of the disk. Are you looking to script the creation of the disk image? If not, sysinst should create the GPT partitions with no difficulty. You'll need to add the MBR partition(s) by hand. If you're having getting the machine to boot, you may be missing the u-boot code that's in the blank space before the start of the MSDOS partition (sectors 34 to 32767). You could copy the u-boot code using dd or look for in pkgsrc for a package that will build the boot code for you. Such a package would give you the command to copy the boot loader to other disks. Having the GPT partition table start at sector 1 shouldn't be a problem. An unscientific survey of the machines I have with GPT tables shows that all of them have the GPT header in sector 1. HTH, Jason M.
Re: Creating a GPT tab
> On Jan 24, 2021, at 4:50 PM, Robert Elz wrote: > >Date:Sun, 24 Jan 2021 14:12:20 -0800 >From:John Nemeth >Message-ID: <202101242212.10omckhx022...@server.cornerstoneservice.ca> > > | The tools won't replicate this, nor should they, as it is a > | seriously broken setup. To fix this setup, delete MBR parition 0. > > Actually, it would take more than that... The PMBR should cover the > entire drive, the one shown only accounted for the (unused except for > the partitioning headers) section before the start of the windows > partition. > > This is even worse than when I looked at it before. If this works > for anything at all (except perhaps ignoring the GPT partitions > entirely, and simply allowing access via the MBR to the windows > partition) then I suspect that indicates a bug somewhere. It shouldn't. The drive I am trying to replicate manually is from an evbmips (octeon) system that is working fine and was (more or less) created by NetBSD tools for a release. The only difference from the original disk image created by the NetBSD release is that I replaced a single ffs partition with two. Now I am trying to create a similar drive layout manually rather than going through the dance I did before: dd the image, boot to resize the root partition, boot diskless, delete root partition, make new partitions, repopulate filesystems. As far as I can tell, the NetBSD releases use the code included below to create the disk image that I started with and am trying to replicate. See src/distrib/utils/embedded/mkimage, the relevant portion of which is copied below; in this case $gpt and $gpt_hybrid are both true. (One thing I still don’t understand in this code is that ${image} does not occur as the last argument to gpt.) I’ll let others comment further on the wisdom of a hybrid GPT/MBR scheme or the layout of the MBR, but the -H option was added post-9, presumably to support applications like this. Further, this is the layout actually created by NetBSD tools for working systems. If there is a better layout, I would like to know. Thanks. Cheers, Brook if $gpt; then if $gpt_hybrid; then gpt_flags="-H" fi initsecs=$((${init} * 1024)) bootsecs=$((${boot} * 1024)) ffsstart="$(getsectors ${ffsoffset})" echo ${bar} Clearing existing partitions ${bar} ${GPT} ${gpt_flags} ${image} destroy || true echo ${bar} Creating partitions ${bar} ${GPT} ${gpt_flags} ${image} create ${gpt_create_flags} ${GPT} ${gpt_flags} ${image} add -b ${initsecs} -s ${bootsecs} -l ${gpt_label_boot:-EFI} -t ${gpt_boot_type:-efi} ${GPT} ${gpt_flags} ${image} set -a required -i 1 ${GPT} ${gpt_flags} ${image} add -a 4m -b ${ffsstart} -l ${gpt_label_ffs:-netbsd-root} -t ffs ${GPT} ${gpt_flags} ${image} show if $gpt_hybrid; then echo ${bar} Creating hybrid MBR ${bar} ${FDISK} -f -g -u -0 -a -s ${msdosid}/${initsecs}/${bootsecs} -F ${image} ${FDISK} -f -g -u -3 -s 238/1/$((${initsecs} - 1)) -F ${image} ${FDISK} -F ${image} fi else … fi
Re: Creating a GPT tab
Date:Sun, 24 Jan 2021 14:12:20 -0800 From:John Nemeth Message-ID: <202101242212.10omckhx022...@server.cornerstoneservice.ca> | The tools won't replicate this, nor should they, as it is a | seriously broken setup. To fix this setup, delete MBR parition 0. Actually, it would take more than that... The PMBR should cover the entire drive, the one shown only accounted for the (unused except for the partitioning headers) section before the start of the windows partition. This is even worse than when I looked at it before. If this works for anything at all (except perhaps ignoring the GPT partitions entirely, and simply allowing access via the MBR to the windows partition) then I suspect that indicates a bug somewhere. It shouldn't. kre
Re: Creating a GPT tab
On Jan 24, 11:49, Brook Milligan wrote: } } I am trying to create GPT partitions that are the same as the following: } } # fdisk sd0 } fdisk: Cannot determine the number of heads } Disk: /dev/rsd0 } NetBSD disklabel disk geometry: } cylinders: 118152, heads: 64, sectors/track: 32 (2048 sectors/cylinder) } total sectors: 241975296, bytes/sector: 512 } } BIOS disk geometry: } cylinders: 1023, heads: 255, sectors/track: 63 (16065 sectors/cylinder) } total sectors: 241975296 } } Partitions aligned to 2048 sector boundaries, offset 63 } } Partition table: } 0: Primary DOS with 32 bit FAT - LBA (sysid 12) } start 32768, size 163840 (80 MB, Cyls 2/10/9-12/60/48), Active } 1: } 2: } 3: GPT Protective MBR (sysid 238) } start 1, size 32767 (16 MB, Cyls 0/0/2-2/10/8) } PBR is not bootable: Bad magic number (0x) } First active partition: 0 } Drive serial number: 0 (0x) This is a bit of a mess, as you should NEVER EVER have anything other than a "GPT Protective MBR" in the MBR on a disk that has a GPT. This is basically mixing two very different partitioning schemes on the same disk (that can only lead to sadness). } # gpt show sd0 } start size index contents } 0 1 MBR } 1 1 Pri GPT header } 2 32 Pri GPT table } 34 32734 Unused } 32768 163840 1 GPT part - Windows basic data } 196608 33554432 2 GPT part - NetBSD FFSv1/FFSv2 }33751040 207618048 3 GPT part - NetBSD FFSv1/FFSv2 } 241369088 606175 Unused } 241975263 32 Sec GPT table } 241975295 1 Sec GPT header } } The complicating factor is that there is an MBR in sector 0 and } the primary GPT begins at sector 1. } } I cannot figure out how to make the tools replicate this and } would appreciate help. The tools won't replicate this, nor should they, as it is a seriously broken setup. To fix this setup, delete MBR parition 0. }-- End of excerpt from Brook Milligan
Re: Creating a GPT tab
Hmm, in my previous reply I missed the 0 MBR partition. That one is weird. That's a duplicate spec of the first GPT partition (the windows GPT partition) - which I assume is there to allow ancient windows systems, and other things that understand MBRs, to find that partition without understanding GPT. I am now guessing this is not a PC (for which that would make this an invalid PMBR) but an ARM system perhaps? I am not sure that we have tools that can make something like that. Perhaps, someone else will need to answer. kre
Re: Creating a GPT tab
Date:Sun, 24 Jan 2021 11:49:09 -0700 From:Brook Milligan Message-ID: <818cc659-27b2-4207-94e2-a14c9579f...@nmsu.edu> | I am trying to create GPT partitions that are the same as the following: | The complicating factor is that there is an MBR in sector 0 and the | primary GPT begins at sector 1. That's normal. The MBR is a "protective MBR" - it exists entirely so that old systems that don't understand GPT won't think the drive is empty and overwrite its contents without verifying first. | I cannot figure out how to make the tools replicate this and would | appreciate help. Assuming you mean to use the tools to make a similar structure, rather that make a literal copy of what is on the drive, then gpt create sd0 gpt add -b 32788 -s 163840 -t windows -l Windows_Data sd0 gpt add -s 33554432 -t ffs -l NetBSD_Root sd0 gpt add -s 207618048 -t ffs -l NetBSD-Data sd0 you didn't show the existing partition labels, so I just made some up, use whatever is appropriate (but they should be different from the ones on the existing drive, if you are making a new one, unless the two drives will (absolutely 100% for certain) never be connected to the same system at the same time. That's it. gpt will create the PMBR for you as part of gpt create, don't try and use fdisk to make that one appear. kre