2021年5月28日 星期五

Jetson nano clone SD card (For Jetpack 4.5.1)

 The actual size of SD card is different from each other. It will be problem when SD card image file size is large than target SD card.

sudo gunzip -c ~/dragon-eye.img.gz | sudo dd of=/dev/mmcblk0 bs=64k status=progress
62261100544 bytes (62 GB, 58 GiB) copied, 3227 s, 19.3 MB/s
dd: error writing '/dev/mmcblk0': No space left on device
146314+1607917 records in
146314+1607916 records out
62277025792 bytes (62 GB, 58 GiB) copied, 3266.33 s, 19.1 MB/s

Jetson nano will refuse to boot with this SD card. 
I found a procedure to fix the probelm

1.Shrink APP partition (ext4) before clone SD card to image file. Reserve 512MB space on tail.









2.Clone SD card to image file

sudo dd if=/dev/mmcblk0 conv=sync,noerror bs=64K status=progress | gzip -c > ~/dragon-eye.img.gz
[sudo] password for gigijoe: 
62306058240 bytes (62 GB, 58 GiB) copied, 1309 s, 47.6 MB/s
951808+0 records in
951808+0 records out
62377689088 bytes (62 GB, 58 GiB) copied, 1310.95 s, 47.6 MB/s

3.Copy image file to target SD card

sudo gunzip -c ~/dragon-eye.img.gz | sudo dd of=/dev/mmcblk0 bs=64k status=progress
[sudo] password for gigijoe: 
62261100544 bytes (62 GB, 58 GiB) copied, 3227 s, 19.3 MB/s
dd: error writing '/dev/mmcblk0': No space left on device
146314+1607917 records in
146314+1607916 records out
62277025792 bytes (62 GB, 58 GiB) copied, 3266.33 s, 19.1 MB/s

There's error of no space. It's ok, just ignore it.

4.Fix partition

This SD card is NOT ready to boot because the partition table is corrupt. Run gdisk and write back partition table to fix.

sudo gdisk /dev/mmcblk0 

GPT fdisk (gdisk) version 1.0.5

Warning! Disk size is smaller than the main header indicates! Loading
secondary header from the last sector of the disk! You should use 'v' to
verify disk integrity, and perhaps options on the experts' menu to repair
the disk.
Caution: invalid backup GPT header, but valid main header; regenerating
backup header from main header.

Warning! One or more CRCs don't match. You should repair the disk!
Main header: OK
Backup header: ERROR
Main partition table: OK
Backup partition table: ERROR

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: damaged

****************************************************************************
Caution: Found protective or hybrid MBR and corrupt GPT. Using GPT, but disk
verification and recovery are STRONGLY recommended.
****************************************************************************

Command (? for help): p
Disk /dev/mmcblk0: 121634816 sectors, 58.0 GiB
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): CEF61F19-EF34-40C6-B658-4039F0AB5630
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 121634782
Partitions will be aligned on 2048-sector boundaries
Total free space is 1079229 sectors (527.0 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1           28672       120584191   57.5 GiB    8300  APP

Recovery/transformation command (? for help): w
Caution! Secondary header was placed beyond the disk's limits! Moving the
header, but other problems may occur!

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/mmcblk0.
The operation has completed successfully.

Now the SD card works ...




沒有留言:

張貼留言