improve partitioning moar
This commit is contained in:
parent
15a158431a
commit
3ef2b90cad
@ -17,21 +17,31 @@ done
|
|||||||
|
|
||||||
function create_new_image {
|
function create_new_image {
|
||||||
UBOOT_MAX_SIZE='32'
|
UBOOT_MAX_SIZE='32'
|
||||||
EFI_END=$(( 256 + UBOOT_MAX_SIZE ))
|
|
||||||
BOOT_START=$(( EFI_END + 1 ))
|
|
||||||
BOOT_END=$(( BOOT_START + 1024 ))
|
|
||||||
ROOT_START=$(( BOOT_END + 1 ))
|
|
||||||
IMAGE_SIZE=$(( $(stat -c '%s' "${IMAGE_NAME}") / 1024 / 1024 ))
|
IMAGE_SIZE=$(( $(stat -c '%s' "${IMAGE_NAME}") / 1024 / 1024 ))
|
||||||
NEW_IMAGE_NAME="${IMAGE_NAME}.new"
|
NEW_IMAGE_NAME="${IMAGE_NAME}.new"
|
||||||
truncate -s "$(( IMAGE_SIZE + (UBOOT_MAX_SIZE * 2) ))"MiB "${NEW_IMAGE_NAME}"
|
truncate -s "$(( IMAGE_SIZE + (UBOOT_MAX_SIZE * 2) ))"MiB "${NEW_IMAGE_NAME}"
|
||||||
|
|
||||||
LOOPBACK_01=$(losetup -f -P --show "${IMAGE_NAME}")
|
LOOPBACK_01=$(losetup -f -P --show "${IMAGE_NAME}")
|
||||||
LOOPBACK_02=$(losetup -f -P --show "${NEW_IMAGE_NAME}")
|
LOOPBACK_02=$(losetup -f -P --show "${NEW_IMAGE_NAME}")
|
||||||
|
UEFI_SECTORS="$(fdisk -l "${LOOPBACK_02}" | grep "${LOOPBACK_02}p1" | awk '{print $4}')"
|
||||||
|
BOOT_SECTORS="$(fdisk -l "${LOOPBACK_02}" | grep "${LOOPBACK_02}p2" | awk '{print $4}')"
|
||||||
|
|
||||||
parted -s "${LOOPBACK_02}" -- mklabel gpt
|
cat << EOF | fdisk "${LOOPBACK_02}"
|
||||||
parted -s "${LOOPBACK_02}" -- mkpart rockyefi fat32 "${UBOOT_MAX_SIZE}"MiB "${EFI_END}"MiB
|
g
|
||||||
parted -s "${LOOPBACK_02}" -- mkpart rockyboot ext4 "${BOOT_START}"MiB "${BOOT_END}"MiB
|
n
|
||||||
parted -s "${LOOPBACK_02}" -- mkpart rockyroot ext4 "${ROOT_START}"MiB 100%
|
1
|
||||||
|
65536
|
||||||
|
+${UEFI_SECTORS}
|
||||||
|
n
|
||||||
|
2
|
||||||
|
|
||||||
|
+${BOOT_SECTORS}
|
||||||
|
n
|
||||||
|
3
|
||||||
|
|
||||||
|
|
||||||
|
w
|
||||||
|
EOF
|
||||||
sync; sync; sync; sync;
|
sync; sync; sync; sync;
|
||||||
sleep 10
|
sleep 10
|
||||||
hdparm -z "${LOOPBACK_02}"
|
hdparm -z "${LOOPBACK_02}"
|
||||||
@ -44,6 +54,8 @@ function create_new_image {
|
|||||||
|
|
||||||
losetup -d "${LOOPBACK_02}"
|
losetup -d "${LOOPBACK_02}"
|
||||||
losetup -d "${LOOPBACK_01}"
|
losetup -d "${LOOPBACK_01}"
|
||||||
|
fdisk -l "${NEW_IMAGE_NAME}"
|
||||||
|
fdisk -l "${IMAGE_NAME}"
|
||||||
mv "${NEW_IMAGE_NAME}" "${IMAGE_NAME}"
|
mv "${NEW_IMAGE_NAME}" "${IMAGE_NAME}"
|
||||||
sync; sync; sync; sync;
|
sync; sync; sync; sync;
|
||||||
sleep 10
|
sleep 10
|
||||||
|
Loading…
Reference in New Issue
Block a user