EMMC questions regarding backing up and using microSD as storage

EMMC has been flashed and LePotato boots from it. My questions are below

How can I now back up the finished image to the onboard microSD card? mmcblk0 is a 32gb EMMC. You can see mmcblk1 is showing up and is a 32gb microSD

Can I use the onboard microSD as additional storage? Is there a way to automatically expand to current file system to both storage devices combined?

To backup the eMMC:

  1. Flash a MicroSD card with some OS and insert it into the board.
  2. Interrupt the bootloader and type in run bootcmd_mmc1.
  3. Once the MicroSD card OS is booted, run sudo dd if=/dev/mmcblk0 of=backup.img bs=1M. Your MicroSD card has to be larger than your eMMC. If you want to compress it before writing it to the MicroSD card, run sudo dd if=/dev/mmcblk0 bs=1M | gzip > backup.img.gz

To use MicroSD card as additional storage, just boot from the eMMC and use mkfs.FS /dev/mmcblk1 and replace FS with ext4 or btrfs or xfs or vfat etc. Setup a mount entry in /dev/fstab.

You have to modify the image via a loopback device or before backing up and insert an expansion script to run.

# Provides:          resize2fs_once
# Required-Start:
# Required-Stop:
# Default-Start: 3
# Default-Stop:
# Short-Description: Resize the root filesystem to fill partition
# Description:
. /lib/lsb/init-functions
case "$1" in
    log_daemon_msg "Starting resize2fs_once"
    ROOT_DEV=$(findmnt / -o source -nv | sed -E "s/p?[0-9]\$//") &&
    sfdisk -d $ROOT_DEV | sed "s/size=\s\+[0-9]*,\s\+type=83/type=83/" | sfdisk --force $ROOT_DEV &&
    partprobe $ROOT_DEV &&
    btrfs fi resize max / &&
    update-rc.d resize2fs_once remove &&
    rm /etc/init.d/resize2fs_once &&
    log_end_msg $?
    echo "Usage: $0 start" >&2
    exit 3
1 Like