Skip to content

Commit

Permalink
Rework boot partition options
Browse files Browse the repository at this point in the history
  • Loading branch information
zador-blood-stained committed Apr 23, 2017
1 parent 80e371b commit e203564
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 32 deletions.
2 changes: 1 addition & 1 deletion build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ buildall_start=`date +%s`
n=0
for line in "${buildlist[@]}"; do
unset LINUXFAMILY LINUXCONFIG KERNELDIR KERNELSOURCE KERNELBRANCH BOOTDIR BOOTSOURCE BOOTBRANCH ARCH UBOOT_NEEDS_GCC KERNEL_NEEDS_GCC \
CPUMIN CPUMAX UBOOT_VER KERNEL_VER GOVERNOR BOOTSIZE UBOOT_TOOLCHAIN KERNEL_TOOLCHAIN PACKAGE_LIST_EXCLUDE KERNEL_IMAGE_TYPE \
CPUMIN CPUMAX UBOOT_VER KERNEL_VER GOVERNOR BOOTSIZE BOOTFS_TYPE UBOOT_TOOLCHAIN KERNEL_TOOLCHAIN PACKAGE_LIST_EXCLUDE KERNEL_IMAGE_TYPE \
write_uboot_platform family_tweaks setup_write_uboot_platform BOOTSCRIPT UBOOT_TARGET_MAP LOCALVERSION UBOOT_COMPILER KERNEL_COMPILER \
MODULES MODULES_NEXT MODULES_DEV INITRD_ARCH HAS_UUID_SUPPORT BOOTENV_FILE BOOTDELAY MODULES_BLACKLIST MODULES_BLACKLIST_NEXT \
MODULES_BLACKLIST_DEV MOUNT SDCARD BOOTPATCHDIR buildtext RELEASE UBOOT_ALT_GCC KERNEL_ALT_GCC IMAGE_TYPE OVERLAY_PREFIX
Expand Down
12 changes: 9 additions & 3 deletions configuration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ ARCH=armhf
KERNEL_IMAGE_TYPE=zImage
SERIALCON=ttyS0

# WARNING: This option is deprecated
BOOTSIZE=0
# single ext4 partition is the default and preferred configuration
BOOTFS_TYPE=''

# set unique mounting directory
SDCARD="sdcard-${BRANCH}-${BOARD}-${RELEASE}-${BUILD_DESKTOP}"
Expand Down Expand Up @@ -191,6 +191,7 @@ Version: $(cd $SRC/lib; git rev-parse @)
Build target:
Board: $BOARD
Branch: $BRANCH
Desktop: $BUILD_DESKTOP
Kernel configuration:
Repository: $KERNELSOURCE
Expand All @@ -200,8 +201,13 @@ Config file: $LINUXCONFIG
U-boot configuration:
Repository: $BOOTSOURCE
Branch: $BOOTBRANCH
Config file: $BOOTCONFIG
Partitioning configuration:
Root partition type: $ROOTFS_TYPE
Boot partition type: ${BOOTFS_TYPE:-(none)}
User provided boot partition size: ${BOOTSIZE:-0}
Offset: $OFFSET
Size: $BOOTSIZE
CPU configuration:
$CPUMIN - $CPUMAX with $GOVERNOR
Expand Down
58 changes: 30 additions & 28 deletions debootstrap-ng.sh
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,8 @@ prepare_partitions()
display_alert "Preparing image file for rootfs" "$BOARD $RELEASE" "info"

# possible partition combinations
# ext4 root only (BOOTSIZE == 0 && ROOTFS_TYPE == ext4)
# ext4 boot + non-ext4 local root (BOOTSIZE == 0; ROOTFS_TYPE != ext4 or nfs)
# fat32 boot + ext4 root (BOOTSIZE > 0 && ROOTFS_TYPE == ext4)
# fat32 boot + non-ext4 local root (BOOTSIZE > 0; ROOTFS_TYPE != ext4 or nfs)
# ext4 boot + NFS root (BOOTSIZE == 0; ROOTFS_TYPE == nfs)
# fat32 boot + NFS root (BOOTSIZE > 0; ROOTFS_TYPE == nfs)
# /boot: none, ext4, ext2, fat (BOOTFS_TYPE)
# root: ext4, btrfs, f2fs, nfs (ROOTFS_TYPE)

