diff options
author | Stefano Stabellini | 2022-03-31 10:09:50 -0700 |
---|---|---|
committer | Stefano Stabellini | 2022-04-06 12:55:34 -0700 |
commit | 96b30388509a9bcff297f8eaa91cae5546842573 (patch) | |
tree | 3a8bdfdfcfe922c214955d61037efbf71302c98a | |
parent | 60f2a6d5af3a36dcb28768a18f61ade70cbf21b5 (diff) |
disk_image: use DOS partition table and FAT for the first partition
This way, ImageBuilder can generate an SD card image with BOOT.BIN
bootable on Xilinx ZCU102 systems.
Retain the ability to generate a GPT partition table with a GPT
config option.
Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
Tested-by: Andrea Stevanato <andrea.stevanato@santannapisa.it>
-rw-r--r-- | README.md | 6 | ||||
-rwxr-xr-x | scripts/disk_image | 53 |
2 files changed, 43 insertions, 16 deletions
@@ -281,6 +281,12 @@ Where:\ for instance -t "fatload" is valid. +disk\_image supports these additional parameters on the config file: + +- GPT is optional and select the usage of a GPT partition table (sgdisk + is required) + + disk_image also generates on the fly a xl config file for each domU and adds them to the dom0 rootfs partition under /etc/xen. It makes it easier to start those domUs from dom0. diff --git a/scripts/disk_image b/scripts/disk_image index 1efc3af..12fb06b 100755 --- a/scripts/disk_image +++ b/scripts/disk_image @@ -1,6 +1,6 @@ #!/bin/bash -PROG_REQ=( kpartx mkfs.ext4 losetup sgdisk readlink awk ) +PROG_REQ=( kpartx mkfs.ext4 mkfs.vfat losetup readlink awk parted ) SLACK=128 function cleanup_disk_image() @@ -366,7 +366,7 @@ function generate_domU_configs() local dest local dtb_name - mount -t ext4 /dev/mapper/diskimage$j $DESTDIR/part/disk$j + mount /dev/mapper/diskimage$j $DESTDIR/part/disk$j mkdir -p $DESTDIR/part/disk$j/etc/xen add_rootfs 0 first_part=$retval @@ -512,7 +512,7 @@ function write_rootfs() # create mount point and mount diskn mkdir -p ${DESTDIR}/part/disk$j - mount -t ext4 /dev/mapper/diskimage$j $DESTDIR/part/disk$j + mount /dev/mapper/diskimage$j $DESTDIR/part/disk$j # Extract rootfs cpio archive into `.../part/vos_$j` cd ${DESTDIR}/part/disk$j @@ -756,17 +756,37 @@ fi # 528 MiB (256 + 256 + 16) truncate $IMG -s "$_tot_size"M -# create GPT partition table -sgdisk -og $IMG +if test "$GPT" +then + # create GPT partition table + sgdisk -og $IMG -i=0 -j=1 -while test $i -lt $_npart -do - sgdisk -n $j:${_sector_start[$i]}:${_sector_end[$i]} -c $j:"Linux""$j" -t $j:8300 $IMG - i=$(( $i + 1 )) - j=$(( $j + 1 )) -done + i=0 + j=1 + while test $i -lt $_npart + do + sgdisk -n $j:${_sector_start[$i]}:${_sector_end[$i]} -c $j:"Linux""$j" -t $j:8300 $IMG + i=$(( $i + 1 )) + j=$(( $j + 1 )) + done +else + tmp_dos=`mktemp` + tmp_files+=($tmp_dos) + + i=0 + parted -s $IMG mklabel "msdos" + parted $IMG mkpart primary fat32 "${_sector_start[$i]}"s "${_sector_end[$i]}"s + parted $IMG set 1 boot on + + i=1 + j=2 + while test $i -lt $_npart + do + parted $IMG mkpart logical ext4 "${_sector_start[$i]}"s "${_sector_end[$i]}"s + i=$(( $i + 1 )) + j=$(( $j + 1 )) + done +fi # find the first available loop device _loop_dev=$(losetup -f) @@ -792,8 +812,9 @@ do sleep 2 done -i=0 -j=1 +mkfs.vfat -F 32 -n boot /dev/mapper/diskimage1 +i=1 +j=2 while test $i -lt $_npart do mkfs.ext4 -L vos_$j -F /dev/mapper/diskimage$j @@ -803,7 +824,7 @@ done # create mount point and mount disk1 mkdir -p ${DESTDIR}/part/disk1 -mount -t ext4 /dev/mapper/diskimage1 $DESTDIR/part/disk1 +mount /dev/mapper/diskimage1 $DESTDIR/part/disk1 # only copy over files that were counted for the partition size cd "$UBOOT_OUT" |