P1
This commit is contained in:
@@ -49,18 +49,15 @@ function get_boot_size() {
|
||||
|
||||
|
||||
function create_spl_image() {
|
||||
local spl_data="${BINARIES_DIR}/${1}"
|
||||
local spl_img="${BINARIES_DIR}/spl.img"
|
||||
local spl_seek=$(($2-2))
|
||||
local boot_img="$(path_spl_img)"
|
||||
|
||||
dd if=/dev/zero of=${spl_img} bs=512 count=16382
|
||||
dd if=${spl_data} of=${spl_img} conv=notrunc bs=512 seek=${spl_seek}
|
||||
dd if=/dev/zero of=${boot_img} bs=512 count=16382
|
||||
}
|
||||
|
||||
|
||||
function create_boot_image() {
|
||||
local boot_data="${BINARIES_DIR}/boot"
|
||||
local boot_img="${BINARIES_DIR}/boot.vfat"
|
||||
local boot_data="$(path_boot_dir)"
|
||||
local boot_img="$(path_boot_img)"
|
||||
|
||||
echo "mtools_skip_check=1" > ~/.mtoolsrc
|
||||
dd if=/dev/zero of=${boot_img} bs=$(get_boot_size) count=1
|
||||
@@ -70,7 +67,7 @@ function create_boot_image() {
|
||||
|
||||
|
||||
function create_overlay_image() {
|
||||
local overlay_img="${BINARIES_DIR}/overlay.ext4"
|
||||
local overlay_img="$(path_overlay_img)"
|
||||
|
||||
dd if=/dev/zero of=${overlay_img} bs=${OVERLAY_SIZE} count=1
|
||||
mkfs.ext4 -L "hassos-overlay" -E lazy_itable_init=0,lazy_journal_init=0 ${overlay_img}
|
||||
@@ -78,7 +75,7 @@ function create_overlay_image() {
|
||||
|
||||
|
||||
function create_kernel_image() {
|
||||
local kernel_img="${BINARIES_DIR}/kernel.ext4"
|
||||
local kernel_img="$(path_kernel_img)"
|
||||
local kernel="${BINARIES_DIR}/${KERNEL_FILE}"
|
||||
|
||||
# Make image
|
||||
@@ -93,7 +90,7 @@ function create_kernel_image() {
|
||||
}
|
||||
|
||||
|
||||
function prepare_disk_image() {
|
||||
function _prepare_disk_image() {
|
||||
create_boot_image
|
||||
create_overlay_image
|
||||
create_kernel_image
|
||||
@@ -101,13 +98,24 @@ function prepare_disk_image() {
|
||||
|
||||
|
||||
function create_disk_image() {
|
||||
local boot_img="${BINARIES_DIR}/boot.vfat"
|
||||
local rootfs_img="${BINARIES_DIR}/rootfs.squashfs"
|
||||
local overlay_img="${BINARIES_DIR}/overlay.ext4"
|
||||
local data_img="${BINARIES_DIR}/data.ext4"
|
||||
local kernel_img="${BINARIES_DIR}/kernel.ext4"
|
||||
_prepare_disk_image
|
||||
|
||||
if [ "${BOOT_SYS}" == "mbr" ]; then
|
||||
_create_disk_mbr
|
||||
else
|
||||
_create_disk_gpt
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function _create_disk_gpt() {
|
||||
local boot_img="$(path_boot_img)"
|
||||
local rootfs_img="$(path_boot_img)"
|
||||
local overlay_img="$(path_overlay_img)"
|
||||
local data_img="$(path_data_img)"
|
||||
local kernel_img="$(path_kernel_img)"
|
||||
local hdd_img="$(hassos_image_name img)"
|
||||
local hdd_count=${1:-2}
|
||||
local hdd_count=${DISK_SIZE:-2}
|
||||
|
||||
local boot_offset=0
|
||||
local rootfs_offset=0
|
||||
@@ -167,28 +175,28 @@ function create_disk_image() {
|
||||
dd if=${data_img} of=${hdd_img} conv=notrunc bs=512 seek=${data_offset}
|
||||
|
||||
# Fix boot
|
||||
if [ "${BOOT_SYS}" == "mbr" ]; then
|
||||
fix_disk_image_mbr
|
||||
if [ "${BOOT_SYS}" == "hyprid" ]; then
|
||||
_fix_disk_hyprid
|
||||
elif [ "${BOOT_SYS}" == "spl" ]; then
|
||||
fix_disk_image_spl
|
||||
_fix_disk_spl_gpt
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function create_disk_mbr() {
|
||||
local disk_layout="${BINARIES_DIR}/disk.layout"
|
||||
local boot_img="${BINARIES_DIR}/boot.vfat"
|
||||
local rootfs_img="${BINARIES_DIR}/rootfs.squashfs"
|
||||
local overlay_img="${BINARIES_DIR}/overlay.ext4"
|
||||
local data_img="${BINARIES_DIR}/data.ext4"
|
||||
local kernel_img="${BINARIES_DIR}/kernel.ext4"
|
||||
function _create_disk_mbr() {
|
||||
local boot_img="$(path_boot_img)"
|
||||
local rootfs_img="$(path_boot_img)"
|
||||
local overlay_img="$(path_overlay_img)"
|
||||
local data_img="$(path_data_img)"
|
||||
local kernel_img="$(path_kernel_img)"
|
||||
local hdd_img="$(hassos_image_name img)"
|
||||
local hdd_count=${1:-2}
|
||||
local hdd_count=${DISK_SIZE:-2}
|
||||
local disk_layout="${BINARIES_DIR}/disk.layout"
|
||||
|
||||
# Write new image & MBR
|
||||
dd if=/dev/zero of=${hdd_img} bs=1G count=${hdd_count}
|
||||
|
||||
local boot_start=2048
|
||||
let boot_start=16384
|
||||
|
||||
let boot_size=$(size2sectors ${BOOT_SIZE})+2
|
||||
let kernel0_size=$(size2sectors ${KERNEL_SIZE})+2
|
||||
@@ -223,10 +231,10 @@ function create_disk_mbr() {
|
||||
echo "unit: sectors"
|
||||
echo "hassos-boot : start= ${boot_start}, size= ${boot_size}, type=c, bootable" #create the boot partition
|
||||
echo "hassos-extended : start= ${extended_start}, size= ${extended_size}, type=5" #Make an extended partition
|
||||
echo "hassos-kernela : start= ${kernel0_start}, size= ${kernel0_size}, type=83" #Make a logical partition
|
||||
echo "hassos-systema : start= ${system0_start}, size= ${system0_size}, type=83" #Make a logical partition
|
||||
echo "hassos-kernelb : start= ${kernel1_start} size= ${kernel1_size}, type=83" #Make a logical partition
|
||||
echo "hassos-systemb : start= ${system1_start}, size= ${system1_size}, type=83" #Make a logical partition
|
||||
echo "hassos-kernel0 : start= ${kernel0_start}, size= ${kernel0_size}, type=83" #Make a logical partition
|
||||
echo "hassos-system0 : start= ${system0_start}, size= ${system0_size}, type=83" #Make a logical partition
|
||||
echo "hassos-kernel1 : start= ${kernel1_start} size= ${kernel1_size}, type=83" #Make a logical partition
|
||||
echo "hassos-system1 : start= ${system1_start}, size= ${system1_size}, type=83" #Make a logical partition
|
||||
echo "hassos-bootstate : start= ${bootstate_start}, size= ${bootstate_size}, type=83" #Make a logical partition
|
||||
echo "hassos-overlay : start= ${overlay_start}, size= ${overlay_size}, type=83" #Make a logical partition
|
||||
echo "hassos-data : start= ${data_start}, size= ${data_size}, type=83" #Make a logical partition
|
||||
@@ -236,15 +244,18 @@ function create_disk_mbr() {
|
||||
sfdisk ${hdd_img} < ${disk_layout}
|
||||
|
||||
# Write Images
|
||||
dd if=${boot_img} of=${hdd_img} conv=notrunc bs=512 obs=512 seek=${boot_offset}
|
||||
dd if=${kernel_img} of=${hdd_img} conv=notrunc bs=512 obs=512 seek=${kernel_offset}
|
||||
dd if=${rootfs_img} of=${hdd_img} conv=notrunc bs=512 obs=512 seek=${rootfs_offset}
|
||||
dd if=${overlay_img} of=${hdd_img} conv=notrunc bs=512 obs=512 seek=${overlay_offset}
|
||||
dd if=${data_img} of=${hdd_img} conv=notrunc bs=512 obs=512 seek=${data_offset}
|
||||
dd if=${boot_img} of=${hdd_img} conv=notrunc bs=512 seek=${boot_offset}
|
||||
dd if=${kernel_img} of=${hdd_img} conv=notrunc bs=512 seek=${kernel_offset}
|
||||
dd if=${rootfs_img} of=${hdd_img} conv=notrunc bs=512 seek=${rootfs_offset}
|
||||
dd if=${overlay_img} of=${hdd_img} conv=notrunc bs=512 seek=${overlay_offset}
|
||||
dd if=${data_img} of=${hdd_img} conv=notrunc bs=512 seek=${data_offset}
|
||||
|
||||
# Wripte SPL
|
||||
_fix_disk_spl_mbr
|
||||
}
|
||||
|
||||
|
||||
function fix_disk_image_mbr() {
|
||||
function _fix_disk_hyprid() {
|
||||
local hdd_img="$(hassos_image_name img)"
|
||||
|
||||
sgdisk -t 1:"E3C9E316-0B5C-4DB8-817D-F92DF00215AE" ${hdd_img}
|
||||
@@ -252,13 +263,25 @@ function fix_disk_image_mbr() {
|
||||
}
|
||||
|
||||
|
||||
function fix_disk_image_spl() {
|
||||
function _fix_disk_spl_gpt() {
|
||||
local hdd_img="$(hassos_image_name img)"
|
||||
local spl_img="${BINARIES_DIR}/spl.img"
|
||||
local spl_img="$(path_spl_img)"
|
||||
local backup="/tmp/mbr-backup.bin"
|
||||
|
||||
sgdisk -t 1:"E3C9E316-0B5C-4DB8-817D-F92DF00215AE" ${hdd_img}
|
||||
dd if=${BR2_EXTERNAL_HASSOS_PATH}/misc/mbr-spl.img of=${hdd_img} conv=notrunc bs=512 count=1
|
||||
dd if=${spl_img} of=${hdd_img} conv=notrunc bs=512 seek=2
|
||||
dd if=${spl_img} of=${hdd_img} conv=notrunc bs=512 seek=2 skip=2
|
||||
}
|
||||
|
||||
|
||||
function _fix_disk_spl_mbr() {
|
||||
local hdd_img="$(hassos_image_name img)"
|
||||
local spl_img="$(path_spl_img)"
|
||||
|
||||
# backup MBR
|
||||
dd if=${hdd_img} of=${backup} bs=1 count=72 skip=440
|
||||
dd if=${spl_img} of=${hdd_img} conv=notrunc bs=512
|
||||
dd if=${backup} of=${hdd_img} conv=notrunc bs=1 skip=440
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user