OrangePI and other ARM single-board computers often use eMMC or SD cards with limited write endurance. Over time, storage fills up, degrades, or fails. This guide describes a method for data recovery and migration to external storage (USB SSD/HDD) via a chroot environment.
π‘ Method is universal: works for OrangePI, Raspberry Pi, NanoPi, and other ARM systems.
π¦ Preparation
Requirements
| Component | Requirements |
|---|---|
| USB drive | SSD/HDD, capacity β₯ eMMC data |
| Live image | Any Linux with ARM support (optional) |
| Access | root or sudo, physical access to board |
| Network | Ethernet or WiFi (for remote access) |
Check connected storage
# Show all MMC devices (eMMC, SD card)
ls /dev/mmc*
# Show all block devices
lsblk
# Show partitions and mount points
df -h
Expected output:
/dev/mmcblk0- built-in eMMC or SD card/dev/sda,/dev/sdb- connected USB drives
π§ Mounting partitions
Step 1: Mount eMMC root filesystem
# Create mount point
mkdir -p /mnt
# Mount root partition (usually mmcblk0p1 or p2)
mount /dev/mmcblk0p2 /mnt
Why:
- Direct access to filesystem for diagnostics
- Ability to boot from USB but work with eMMC data
Step 2: Connect external storage
# Create USB mount point
mkdir -p /mnt/usb
# Mount USB partition
mount /dev/sda1 /mnt/usb
Why USB:
- eMMC has limited write cycles (~10K cycles)
- USB SSD is more reliable for long-term storage
- Easier to replace when degraded
Step 3: Verify accessibility
# Confirm partitions are mounted
df -h /mnt
df -h /mnt/usb
# Check access permissions
ls -la /mnt/
ls -la /mnt/usb/
π Working via chroot
Enter chroot environment
# Change root to mounted system
chroot /mnt /bin/bash
What chroot provides:
- Work inside original system, not live image
- Access to installed packages, configs, services
- Run commands as the target system
Verify inside chroot
# Confirm we're in the right system
hostname
cat /etc/os-release
# Check mounts inside chroot
df -h
β οΈ If
/proc,/sys,/devneeded - mount before chroot:mount -t proc proc /mnt/proc mount -t sysfs sys /mnt/sys mount --bind /dev /mnt/dev
π Analyze disk usage
Check usage by directory
# Home directory size
du -h /home
# Project/application size
du -h /opt/project
# Overall partition stats
df -h /
Why du -h:
-h- human-readable format (K, M, G)- Shows actual disk usage, not file sizes
- Helps find “space hogs”
Find large files
# Find files > 100MB
find / -type f -size +100M -exec ls -lh {} \;
# Top 10 largest directories
du -h / | sort -rh | head -10
π Data migration via rsync
Basic sync
# Copy home directory and projects to USB
rsync -av /home /opt/project /mnt/usb/
rsync options:
-a- archive mode (preserves permissions, links, timestamps)-v- verbose (shows copy progress)
Advanced sync
# With progress and deletion of extra files on target
rsync -av --progress --delete /home /opt/project /mnt/usb/
# With compression for slow connections
rsync -avz --progress /home /opt/project /mnt/usb/
Why rsync, not cp:
- Copies only changed files on re-run
- Preserves all metadata (owner, permissions, timestamps)
- Shows progress and speed
- Can be interrupted and resumed
Verify after copy
# Compare source and destination sizes
du -sh /home /opt/project
du -sh /mnt/usb/home /mnt/usb/project
# Check checksums (optional)
md5sum /home/user/.bashrc
md5sum /mnt/usb/home/user/.bashrc
π Boot from USB (optional)
Change boot configuration
# For OrangePI with U-Boot
# Edit /boot/boot.cmd or /boot/uEnv.txt
# Specify USB as root partition
# Example for uEnv.txt:
setenv bootargs 'console=ttyS0,115200 root=/dev/sda1 rootwait'
Or via fstab
# Mount USB as root on boot
# /etc/fstab
/dev/sda1 / ext4 defaults,noatime 0 1
Why boot from USB:
- Offload eMMC from writes (system logs, cache)
- Extend built-in storage lifespan
- Easy replacement/upgrade without reflashing
π‘ Recovery after failure
If system won’t boot
# Boot from live image (SD card or network)
# Mount eMMC and USB as described above
# Use rsync to recover data
If eMMC fully degraded
# Move entire system to USB
rsync -avx / /mnt/usb/
# Reinstall bootloader on USB
# For U-Boot:
dd if=/usr/lib/u-boot/orangepi_pc_plus/u-boot-sunxi-with-spl.bin of=/dev/sda bs=1024 seek=8
β οΈ Bootloader operations require exact board model matching!
π§ Diagnostic commands
# Check eMMC health (if supported)
smartctl -a /dev/mmcblk0
# Check write errors in logs
dmesg | grep -iE 'error|fail|mmc'
# Get USB drive model and speed
lsusb -t
hdparm -I /dev/sda
# Test read/write speed
dd if=/dev/zero of=/mnt/usb/test bs=1M count=1024 conv=fdatasync
dd if=/mnt/usb/test of=/dev/null bs=1M
β οΈ Common issues
# USB not detected
β Check power: some SSDs need external power supply
β Try different USB 3.0 port
β Check dmesg | tail after connection
# Mount error
β Check filesystem: fsck /dev/sda1
β Ensure partition not busy: umount /dev/sda1
# rsync interrupted
β Use --partial for resume:
rsync -av --partial /source /dest
β Check power stability
# chroot not working
β Mount pseudo-FS before chroot:
mount -t proc proc /mnt/proc
mount --bind /dev /mnt/dev
β Check architecture: uname -m
Links
- π OrangePI Official Wiki
- π¦ Armbian Documentation
- π§ rsync Man Page
- πΎ eMMC vs SSD Lifespan