Re: How to add an UFS2 partition on a mbr style partition disk.
Mario Marietto <[email protected]>
| Newsgroups | gmane.os.freebsd.devel.arm |
|---|---|
| Message-ID | <CA+1FSihAoOCeMzxg2PbF9UZWJfmP9gxw2mcM=CdnpDcmQoL9EA@mail.gmail.com> |
Errata corrige : # gpart list da7 | grep rawuuid nothing. On Sun, Jul 13, 2025 at 4:59 PM Mario Marietto <[email protected]> wrote: > Hello. > > Following the man page I have created da7 with the MBR scheme and I've > added the second partition as UFS2 giving the following commands : > > # gpart create -s MBR da7 > # gpart add -t freebsd -s 119G -a 4k da7 > # gpart set -a active -i 1 da7 > # gpart bootcode -b /boot/boot0 da7 > # gpart create -s BSD -n 20 da7s1 > > > => 63 249737153 da7 MBR (119G) > 63 1985 - free - (993K) > 2048 102400 1 fat32lba [active] (50M) > 104448 249561088 2 freebsd (119G) > 249665536 71680 - free - (35M) > > > Now the problem is that I'm not able to determine the uuid of da7s2a,that > is required by the boot.scr script that should be stored on da7s1 : > > # gpart list da7s2a | grep rawuuid > nothing. > > Why ? How to fix it ? thanks. > > On Sun, Jul 13, 2025 at 3:22 PM Ronald Klop <[email protected]> wrote: > >> Hi, >> >> AFAIK, MBR or GPT does not relate to the amount of bits. There are >> reasons why GPT and 64bit system are often used together, but is not >> necessary. Google or ChatGPT can probably tell you more details about this >> than I can come up with from the top of my head. >> >> To be precise I have an RPI3B. It runs 64 bits FreeBSD. >> https://dmesgd.nycbug.org/index.cgi?do=view&id=8422 >> >> Regards, >> Ronald. >>  >> >> *Van:* Mario Marietto <[email protected]> >> *Datum:* zondag, 13 juli 2025 14:36 >> *Aan:* Ronald Klop <[email protected]> >> *CC:* FreeBSD Mailing List <[email protected]>, freebsd-arm < >> [email protected]> >> *Onderwerp:* Re: How to add an UFS2 partition on a mbr style partition >> disk. >> >> Hello bro. >>  >> In your opinion can FreeBSD at 64 bit boot on a disk that's formatted >> with the MBR ? From what I know,64 bit will boot with GPT and 32 bit will >> boot with MBR. >>  >> I bet that your RPI3 runs FreeBSD at 32 bit ? >>  >> On Sun, Jul 13, 2025 at 2:06PM Ronald Klop <[email protected]> wrote: >> >>> I assume your question is 'how to make a bootable SDcard with MBR and >>> UFS2?' >>> In the man page of gpart (type: man gpart) go to the EXAMPLES section >>> and look for MBR. >>> >>> That contains an example of how to setup MBR + UFS2. >>> >>> You can play around a bit with it. My RPI3 boots from an SDcard with >>> this layout: >>> >>> gpart show >>> => 1 3994623 mmcsd0 MBR (1.9G) >>> 1 2047 - free - (1.0M) >>> 2048 102400 1 fat32lba [active] (50M) >>> 104448 3890176 2 freebsd (1.9G) >>> >>> => 0 3890176 ufs/rootfs BSD (1.9G) >>> 0 128 - free - (64K) >>> 128 3890048 1 freebsd-ufs (1.9G) >>> >>> Although in my config the SDcard only contains /boot. The kernel mounts >>> the rootfs from an SSD. >>> For your proof of concept I would advice to just write a full rootfs on >>> the SD. >>> >>> Hope this helps. >>> >>> Regards, >>> Ronald. >>> >>> Â >>> >>> *Van:* Mario Marietto <[email protected]> >>> *Datum:* zondag, 13 juli 2025 12:23 >>> *Aan:* FreeBSD Mailing List <[email protected]>, >>> freebsd-hackers <[email protected]>, freebsd-arm < >>> [email protected]> >>> *Onderwerp:* How to add an UFS2 partition on a mbr style partition disk. >>> >>> Hello. >>> >>> I've bought the nice board "KHADAS Edge-V" because I wanted to try to >>> boot FreeBSD from it. An old version of FreeBSD,version 13, is provided by >>> the company,but unfortunately it does not boot. Later I've found that the >>> reason or one of the reasons is because the board wants the sd card to be >>> "formatted" with an MBR style partition layout. >>> >>> I've understood that the image named >>> "Edge_Ubuntu-gnome-focal_Linux-5.7_arm64_SD-USB_V0.9.1-20200602.img" can >>> boot from the sd card,but the image named >>> "edge-freebsd-aarch64-13.0-release-20210613.img" can't do it. Why ? I've >>> crudely identified some crucial differences that make the magic. >>> >>> 1. >>> >>> the structure of the disk partitions that comes after having written >>> "Edge_Ubuntu-gnome-focal_Linux-5.7_arm64_SD-USB_V0.9.1-20200602.img" to the >>> sd card :=> 63 62333889 da1 MBR (30G) 63 32705 - free - (16M) 32768 491520 >>> 1 fat32 [active] (240M) 524288 61808640 2 linux-data (29G) 62332928 1024 - >>> free - (512K) >>> >>> MBR here is important. With a GPT disk it is not able to boot. >>> >>> 2) inside the fat32 partition there is a script like this : >>> >>> Â >>> >>> echo "Run Khadas boot script" >>> >>> # Constant >>> setenv BOARD_TYPE_NONE 0 >>> setenv BOARD_TYPE_EDGE 1 >>> setenv BOARD_TYPE_EDGE_V 2 >>> setenv BOARD_TYPE_CAPTAIN 3 >>> >>> # Detect board type >>> kbi boarddetect >>> >>> if test ${board_type} = ${BOARD_TYPE_NONE}; then >>> echo "Unsupported board detected! Stop here. Reboot..."; >>> sleep 5; >>> reset; >>> fi >>> >>> setenv emmc_root_part 7 >>> setenv emmc_boot_part 7 >>> setenv emmc_mbr_root_part 2 >>> setenv emmc_mbr_boot_part 1 >>> setenv sd_root_part 2 >>> setenv sd_boot_part 1 >>> >>> if test ${devnum} = 0; then >>> echo "Uboot loaded from eMMC."; >>> if test -e mmc ${devnum}:${emmc_root_part} zImage; then >>> setenv imagetype "EMMC"; >>> setenv boot_env_part ${emmc_boot_part}; >>> setenv root_part ${emmc_root_part}; >>> setenv mark_prefix "boot/"; >>> else >>> setenv imagetype "EMMC_MBR"; >>> setenv boot_env_part ${emmc_mbr_boot_part}; >>> setenv root_part ${emmc_mbr_root_part}; >>> setenv mark_prefix ""; >>> fi; >>> >>> if test -e mmc ${devnum}:${boot_env_part} ${mark_prefix}.next; then >>> setenv default_rootdev "/dev/mmcblk2p${root_part}" >>> else >>> setenv default_rootdev "/dev/mmcblk1p${root_part}" >>> fi >>> else if test ${devnum} = 1; then >>> echo "Uboot loaded from SD."; >>> setenv boot_env_part ${sd_boot_part}; >>> setenv root_part ${sd_root_part} >>> setenv mark_prefix "" >>> if test -e mmc ${devnum}:${boot_env_part} ${mark_prefix}.next; then >>> setenv default_rootdev "/dev/mmcblk1p${sd_root_part}" >>> else >>> setenv default_rootdev "/dev/mmcblk0p${sd_root_part}" >>> fi >>> setenv imagetype "SD-USB"; >>> fi;fi; >>> >>> # Import environment from env.txt >>> if load ${devtype} ${devnum}:${boot_env_part} ${ramdisk_addr_r} /boot/env.txt || load ${devtype} ${devnum}:${boot_env_part} ${ramdisk_addr_r} env.txt; then >>> echo "Import env.txt"; >>> env import -t ${ramdisk_addr_r} ${filesize} >>> fi >>> >>> # Check root part filesystem UUID >>> fsuuid ${devtype} ${devnum}:${root_part} root_uuid >>> if test "UUID=${root_uuid}" != "${rootdev}"; then >>> echo "Rootfs UUID mismatch! Set rootfs part to default: ${default_rootdev}" >>> setenv rootdev ${default_rootdev} >>> fi >>> >>> # Check MIPI >>> if test "${mipi_lcd_enabled}" = "true"; then >>> setenv dtb_suffix "-mipi"; >>> else >>> setenv dtb_suffix ""; >>> fi >>> >>> if test -e mmc ${devnum}:${boot_env_part} ${mark_prefix}.next; then >>> if test ${board_type} = ${BOARD_TYPE_EDGE}; then >>> setenv boot_dtb "rk3399-khadas-edge.dtb"; >>> else if test ${board_type} = ${BOARD_TYPE_EDGE_V}; then >>> setenv boot_dtb "rk3399-khadas-edge-v.dtb"; >>> else if test ${board_type} = ${BOARD_TYPE_CAPTAIN}; then >>> setenv boot_dtb "rk3399-khadas-edge-captain.dtb"; >>> fi;fi;fi >>> else >>> if test ${board_type} = ${BOARD_TYPE_EDGE}; then >>> setenv boot_dtb "rk3399-khadas-edge-linux.dtb"; >>> else if test ${board_type} = ${BOARD_TYPE_EDGE_V}; then >>> setenv boot_dtb "rk3399-khadas-edgev${dtb_suffix}-linux.dtb"; >>> else if test ${board_type} = ${BOARD_TYPE_CAPTAIN}; then >>> setenv boot_dtb "rk3399-khadas-captain${dtb_suffix}-linux.dtb"; >>> fi;fi;fi >>> fi >>> >>> if test ${devnum} = 0; then >>> if test -e mmc ${devnum}:${boot_env_part} ${mark_prefix}.next; then >>> if test ${imagetype} = EMMC_MBR; then >>> setenv dtb_prefix "/dtb/rockchip/"; >>> else >>> setenv dtb_prefix "/boot/dtb/rockchip/"; >>> fi >>> else >>> if test ${imagetype} = EMMC_MBR; then >>> setenv dtb_prefix "/dtb/"; >>> else >>> setenv dtb_prefix "/boot/dtb/"; >>> fi >>> fi >>> else if test ${devnum} = 1; then >>> if test -e mmc ${devnum}:${boot_env_part} ${mark_prefix}.next; then >>> setenv dtb_prefix "/dtb/rockchip/"; >>> else >>> setenv dtb_prefix "/dtb/"; >>> fi >>> fi;fi; >>> >>> echo DTB: ${dtb_prefix}${boot_dtb} >>> >>> if test -e mmc ${devnum}:${boot_env_part} ${mark_prefix}.next; then >>> setenv condev "earlyprintk console=ttyS2,1500000n8 console=tty0" >>> else >>> setenv condev "earlyprintk console=ttyFIQ0,1500000n8 console=tty0" >>> fi >>> >>> setenv boot_start booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r} >>> >>> part uuid mmc ${devnum}:1 ubootpartuuid; >>> if test "X${ubootpartuuid}" = "X"; then >>> echo "Can not get u-boot part UUID, set to NULL"; >>> setenv ubootpartuuid "NULL"; >>> fi; >>> >>> kbi ethmac >>> if test -e ${custom_ethmac}; then >>> echo "Found custom ethmac: ${custom_ethmac}, overwrite eth_mac!"; >>> setenv eth_mac ${custom_ethmac} >>> fi >>> >>> if test "X${eth_mac}" = "X" || test "X${eth_mac}" = "X00:00:00:00:00:00"; then >>> echo "Set default mac address to ethaddr: ${ethaddr}!"; >>> setenv eth_mac ${ethaddr}; >>> setenv saveethmac "save_ethmac=yes"; >>> fi; >>> >>> if test -e ${loglevel}; then >>> setenv log "loglevel=${loglevel}" >>> fi >>> >>> setenv bootargs "${bootargs} ${condev} ${log} rw root=${rootdev} rootfstype=ext4 init=/sbin/init rootwait ubootpart=${ubootpartuuid} board_type=${board_type} board_type_name=${board_type_name} khadas_board=${board_type_name} fan=${fan_mode} mac=${eth_mac} androidboot.mac=${eth_mac} ${saveethmac} coherent_pool=${dma_size} imagetype=${imagetype}" >>> >>> for distro_bootpart in ${devplist}; do >>> echo "Scanning ${devtype} ${devnum}:${distro_bootpart}..." >>> >>> if load ${devtype} ${devnum}:${distro_bootpart} ${ramdisk_addr_r} uInitrd; then >>> if load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} zImage; then >>> if load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${dtb_prefix}${boot_dtb}; then >>> run boot_start; >>> fi; >>> fi; >>> fi; >>> >>> done >>> >>> # Rebuilt >>> # mkimage -A arm64 -O linux -T script -C none -a 0 -e 0 -n "rk3399 autoscript" -d /boot/rk3399_autoscript.cmd /boot/boot.screcho "Run Khadas boot script" >>> >>> # Constant >>> setenv BOARD_TYPE_NONE 0 >>> setenv BOARD_TYPE_EDGE 1 >>> setenv BOARD_TYPE_EDGE_V 2 >>> setenv BOARD_TYPE_CAPTAIN 3 >>> >>> # Detect board type >>> kbi boarddetect >>> >>> if test ${board_type} = ${BOARD_TYPE_NONE}; then >>> echo "Unsupported board detected! Stop here. Reboot..."; >>> sleep 5; >>> reset; >>> fi >>> >>> setenv emmc_root_part 7 >>> setenv emmc_boot_part 7 >>> setenv emmc_mbr_root_part 2 >>> setenv emmc_mbr_boot_part 1 >>> setenv sd_root_part 2 >>> setenv sd_boot_part 1 >>> >>> if test ${devnum} = 0; then >>> echo "Uboot loaded from eMMC."; >>> if test -e mmc ${devnum}:${emmc_root_part} zImage; then >>> setenv imagetype "EMMC"; >>> setenv boot_env_part ${emmc_boot_part}; >>> setenv root_part ${emmc_root_part}; >>> setenv mark_prefix "boot/"; >>> else >>> setenv imagetype "EMMC_MBR"; >>> setenv boot_env_part ${emmc_mbr_boot_part}; >>> setenv root_part ${emmc_mbr_root_part}; >>> setenv mark_prefix ""; >>> fi; >>> >>> if test -e mmc ${devnum}:${boot_env_part} ${mark_prefix}.next; then >>> setenv default_rootdev "/dev/mmcblk2p${root_part}" >>> else >>> setenv default_rootdev "/dev/mmcblk1p${root_part}" >>> fi >>> else if test ${devnum} = 1; then >>> echo "Uboot loaded from SD."; >>> setenv boot_env_part ${sd_boot_part}; >>> setenv root_part ${sd_root_part} >>> setenv mark_prefix "" >>> if test -e mmc ${devnum}:${boot_env_part} ${mark_prefix}.next; then >>> setenv default_rootdev "/dev/mmcblk1p${sd_root_part}" >>> else >>> setenv default_rootdev "/dev/mmcblk0p${sd_root_part}" >>> fi >>> setenv imagetype "SD-USB"; >>> fi;fi; >>> >>> # Import environment from env.txt >>> if load ${devtype} ${devnum}:${boot_env_part} ${ramdisk_addr_r} /boot/env.txt || load ${devtype} ${devnum}:${boot_env_part} ${ramdisk_addr_r} env.txt; then >>> echo "Import env.txt"; >>> env import -t ${ramdisk_addr_r} ${filesize} >>> fi >>> >>> # Check root part filesystem UUID >>> fsuuid ${devtype} ${devnum}:${root_part} root_uuid >>> if test "UUID=${root_uuid}" != "${rootdev}"; then >>> echo "Rootfs UUID mismatch! Set rootfs part to default: ${default_rootdev}" >>> setenv rootdev ${default_rootdev} >>> fi >>> >>> # Check MIPI >>> if test "${mipi_lcd_enabled}" = "true"; then >>> setenv dtb_suffix "-mipi"; >>> else >>> setenv dtb_suffix ""; >>> fi >>> >>> if test -e mmc ${devnum}:${boot_env_part} ${mark_prefix}.next; then >>> if test ${board_type} = ${BOARD_TYPE_EDGE}; then >>> setenv boot_dtb "rk3399-khadas-edge.dtb"; >>> else if test ${board_type} = ${BOARD_TYPE_EDGE_V}; then >>> setenv boot_dtb "rk3399-khadas-edge-v.dtb"; >>> else if test ${board_type} = ${BOARD_TYPE_CAPTAIN}; then >>> setenv boot_dtb "rk3399-khadas-edge-captain.dtb"; >>> fi;fi;fi >>> else >>> if test ${board_type} = ${BOARD_TYPE_EDGE}; then >>> setenv boot_dtb "rk3399-khadas-edge-linux.dtb"; >>> else if test ${board_type} = ${BOARD_TYPE_EDGE_V}; then >>> setenv boot_dtb "rk3399-khadas-edgev${dtb_suffix}-linux.dtb"; >>> else if test ${board_type} = ${BOARD_TYPE_CAPTAIN}; then >>> setenv boot_dtb "rk3399-khadas-captain${dtb_suffix}-linux.dtb"; >>> fi;fi;fi >>> fi >>> >>> if test ${devnum} = 0; then >>> if test -e mmc ${devnum}:${boot_env_part} ${mark_prefix}.next; then >>> if test ${imagetype} = EMMC_MBR; then >>> setenv dtb_prefix "/dtb/rockchip/"; >>> else >>> setenv dtb_prefix "/boot/dtb/rockchip/"; >>> fi >>> else >>> if test ${imagetype} = EMMC_MBR; then >>> setenv dtb_prefix "/dtb/"; >>> else >>> setenv dtb_prefix "/boot/dtb/"; >>> fi >>> fi >>> else if test ${devnum} = 1; then >>> if test -e mmc ${devnum}:${boot_env_part} ${mark_prefix}.next; then >>> setenv dtb_prefix "/dtb/rockchip/"; >>> else >>> setenv dtb_prefix "/dtb/"; >>> fi >>> fi;fi; >>> >>> echo DTB: ${dtb_prefix}${boot_dtb} >>> >>> if test -e mmc ${devnum}:${boot_env_part} ${mark_prefix}.next; then >>> setenv condev "earlyprintk console=ttyS2,1500000n8 console=tty0" >>> else >>> setenv condev "earlyprintk console=ttyFIQ0,1500000n8 console=tty0" >>> fi >>> >>> setenv boot_start booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r} >>> >>> part uuid mmc ${devnum}:1 ubootpartuuid; >>> if test "X${ubootpartuuid}" = "X"; then >>> echo "Can not get u-boot part UUID, set to NULL"; >>> setenv ubootpartuuid "NULL"; >>> fi; >>> >>> kbi ethmac >>> if test -e ${custom_ethmac}; then >>> echo "Found custom ethmac: ${custom_ethmac}, overwrite eth_mac!"; >>> setenv eth_mac ${custom_ethmac} >>> fi >>> >>> if test "X${eth_mac}" = "X" || test "X${eth_mac}" = "X00:00:00:00:00:00"; then >>> echo "Set default mac address to ethaddr: ${ethaddr}!"; >>> setenv eth_mac ${ethaddr}; >>> setenv saveethmac "save_ethmac=yes"; >>> fi; >>> >>> if test -e ${loglevel}; then >>> setenv log "loglevel=${loglevel}" >>> fi >>> >>> setenv bootargs "${bootargs} ${condev} ${log} rw root=${rootdev} rootfstype=ext4 init=/sbin/init rootwait ubootpart=${ubootpartuuid} board_type=${board_type} board_type_name=${board_type_name} khadas_board=${board_type_name} fan=${fan_mode} mac=${eth_mac} androidboot.mac=${eth_mac} ${saveethmac} coherent_pool=${dma_size} imagetype=${imagetype}" >>> >>> for distro_bootpart in ${devplist}; do >>> echo "Scanning ${devtype} ${devnum}:${distro_bootpart}..." >>> >>> if load ${devtype} ${devnum}:${distro_bootpart} ${ramdisk_addr_r} uInitrd; then >>> if load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} zImage; then >>> if load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${dtb_prefix}${boot_dtb}; then >>> run boot_start; >>> fi; >>> fi; >>> fi; >>> >>> done >>> >>> # Rebuilt >>> # mkimage -A arm64 -O linux -T script -C none -a 0 -e 0 -n "rk3399 autoscript" -d /boot/rk3399_autoscript.cmd /boot/boot.scr >>> >>> Â >>> >>> I suspect that it has been compiled and it became the file "boot.scr" >>> that's responsible for the booting of Ubuntu from the sd card. This script >>> is not present on the EFI partition of the sd card where is installed >>> FreeBSD : >>> >>> Â >>> >>> => 40 500006832 da3 GPT (238G) >>> 40 32728 - free - (16M) >>> 32768 102400 1 efi (50M) >>> 135168 483708928 2 freebsd-ufs (231G) >>> 483844096 16154624 3 freebsd-swap (7.7G) >>> 499998720 8152 - free - (4.0M) >>> >>> Â >>> >>> anyway,I tried to put it there : >>> >>> Â >>> >>> marietto# cd /mnt/da3p1 >>> marietto# ls >>> >>> EFI dtb dtb-rock u-boot~1.bin >>> Edge-V dtb-RK3399 rk3399_autoscript.cmd ubootefi.var >>> boot.scr dtb-pinebook-pro splash.bmp ubootefi_.var >>> >>> Â >>> >>> What happened ? that FreeBSD does not boot,but is Android that's >>> installed on the internal EMMC that makes the boot. I'm pretty sure that >>> the script has been written specially for Ubuntu and it should be modified >>> to work with FreeBSD. >>> >>> But at the moment I need to understand how to add an UFS2 partition on >>> top of a MBR disk because the KHADAS Edge-V is not able to boot FreeBSD if >>> it stays inside a GPT disk. >>> -- >>> Mario. >>> >>> >>> Â >>> >>  >> >> -- >> Mario. >> >> >>  >> > > > -- > Mario. > -- Mario.