NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Creating a GPT tab




> On Jan 24, 2021, at 4:50 PM, Robert Elz <kre%munnari.OZ.AU@localhost> wrote:
> 
>    Date:        Sun, 24 Jan 2021 14:12:20 -0800
>    From:        John Nemeth <jnemeth%cue.bc.ca@localhost>
>    Message-ID:  <202101242212.10OMCKHx022982%server.cornerstoneservice.ca@localhost>
> 
>  |      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


Home | Main Index | Thread Index | Old Index