Deleted the emmc partition

To migrate to NVME I did the stupid thing an deleted the partions of the emmc. Is there a way to restore / reflash? I can boot from SD.

Hi,

no worries, as long as you didn’t delete u-boot on the eMMC boot sector (it takes some effort to do that, though), you can still boot from MicroSD card and use the following part from our factory install script to re-image the eMMC freshly. Copy it to a text file and make it executable (with chmod a+x).

The script requires a few tools, to make sure these are installed, do:

apt install bmap-tools e2fsprogs parted

And here’s the main install script:

#!/bin/bash
echo "Copying MNT Pocket Reform System Image to eMMC..."

sudo bmaptool copy https://source.mnt.re/reform/reform-system-image/-/jobs/4400/artifacts/raw/pocket-reform-system-imx8mp.img.gz /dev/mmcblk2

echo "System Image copied. Resizing root partition..."

parted /dev/mmcblk2 resizepart 2 100%
sleep 1
sync
e2fsck -fy /dev/mmcblk2p2
resize2fs -p /dev/mmcblk2p2
e2fsck -fy /dev/mmcblk2p2

echo "Relabeling eMMC partitions..."

ROOTPART=reformemmcroot
BOOTPART=reformemmcboot

e2label /dev/mmcblk2p1 $BOOTPART
e2label /dev/mmcblk2p2 $ROOTPART

mount /dev/mmcblk2p2 /mnt

cat << END > "/mnt/etc/fstab"
/dev/mmcblk2p2 / auto errors=remount-ro 0 1
/dev/mmcblk2p1 /boot auto errors=remount-ro 0 1
END

mount -o bind /dev "/mnt/dev"
mount -t sysfs sys "/mnt/sys"
mount -t proc proc "/mnt/proc"
mount /dev/mmcblk2p1 /mnt/boot
chroot "/mnt" update-initramfs -u

umount --recursive /mnt

echo "Done."
9 Likes

Thanks a lot!!! Worked! Great support!

2 Likes