# declare makes local variables by default if used inside a function
# NOTE: mountopts string should always start with comma if not empty
Expand All @@ -268,6 +264,7 @@ prepare_partitions()
declare -A parttype mkopts mkfs mountopts

parttype[ext4]=ext4
parttype[ext2]=ext2
parttype[fat]=fat16
parttype[f2fs]=ext4 # not a copy-paste error
parttype[btrfs]=btrfs
Expand All @@ -282,22 +279,49 @@ prepare_partitions()
fi

mkopts[fat]='-n BOOT'
mkopts[ext2]='-q'
# mkopts[f2fs] is empty
# mkopts[btrfs] is empty
# mkopts[nfs] is empty

mkfs[ext4]=ext4
mkfs[ext2]=ext2
mkfs[fat]=vfat
mkfs[f2fs]=f2fs
mkfs[btrfs]=btrfs
# mkfs[nfs] is empty

mountopts[ext4]=',commit=600,errors=remount-ro'
# mountopts[ext2] is empty
# mountopts[fat] is empty
# mountopts[f2fs] is empty
# mountopts[btrfs] is empty
# mountopts[nfs] is empty

# stage: determine partition configuration
if [[ -n $BOOTFS_TYPE ]]; then
# 2 partition setup with forced /boot type
local bootfs=$BOOTFS_TYPE
local bootpart=1
local rootpart=2
[[ -z $BOOTSIZE || $BOOTSIZE -le 8 ]] && BOOTSIZE=64 # MiB
elif [[ $ROOTFS_TYPE != ext4 && $ROOTFS_TYPE != nfs ]]; then
# 2 partition setup for non-ext4 local root
local bootfs=ext4
local bootpart=1
local rootpart=2
[[ -z $BOOTSIZE || $BOOTSIZE -le 8 ]] && BOOTSIZE=64 # MiB
elif [[ $ROOTFS_TYPE == nfs ]]; then
# single partition ext4 /boot, no root
local bootfs=ext4
local bootpart=1
[[ -z $BOOTSIZE || $BOOTSIZE -le 8 ]] && BOOTSIZE=64 # MiB, For cleanup processing only
else
# single partition ext4 root
local rootpart=1
BOOTSIZE=0
fi

# stage: calculate rootfs size
local rootfs_size=$(du -sm $CACHEDIR/$SDCARD/ | cut -f1) # MiB
display_alert "Current rootfs size" "$rootfs_size MiB" "info"
Expand All @@ -319,28 +343,6 @@ prepare_partitions()
display_alert "Creating blank image for rootfs" "$sdsize MiB" "info"
dd if=/dev/zero bs=1M status=none count=$sdsize | pv -p -b -r -s $(( $sdsize * 1024 * 1024 )) | dd status=none of=$CACHEDIR/${SDCARD}.raw

# stage: determine partition configuration
if [[ $BOOTSIZE != 0 ]]; then
# fat32 /boot + ext4 or other root, deprecated
local bootfs=fat
local bootpart=1
local rootpart=2
elif [[ $ROOTFS_TYPE != ext4 && $ROOTFS_TYPE != nfs ]]; then
# ext4 /boot + non-ext4 root
BOOTSIZE=64 # MiB
local bootfs=ext4
local bootpart=1
local rootpart=2
elif [[ $ROOTFS_TYPE == nfs ]]; then
# ext4 /boot, no root
BOOTSIZE=64 # For cleanup processing only
local bootfs=ext4
local bootpart=1
else
# ext4 root
local rootpart=1
fi

# stage: calculate boot partition size
local bootstart=$(($OFFSET * 2048))
local rootstart=$(($bootstart + ($BOOTSIZE * 2048)))
Expand Down

0 comments on commit e203564

Please sign in to comment.