Create image from eMMC to SD card

I failed to create image from eMMC to SD card on my Xavier AGX:

➜  ~ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/mmcblk0p1   28G   18G  8.8G  67% /
none             16G     0   16G   0% /dev
tmpfs            16G   88K   16G   1% /dev/shm
tmpfs            16G   31M   16G   1% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs            16G     0   16G   0% /sys/fs/cgroup
tmpfs           3.2G   12K  3.2G   1% /run/user/120
tmpfs           3.2G  116K  3.2G   1% /run/user/1000
/dev/mmcblk1p1   29G   29G     0 100% /media/lvision/AGX-SD

And I got the following Nospace left on device ERROR

➜  ~ sudo dd bs=1024 if=/dev/mmcblk0 of=/dev/mmcblk1
[sudo] password for lvision:
dd: error writing '/dev/mmcblk1': No space left on device
30318593+0 records in
30318592+0 records out
31046238208 bytes (31 GB, 29 GiB) copied, 4605.66 s, 6.7 MB/s

while I tried to dd mmcblk0 which is ONLY used 18G to mmcblk1 which is of 29G size.

Can anybody give me a hand??

I suspect a typographic error. What do you see from “lsblk -f”? Normally eMMC would be rootfs of “/dev/mmcblk0p1” (note “p1”), and SD card’s first partition would be “mmcblk1p1” (also “p1”, but there might be other differences for the SD card…thus wondering what “lsblk -f” shows).

Hi, @linuxdev

➜  ~ lsblk -f
NAME         FSTYPE LABEL      UUID                                 MOUNTPOINT
loop0        vfat   L4T-README 1234-ABCD                            
mmcblk0                                                             
├─mmcblk0p1  ext4              8a8322bc-3c72-4bcd-96d1-a49a5b432dfa /
├─mmcblk0p2                                                         
├─mmcblk0p3                                                         
├─mmcblk0p4                                                         
├─mmcblk0p5                                                         
├─mmcblk0p6                                                         
├─mmcblk0p7                                                         
├─mmcblk0p8                                                         
├─mmcblk0p9                                                         
├─mmcblk0p10                                                        
├─mmcblk0p11                                                        
├─mmcblk0p12                                                        
├─mmcblk0p13                                                        
├─mmcblk0p14                                                        
├─mmcblk0p15                                                        
├─mmcblk0p16                                                        
├─mmcblk0p17                                                        
├─mmcblk0p18                                                        
├─mmcblk0p19                                                        
├─mmcblk0p20                                                        
├─mmcblk0p21                                                        
├─mmcblk0p22                                                        
├─mmcblk0p23                                                        
├─mmcblk0p24                                                        
├─mmcblk0p25                                                        
├─mmcblk0p26                                                        
├─mmcblk0p27                                                        
├─mmcblk0p28                                                        
├─mmcblk0p29                                                        
├─mmcblk0p30                                                        
├─mmcblk0p31                                                        
├─mmcblk0p32                                                        
├─mmcblk0p33                                                        
├─mmcblk0p34                                                        
├─mmcblk0p35                                                        
├─mmcblk0p36                                                        
├─mmcblk0p37                                                        
├─mmcblk0p38                                                        
├─mmcblk0p39                                                        
├─mmcblk0p40                                                        
├─mmcblk0p41                                                        
└─mmcblk0p42                                                        
mmcblk0boot0                                                        
mmcblk0boot1                                                        
mmcblk0rpmb                                                         
mmcblk1                                                             
└─mmcblk1p1  ext4   AGX-SD     5283dc45-f8d2-49ec-99c3-9089f05a55cc /media/lvision/AGX-SD
zram0                                                               [SWAP]
zram1                                                               [SWAP]
zram2                                                               [SWAP]
zram3                                                               [SWAP]

The mmcblk0 device is the main boot device since it has all of those extra partitions. The mmcblk0p1 is verified to have ext4 as the rootfs.

It is mounted, so you wouldn’t want to use dd with it, but mmcblk1 is verified as your SD card, and specifically mmcblk1p1 is the destination.

Your command “df -h” does indicate individual partition sizes, so anything “dd if=/devmmcblk0” will exceed the size of just “mmcblk0p1”. Are you trying to copy everything, or just the rootfs? If you want to keep a backup somewhere I can see why you might want to copy everything, but if this is for booting to, then that other content cannot be put on the SD card…just the rootfs.

Keep in mind that a dd command which places all of mmcblk0 onto SD card would produce all of those partitions, and not just one. “mmcblk0” also includes some invisible content for the GPT partition scheme, so total device copy exceeds the size required even for the sum of visible partitions (partition scheme data might be invisible, but its size is not zero).

