WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ ubuntu-*-cloudimg-console.log
/.tmp/
/output/
/cache/
/*userpatches*/
/userpatches
#/*userpatches*/
#/userpatches

### General annoyances ###
.DS_Store
Expand Down
2 changes: 2 additions & 0 deletions config/kernel/linux-rk35xx-vendor.config
Original file line number Diff line number Diff line change
Expand Up @@ -2740,6 +2740,8 @@ CONFIG_DMA_CMA=y
CONFIG_PRINTK_TIME=y
CONFIG_PRINTK_TIME_FROM_ARM_ARCH_TIMER=y
CONFIG_DYNAMIC_DEBUG=y
CONFIG_DEBUG_INFO_DWARF5=y
CONFIG_DEBUG_INFO_BTF=y
CONFIG_MAGIC_SYSRQ=y
CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE=0
CONFIG_DEBUG_MEMORY_INIT=y
Expand Down
74 changes: 74 additions & 0 deletions format-extra-partitions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash
# Format and rename partitions in the latest Armbian image
# Layout:
# p1 = boot
# p2 = recovery
# p3 = rootfs
# p4 = userdata

set -e

IMG_DIR="/build/os-boy/new-build/build/output/images"

# Find the newest .img file
IMG=$(ls -1t "$IMG_DIR"/*.img 2>/dev/null | head -n1)
if [ -z "$IMG" ]; then
echo "❌ No image file found in $IMG_DIR"
exit 1
fi

echo "[🌱] Found image: $IMG"
echo "[🌱] Setting up loop device..."

# Create loop device with partition mappings
LOOP=$(losetup -fP --show "$IMG")
echo "→ Using $LOOP"
sleep 1

# --- Format partitions ---
if [ -b "${LOOP}p2" ]; then
echo "[🪄] Formatting ${LOOP}p2 as ext4 (recovery)"
mkfs.ext4 -F -L recovery "${LOOP}p2"
else
echo "⚠️ Partition 2 not found (skipped)"
fi

if [ -b "${LOOP}p4" ]; then
echo "[🪄] Formatting ${LOOP}p4 as ext4 (userdata)"
mkfs.ext4 -F -L userdata "${LOOP}p4"
else
echo "⚠️ Partition 4 not found (skipped)"
fi

# --- Rename all partition labels for consistency ---
echo "[✏️] Renaming partition labels..."

if [ -b "${LOOP}p1" ]; then
e2label "${LOOP}p1" boot || true
fi
if [ -b "${LOOP}p2" ]; then
e2label "${LOOP}p2" recovery || true
fi
if [ -b "${LOOP}p3" ]; then
e2label "${LOOP}p3" rootfs || true
fi
if [ -b "${LOOP}p4" ]; then
e2label "${LOOP}p4" userdata || true
fi

# Force kernel to re-read partition info
sync
partprobe "$LOOP"
sleep 1

# --- Verify labels ---
echo "[🔍] Partition labels after rename:"
lsblk "$LOOP" -o NAME,LABEL,SIZE,TYPE

# --- Cleanup ---
sync
echo "[🌿] Detaching loop device..."
losetup -d "$LOOP"

echo "[✅] Format and label complete: $IMG"

62 changes: 62 additions & 0 deletions inject-rootfs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash
set -e

IMG_DIR="/build/os-boy/new-build/build/output/images"
DATA_TAR="/build/os-boy/user-data.tar.gz"
MNT_DIR="/mnt/userdata"

# --- Step 1 – find latest image file ---
IMG_FILE=$(ls -t "${IMG_DIR}"/*.img "${IMG_DIR}"/*.raw 2>/dev/null | head -n 1)
if [[ -z "$IMG_FILE" ]]; then
echo "[ERROR] No image found in ${IMG_DIR}"
exit 1
fi
echo "[+] Found image: $IMG_FILE"

# --- Step 2 – setup loop device ---
LOOP=$(losetup -f --show -P "$IMG_FILE")
echo "[+] Loop device attached: $LOOP"

# --- Step 3 – identify userdata partition (p4) ---
PART="${LOOP}p4"
if [[ ! -b "$PART" ]]; then
echo "[ERROR] ${PART} not found — check partition layout."
losetup -d "$LOOP"
exit 1
fi

# --- Step 4 – ensure filesystem exists (format if needed) ---
FS_TYPE=$(blkid -o value -s TYPE "$PART" || true)
if [[ -z "$FS_TYPE" ]]; then
echo "[+] No filesystem detected on $PART — formatting as ext4 (label=userdata)..."
mkfs.ext4 -L userdata "$PART"
else
echo "[+] Detected existing filesystem ($FS_TYPE) on $PART"
fi

# --- Step 5 – mount and copy file ---
mkdir -p "$MNT_DIR"
echo "[+] Mounting ${PART}..."
mount "$PART" "$MNT_DIR"

FREE_SPACE=$(df -m --output=avail "$MNT_DIR" | tail -n 1)
FILE_SIZE=$(du -m "$DATA_TAR" | cut -f1)
if (( FREE_SPACE < FILE_SIZE + 50 )); then
echo "[WARNING] Low space: only ${FREE_SPACE} MB available, file is ${FILE_SIZE} MB"
fi

DEST_PATH="$MNT_DIR/user-data.tar.gz"
echo "[+] Copying ${DATA_TAR} → ${DEST_PATH}"
cp "$DATA_TAR" "$DEST_PATH"

sync
echo "[+] File copied successfully to userdata partition."

# --- Step 6 – cleanup ---
echo "[+] Unmounting and detaching loop..."
umount "$MNT_DIR"
losetup -d "$LOOP"
rmdir "$MNT_DIR"

echo "[✓] Done. user-data.tar.gz injected into partition 4 (/userdata) successfully!"

3 changes: 3 additions & 0 deletions lib/functions/image/partitioning.sh
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ function prepare_partitions() {
display_alert "Checking again after partprobe" "${LOOP}" "debug"
check_loop_device "${LOOP}" # check again, now it has to have a size! otherwise wait.

# --- CUSTOM PATCH: force root partition to p3 instead of default p2 ---
rootpart=3

# stage: create fs, mount partitions, create fstab
rm -f $SDCARD/etc/fstab

Expand Down
55 changes: 55 additions & 0 deletions update-fstab.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

set -e

IMG_DIR="/build/os-boy/new-build/build/output/images"

# Find the newest .img file
IMG=$(ls -1t "$IMG_DIR"/*.img 2>/dev/null | head -n1)
if [ -z "$IMG" ]; then
echo "❌ No image file found in $IMG_DIR"
exit 1
fi

echo "[🧠] Updating fstab inside: $IMG"

# Setup loop device
LOOP=$(losetup -fP --show "$IMG")
echo "→ Using $LOOP"
sleep 1

# Mount rootfs (partition 3)
if [ -b "${LOOP}p3" ]; then
mkdir -p /mnt/rootfs
mount "${LOOP}p3" /mnt/rootfs
echo "[🧾] Writing /etc/fstab..."

cat << 'EOF' > /mnt/rootfs/etc/fstab
# Do not direct edit this file, this file was generated from the update-fstab script.
/dev/mmcblk1p3 / ext4 defaults,noatime,commit=120,errors=remount-ro 0 1
/dev/mmcblk1p1 /boot ext4 defaults,ro 0 2
/dev/mmcblk1p4 /user-data ext4 defaults,noatime,commit=120,errors=remount-ro 0 2
#/user-data/root /root none bind 0 0
#/user-data/home /home none bind 0 0
tmpfs /tmp tmpfs defaults,nosuid 0 0
EOF

# Ensure mountpoint exists
mkdir -p /mnt/rootfs/user-data
sync
umount /mnt/rootfs

echo "[🧩] Running filesystem checks..."
e2fsck -y "${LOOP}p3" || true
if [ -b "${LOOP}p4" ]; then
e2fsck -y "${LOOP}p4" || true
fi

echo "[✅] fstab updated and filesystems verified"
else
echo "⚠️ Partition 3 (rootfs) not found!"
fi

# Cleanup
losetup -d "$LOOP"
echo "[🌿] Done."
25 changes: 25 additions & 0 deletions userpatches/config-example.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# See build framework documentation for a detailed explanation of all available switches:
# https://docs.armbian.com/Developer-Guide_Build-Switches/

# This example config file can be issue by running
# ./compile.sh example
# and will output a ready to run image as described below

# ATTENTION: This file may get out of date since updating the build framework
# ("git pull" to say) does not automatically update this file.
# To regenerate an up-to-date sample config simply delete this file.


BOARD=rock-5b # Build something for the Radxa ROCK 5B as further specified below
BRANCH=current # Use _current_ branch which equals to latest available Linux LTS kernel
RELEASE=bookworm # Use Debian Bookworm userspace
KERNEL_CONFIGURE=no # skip dialog prompt for adjusting the Linux kernel configuration
INSTALL_HEADERS=yes # Install Linux kernel headers while building. Can be useful for 3rd party drivers
SHARE_LOGS=yes # Upload logs to Armbian's paste service to share with developers
BUILD_DESKTOP=no # Do not install a graphical desktop environment
BUILD_MINIMAL=no # Install common CLI utils

# advanced

# Use build host DNS server inside chroot instead of default 1.0.0.1
NAMESERVER=$(grep nameserver /etc/resolv.conf|awk '{ print $2 }'| head -n 1)
Loading