Remove recovery partition
This commit is contained in:
@@ -12,9 +12,11 @@ mkdir -p "${ROOTFS_DIR}"
|
||||
BOOT_SIZE="$((512 * 1024 * 1024))"
|
||||
ROOT_SIZE=$(du -x --apparent-size -s "${EXPORT_ROOTFS_DIR}" --exclude var/cache/apt/archives --exclude boot/firmware --block-size=1 | cut -f 1)
|
||||
|
||||
# All partition sizes and starts will be aligned to this size
|
||||
ALIGN="$((4 * 1024 * 1024))"
|
||||
ROOT_MARGIN="$(echo "($ROOT_SIZE * 0.2 + 400 * 1024 * 1024) / 1" | bc)"
|
||||
|
||||
# Recovery partition fixed size: 256MB
|
||||
RECOVERY_SIZE="$((256 * 1024 * 1024))"
|
||||
|
||||
BOOT_PART_START=$((ALIGN))
|
||||
@@ -29,8 +31,8 @@ truncate -s "${IMG_SIZE}" "${IMG_FILE}"
|
||||
|
||||
parted --script "${IMG_FILE}" mklabel msdos
|
||||
parted --script "${IMG_FILE}" unit B mkpart primary fat32 "${BOOT_PART_START}" "$((BOOT_PART_START + BOOT_PART_SIZE - 1))"
|
||||
parted --script "${IMG_FILE}" unit B mkpart primary fat32 "${RECOVERY_PART_START}" "$((RECOVERY_PART_START + RECOVERY_PART_SIZE - 1))"
|
||||
parted --script "${IMG_FILE}" unit B mkpart primary ext4 "${ROOT_PART_START}" "$((ROOT_PART_START + ROOT_PART_SIZE - 1))"
|
||||
parted --script "${IMG_FILE}" unit B mkpart primary ext4 "${RECOVERY_PART_START}" "$((RECOVERY_PART_START + RECOVERY_PART_SIZE - 1))"
|
||||
|
||||
echo "Creating loop device..."
|
||||
cnt=0
|
||||
@@ -65,24 +67,16 @@ fi
|
||||
|
||||
mkdosfs -n bootfs -F "$FAT_SIZE" -s 4 -v "$BOOT_DEV" > /dev/null
|
||||
mkfs.ext4 -L rootfs -O "$ROOT_FEATURES" "$ROOT_DEV" > /dev/null
|
||||
mkdosfs -n recovery -F "32" -s 4 -v "$RECOVERY_DEV" > /dev/null
|
||||
#mkfs.ext4 -L recoveryfs -O "$ROOT_FEATURES" "$RECOVERY_DEV" > /dev/null
|
||||
|
||||
# Create new layout
|
||||
mkdir -p "${ROOTFS_DIR}/part1"
|
||||
mkdir -p "${ROOTFS_DIR}/part2"
|
||||
mount -v "$ROOT_DEV" "${ROOTFS_DIR}" -t ext4
|
||||
mkdir -p "${ROOTFS_DIR}/boot/firmware"
|
||||
mount -v "$BOOT_DEV" "${ROOTFS_DIR}/boot/firmware" -t vfat
|
||||
#mkdir -p "${ROOTFS_DIR}/recovery"
|
||||
#mount -v "$RECOVERY_DEV" "${ROOTFS_DIR}/recovery" -t ext4
|
||||
|
||||
mount -v "$BOOT_DEV" "${ROOTFS_DIR}/part1" -t vfat
|
||||
mount -v "$RECOVERY_DEV" "${ROOTFS_DIR}/part2" -t vfat
|
||||
rsync -aHAXx --exclude /var/cache/apt/archives --exclude /boot/firmware "${EXPORT_ROOTFS_DIR}/" "${ROOTFS_DIR}/"
|
||||
rsync -rtx "${EXPORT_ROOTFS_DIR}/boot/firmware/" "${ROOTFS_DIR}/boot/firmware/"
|
||||
#rsync -aHAXx "${EXPORT_ROOTFS_DIR}/recovery/" "${ROOTFS_DIR}/recovery/"
|
||||
|
||||
mkdir -p "${ROOTFS_DIR}/part1/bootfs"
|
||||
mkdir -p "${ROOTFS_DIR}/part1/rootfs"
|
||||
mkdir -p "${ROOTFS_DIR}/part2/recovery"
|
||||
|
||||
mount -v "$ROOT_DEV" "${ROOTFS_DIR}/part1/rootfs" -t ext4
|
||||
|
||||
# Copy files
|
||||
rsync -aHAXx --exclude /var/cache/apt/archives --exclude /boot/firmware "${EXPORT_ROOTFS_DIR}/" "${ROOTFS_DIR}/part1/rootfs/"
|
||||
rsync -rtx "${EXPORT_ROOTFS_DIR}/boot/firmware/" "${ROOTFS_DIR}/part1/bootfs/"
|
||||
|
||||
# If you have recovery files to copy, uncomment:
|
||||
# rsync -aHAXx "${EXPORT_ROOTFS_DIR}/recovery/" "${ROOTFS_DIR}/part2/recovery/"
|
||||
echo "Image created with boot, rootfs, and 256MB recovery partition."
|
Reference in New Issue
Block a user