Solved unable to create more than 6 partitions using mfsbsd (UFS/GPT)

Hi,

I am trying to configure FreeBSD 11.1 auto installation using the mfsbsd utility, Auto installation works fine when I define 6 partitions but when I try to configure more than 6 partitions then it failed with no space available index '9'

While checking the mfsbsd scripts do_gpt.sh under tools (https://github.com/mmatuska/mfsbsd)

it shows the code is trying to create gpt partition(not MBR)
Code:
--do_gpt.sh--
if [ -n "$VERBOSE" ]; then
  TIME=time
  set -x
else
  TIME=
fi
gpart create -s gpt ${unit}
gpart add -t freebsd-boot -b 40 -l boot -s 472 ${unit}
gpart bootcode -b ${BOOTDIR}/pmbr -p ${BOOTDIR}/gptboot -i 1 ${unit}
gpart add -t freebsd-ufs -l rootfs ${unit}

${TIME} makefs -B little ${TMPIMG} ${FSPROTO}
${TIME} dd if=${TMPIMG} of=/dev/${unit}p2 bs=128k
While after deployment with less then 6 partitions - I can see it creates MBR with BSDLABLE.

my installerconfig's partition portion is as below ( i defined more partitions here, when I remove /opt - last partition) then it will work fine .
Code:
root@server:~ # cat installerconfig.sample
# for variations in the root disk device name between VMware and Virtualbox
if [ -e /dev/ada0 ]; then
  PARTITIONS="ada0 { 12G freebsd-ufs /, 8G freebsd-swap, 8G freebsd-ufs /tmp, 12G freebsd-ufs /home, 8G freebsd-ufs /var, 8G freebsd-ufs /var/log, 8G freebsd-ufs /var/log/audit, 8G freebsd-ufs /opt  }"
elif [ -e /dev/da0 ]; then
  PARTITIONS="da0 { 12G freebsd-ufs /, 16G freebsd-swap, 8G freebsd-ufs /tmp, 12G freebsd-ufs /home, 8G freebsd-ufs /var, 8G freebsd-ufs /var/log, 8G freebsd-ufs /var/log/audit, 8G freebsd-ufs /opt  }"
elif [ -e /dev/vtbd0 ]; then
  PARTITIONS="vtbd0 { 12G freebsd-ufs /, 16G freebsd-swap, 8G freebsd-ufs /tmp, 12G freebsd-ufs /home, 8G freebsd-ufs /var, 8G freebsd-ufs /var/log, 8G freebsd-ufs /var/log/audit, 8G freebsd-ufs /opt  }"
else
  echo "Unknown disk for install.sh to work with!"
  exit -1
fi

DISTRIBUTIONS="kernel.txz base.txz"
BSDINSTALL_DISTDIR=/tmp
---------------end----------------

Appreciate your help!!


Thanks,
Niks
 
This will use the rest of the free space of the device.
Code:
gpart add -t freebsd-ufs -l rootfs ${unit}

That's why when you try to add another partition after that it will return the error.
 
This will use the rest of the free space of the device.
Code:
gpart add -t freebsd-ufs -l rootfs ${unit}

That's why when you try to add another partition after that it will return the error.


Thanks,
But If remove that line than i am unable to create image using make command

In that case why it is able to create less then 6 partitions .
Appreciate your support
 
This is a set of scripts that generates a bootable image, ISO file or boot files only, that create a working minimal installation of FreeBSD. This minimal installation gets completely loaded into memory.

As i understand the purpose of the this scrip: https://github.com/mmatuska/mfsbsd/blob/master/INSTALL.md

The do_gpt.sh script is used during the make to create a single partition for the image that's why it utilize the entire disk space.

Code:
image: install prune config genkeys customfiles boot compress-usr mfsroot fbsddist ${IMAGE}
${IMAGE}:
    @echo -n "Creating image file ..."
.if defined(BSDPART)
    ${_v}${MKDIR} ${WRKDIR}/mnt ${WRKDIR}/trees/base/boot
    ${_v}${INSTALL} -m 0444 ${WRKDIR}/disk/boot/boot ${WRKDIR}/trees/base/boot/
    ${_v}${DOFS} ${BSDLABEL} "" ${WRKDIR}/disk.img ${WRKDIR} ${WRKDIR}/mnt 0 ${WRKDIR}/disk 80000 auto > /dev/null 2> /dev/null
    ${_v}${RM} -rf ${WRKDIR}/mnt ${WRKDIR}/trees
    ${_v}${MV} ${WRKDIR}/disk.img ${.TARGET}
.else
    ${_v}${TOOLSDIR}/do_gpt.sh ${.TARGET} ${WRKDIR}/disk 0 ${WRKDIR}/boot ${VERB}
.endif
    @echo " done"
    ${_v}${LS} -l ${.TARGET}
 
As i understand the purpose of the this scrip: https://github.com/mmatuska/mfsbsd/blob/master/INSTALL.md

The do_gpt.sh script is used during the make to create a single partition for the image that's why it utilize the entire disk space.

Code:
image: install prune config genkeys customfiles boot compress-usr mfsroot fbsddist ${IMAGE}
${IMAGE}:
    @echo -n "Creating image file ..."
.if defined(BSDPART)
    ${_v}${MKDIR} ${WRKDIR}/mnt ${WRKDIR}/trees/base/boot
    ${_v}${INSTALL} -m 0444 ${WRKDIR}/disk/boot/boot ${WRKDIR}/trees/base/boot/
    ${_v}${DOFS} ${BSDLABEL} "" ${WRKDIR}/disk.img ${WRKDIR} ${WRKDIR}/mnt 0 ${WRKDIR}/disk 80000 auto > /dev/null 2> /dev/null
    ${_v}${RM} -rf ${WRKDIR}/mnt ${WRKDIR}/trees
    ${_v}${MV} ${WRKDIR}/disk.img ${.TARGET}
.else
    ${_v}${TOOLSDIR}/do_gpt.sh ${.TARGET} ${WRKDIR}/disk 0 ${WRKDIR}/boot ${VERB}
.endif
    @echo " done"
    ${_v}${LS} -l ${.TARGET}
How can I create multiple GPT partitions and automated install the os

I use the "bsdinstall script installerconfig" - where my partitions and configs are mentioned..

I also tried ZFS(zfsinstall) but again system is not booting with it.

I feel that I am missing some thing but unable to find .
 
I'm sorry i didn't understand your question because your topic was for mfsbsd not about bsdinstall script. So let's summarize you are creating a bootable media using mfsbsd with modified bsdinstall preamble scrip

If you look at bsdinstall (8)manual you will see that you must specify the disk scheme also. Check this part:

scriptedpart parameters
...
disk
[scheme] [{partitions}]
...
If scheme is unspecified, scriptedpart will
apply the default bootable scheme on your platform.
...

So you are restricted by the number of the MBR partitions because you didn't specify the GPT scheme.
 
Hey,

The handbook is a bit dated on that topic, take a look at this thread where I discuss that topic with a modern GPT and UEFI boot setup.


I see two things...
1. You can't create a new scheme on your disk before destroying the old one. You script has to start with gpart destroy -F /dev/.... before the gpart create ....
2. If FreeBSD won't boot, make sure you install the right bootcode. You installed legacy bootcode for GPT from your script, this can't be booted from in UEFI mode.


Such scripts as yours are REALLY destructive when accidentally run on the wrong device!
I would never ever run such a script without a serial number check of the drive before actually executing gpart commands.
e.g.
if [ `camcontrol inquiry /dev/da0 -S` != "575841314536363045365455" ]; then exit 1
Camcontrol inquiry works only when there are no partitions mounted on that drive. This command requires root priv.

This one is a little more easy to use, as it allways works and doesn't require root.
diskinfo -v /dev/da0 | grep ident | cut -f2
 
I'm sorry i didn't understand your question because your topic was for mfsbsd not about bsdinstall script. So let's summarize you are creating a bootable media using mfsbsd with modified bsdinstall preamble scrip

If you look at bsdinstall (8)manual you will see that you must specify the disk scheme also. Check this part:



So you are restricted by the number of the MBR partitions because you didn't specify the GPT scheme.


Yes Originally its related to MFSBSD but here I am using installerconfig with bsdinstall , part of the mfsbsd
 
Hey,

The handbook is a bit dated on that topic, take a look at this thread where I discuss that topic with a modern GPT and UEFI boot setup.


I see two things...
1. You can't create a new scheme on your disk before destroying the old one. You script has to start with gpart destroy -F /dev/.... before the gpart create ....
2. If FreeBSD won't boot, make sure you install the right bootcode. You installed legacy bootcode for GPT from your script, this can't be booted from in UEFI mode.


Such scripts as yours are REALLY destructive when accidentally run on the wrong device!
I would never ever run such a script without a serial number check of the drive before actually executing gpart commands.
e.g.
if [ `camcontrol inquiry /dev/da0 -S` != "575841314536363045365455" ]; then exit 1
Camcontrol inquiry works only when there are no partitions mounted on that drive. This command requires root priv.

This one is a little more easy to use, as it allways works and doesn't require root.
diskinfo -v /dev/da0 | grep ident | cut -f2
Thanks,
I will test and update!
 
btw your initial script also must work if you boot under UEFI.

If i boot the virtual machine under Hyper-V generation 1 BIOS mode the bsdinstall scriptedpart da1 will create the partition scheme with MBR limited to 4 FreeBSD partitions.

If i boot the virtual machine under Hyper-V generation 2 UEFI mode the bsdinstall scriptedpart da1 will create the partition scheme with GPT and you will be able to create up to 128 partitions.
 
btw your initial script also must work if you boot under UEFI.

If i boot the virtual machine under Hyper-V generation 1 BIOS mode the bsdinstall scriptedpart da1 will create the partition scheme with MBR limited to 4 FreeBSD partitions.

If i boot the virtual machine under Hyper-V generation 2 UEFI mode the bsdinstall scriptedpart da1 will create the partition scheme with GPT and you will be able to create up to 128 partitions.

Thanks for information, it really helped me!
 
Thank you every one.

Has any one tried ZFS partition with mfsbsd and installer script? it would be great if you share details on zfs

I used zfsinstall script (mfsbsd script) but unable to boot with zfs
 
Back
Top