TS-4720 eMMC Backup/restore: Difference between revisions

From embeddedTS Manuals
No edit summary
No edit summary
Line 5: Line 5:


{{Warning|Make sure the SD and eMMC filesystems are mounted read only while writing any images.  If dd is used to read or write a disk while a filesystem on it is mounted read/write this can result in a corrupt image.}}
{{Warning|Make sure the SD and eMMC filesystems are mounted read only while writing any images.  If dd is used to read or write a disk while a filesystem on it is mounted read/write this can result in a corrupt image.}}
First boot to the initramfs.  These steps should '''not be run from the full Debian environment''', so to get back to the initramfs, first run:
<source lang=bash>
tshwctl --removejp 1 && reboot
</source>
Once you are in the initramfs, mount a network share or usb drive containing the emmc image.


''' Write an Image to eMMC '''
''' Write an Image to eMMC '''


The onboard eMMC uses the same image as the MicroSD card.  To program the eMMC chip you would need to first boot to the MicroSD card.  From the stock SD image initramfs you can use dd to write the SD image to the eMMC:
<source lang=bash>
<source lang=bash>
dd if=/dev/nbd0 of=/dev/nbd1 bs=4M conv=fsync
# Check /mnt/root.  If it shows a file "root.version", you can proceed.
#/dev/nbd0 is the microSD
# If it shows nothing, you need to wait for the Debian filesystem
#/dev/nbd1 is the eMMC
ls /mnt/root/
#bs=4M is not required but will speed up the copy
 
#conv=fsync causes dd to flush all writes to the disk immediately rather than use cache
 
</source>
# Plug in a thumbdrive formatted with ext2/3/4 or fat32/ntfs
mkdir /mnt/usbdev
mount /dev/sda1 /mnt/usbdev
umount -l /mnt/root/
 
# Tell sdctl to pause so we don't kill it during a burst
killall -USR1 sdctl
# Allow time for any buffered writes to finish
sleep 5
killall sdctl


Alternatively you can use a usb drive with a copy of the eMMC image:
# The dblstor-disable command only tells the card to
<source lang=bash>
# ignore any doublestore metadata on the eMMC during
# The first partition of a usb drive would be at /dev/sda1
# this write.  It does not prevent reading/writing doublestore
mkdir /mnt/usb/
# formatted media.
mount /dev/sda1 /mnt/usb/
# This command can be expected to take about 10 minutes
dd if=/mnt/usb/emmcImage.dd of=/dev/nbd1  bs=4M conv=fsync
sdctl --lun 1 -z 65536 --dblstor-disable -i /mnt/usbdev/emmc-image.dd
reboot
</source>
</source>


''' Create image from eMMC '''
These steps can write the eMMC image to use a single-card [[#Doublestore]], or you can write the [ftp://ftp.embeddedarm.com/ts-socket-macrocontrollers/ts-4710-linux/binaries/ts-images/4gbsd-471x-latest.dd.bz2 SD Image]] to not use doublestore.


Since the eMMC and SD images are the same you can use an SD card to backup the eMMC image.  This will replace the contents of the MicroSD card with the eMMC image:
''' Save an image from eMMC '''


<source lang=bash>
<source lang=bash>
# Boot from SD (/dev/nbd1) will not start the nbd-client for eMMC.  This only needs
# Plug in a thumbdrive formatted with ext2/3/4 or fat32
# to be started once per boot to access eMMC with:
mkdir /mnt/usbdev
nbd-client 127.0.0.1 7500 /dev/nbd0
mount /dev/sda1 /mnt/usbdev
dd if=/dev/nbd1 of=/dev/nbd0 bs=4M conv=fsync
umount -l /mnt/root/
#/dev/nbd1 is the eMMC
 
#/dev/nbd0 is the microSD
# Tell sdctl to pause so we don't kill it during a burst
#bs=4M is not required but will speed up the copy
killall -USR1 sdctl
#conv=fsync causes dd to flush all writes to the disk immediately rather than use cache
# Allow time for any buffered writes to finish
</source>
sleep 5
killall sdctl


Alternatively you can use a usb drive as the location to store the eMMC image:
sdctl --lun 1 -z 65536 --dblstor-disable --nbdserver lun1:disc
<source lang=bash>
nbd-client 127.0.0.1 7500 /dev/nbd1
# The first partition of a usb drive would be at /dev/sda1
dd if=/dev/nbd1 bs=4M of=/mnt/usbdev/emmc-image.dd
mkdir /mnt/usb/
sync
mount /dev/sda1 /mnt/usb/
dd if=/dev/nbd1 of=/mnt/usb/emmcBackup.dd bs=4M conv=fsync
</source>
</source>

Revision as of 10:40, 10 June 2014

EMMC.png Click to download the latest 4GB SD card image.
WARNING: Make sure the SD and eMMC filesystems are mounted read only while writing any images. If dd is used to read or write a disk while a filesystem on it is mounted read/write this can result in a corrupt image.

First boot to the initramfs. These steps should not be run from the full Debian environment, so to get back to the initramfs, first run:

tshwctl --removejp 1 && reboot

Once you are in the initramfs, mount a network share or usb drive containing the emmc image.

Write an Image to eMMC

# Check /mnt/root.  If it shows a file "root.version", you can proceed.
# If it shows nothing, you need to wait for the Debian filesystem
ls /mnt/root/


# Plug in a thumbdrive formatted with ext2/3/4 or fat32/ntfs
mkdir /mnt/usbdev
mount /dev/sda1 /mnt/usbdev
umount -l /mnt/root/

# Tell sdctl to pause so we don't kill it during a burst
killall -USR1 sdctl
# Allow time for any buffered writes to finish
sleep 5 
killall sdctl

# The dblstor-disable command only tells the card to
# ignore any doublestore metadata on the eMMC during
# this write.  It does not prevent reading/writing doublestore
# formatted media.
# This command can be expected to take about 10 minutes
sdctl --lun 1 -z 65536 --dblstor-disable -i /mnt/usbdev/emmc-image.dd
reboot

These steps can write the eMMC image to use a single-card #Doublestore, or you can write the SD Image] to not use doublestore.

Save an image from eMMC

# Plug in a thumbdrive formatted with ext2/3/4 or fat32
mkdir /mnt/usbdev
mount /dev/sda1 /mnt/usbdev
umount -l /mnt/root/

# Tell sdctl to pause so we don't kill it during a burst
killall -USR1 sdctl
# Allow time for any buffered writes to finish
sleep 5 
killall sdctl

sdctl --lun 1 -z 65536 --dblstor-disable --nbdserver lun1:disc
nbd-client 127.0.0.1 7500 /dev/nbd1
dd if=/dev/nbd1 bs=4M of=/mnt/usbdev/emmc-image.dd
sync