FYI, you might continue after providing more details on exactly what you want to accomplish since there are a lot of little nuances which change how to go about what you are doing.

If you wanted to copy the rootfs to the SD card’s first partition, then it would go something like this (but if you’ve overwritten some of the invisible GPT data there might be additional steps):
sudo dd if=/dev/mmcblk0p1 of=/dev/mmcblk1p1 bs=1M
(notice that block size of bs=1M won’t change anything other than buffer size, and will be somewhat faster with a 1M block size…you could leave that out if you want)

Note that the danger here is that if mmcblk0p1 is a running filesystem, then it can change during copy. You could use Magic SysRq to at least make it read only (then reboot after the copy). Basically, if it is a local keyboard:

# Each "s" syncs.
alt+sysrq+s
alt+sysrq+s
# "u" remounts read-only
alt+sysrq+u

…make sure the SD card is not mounted at that time, and after the rootfs is read-only, then add the SD card. Do not mount the SD card anywhere, just dd to it without mount.

Note: “alt” is the ALT key, and there is a more obscure key near the scroll lock key which shows shifted as “PrtScn” (printscreen) and unshifted as “SysRq” (system request).

Thank you so much @linuxdev .

  1. My purpose is just to make a bootable SD card, which is configured exactly the same environment as my current eMMC.
  2. How can I guarentee booting from SD card instead of eMMC for Xavier AGX ?

It looks like your SD card is every so slightly smaller than the built-in eMMC in the Jetson. If you can find a larger SD card (such as a 64 GB card) then it will work fine with the sudo dd command you suggested:

sudo dd bs=1024 if=/dev/mmcblk0 of=/dev/mmcblk1

Note that bs=1024 is going to be very slow. Tyipcally when cloning disks, you’ll want to tack a k on the end; bs=1024k to read/write in gulps of 1 MB at a time. If you for some reason don’t like this, at least bumping up to bs=65536 is likely to increase throughput when cloning.

Note that the Jetson eMMC has a number of smallish partitions that are separate from the main mounted file system, used for a variety of purposes in the boot/flash/configuration process. Thus, the amount of space you need to clone the entire device, is more than just the size of the file system partition.

SEPARATELY, you should not have a file system mounted on the device you’re cloning to. You run a pretty significant risk that the kernel will flush some buffers from the file system into the middle of your cloned image, and there will be some silent random corruption on the output.

So, in your case, you’d actually want to do something like:

$ sudo umount /dev/mmcblk1p1
$ sudo dd if=/dev/mmcblk0 of=/dev/mmcblk1 bs=1024k
...
2 Likes

@snarky

Thank you for your detailed reply @snarky

  1. However, SD card larger than 32G is NOT supported by Xavier AGX. please refer to this sentence:

A combo UFS and Micro SD Card Socket (J4) is implemented. The SD card interface supports up to SDR104 mode (UHS-1). The UFS interface supports up to HS-GEAR 3.
in [ Jetson AGX Xavier Developer Kit Carrier Board Specification.

  1. Tried already. You are correct. The 32G SD card is just a little smaller than the built-in eMMC in Jetson. By using a 64G SD card via a SD card reader, which is mounted as /dev/sda, I can now successfully dd everything from eMMC to SD.

It is actually supported, but higher speeds of some newer devices will revert back to UHS-I speeds. Many “faster” devices with more recent modes will revert to older modes if the faster mode is not supported.

Btw, the boot requirements for eMMC versus SD card differ. I doubt you would succeed with just cloning partitions as a means to migrate from eMMC to SD card. There might be cases where editing “extlinux.conf” (or other boot environment) will allow part of the boot content to live on eMMC, but use the rootfs from SD. So far as migrating everything to SD, it won’t work.

1 Like

@linuxdev

Really? SDXC and SDUC are supported? But why in my case: None of my TF cards larger than 32G (I tried 64G and 128G) is able to be detected as mmcblk1 after being inserted into Xavier AGX ?

So, do you have any recommended brands ? Can you please help to share the product (64G or 128G) link?

Cheers
Pei

@linuxdev @snarky

Hey, I posted another issue the other day: AGX Xavier won't detect TF card? - #3 by jiapei1

And, please take a look at my dmesg here AGX-Xavier-SDCard-dmesg - Pastebin.com .

Anyway, if SDXC is working with Xavier AGX, there must be some issue with some particular brands/series.
Can you please help to let me know: which brands/series have been demonstrated working with Xavier AGX?

I have several SD cards larger than 32GB. I find ADATA less reliable, but it sometimes works. The one I’m most pleased with at the moment (this is 64GB):
SanDisk Ultra microSDXC UHS-1 Card

I also have had good luck with Samsung.

1 Like

Kingston 128GB works perfect for me. Thank you very much @linuxdev and @snarky.