TS-7553-V2 MicroSD Backup: Difference between revisions

From embeddedTS Manuals
(Initial creation)
 
m (Links auto-updated for 2022 re-branding ( https://files.embeddedarm.com/ts-arm-sbc/ts-7553-V2-linux/distributions/ts7553-V2-latest.tar.bz2 →‎ https://files.embeddedTS.com/ts-arm-sbc/ts-7553-V2-linux/distributions/ts7553-V2-latest.tar.bz2))
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{|  
{|  
| [[File:MicroSD.png|70px|link=ftp://ftp.embeddedarm.com/ts-arm-sbc/ts-7553-V2-linux/binaries/ts-images/ts553-V2-latest.dd.bz2]]
| [[File:MicroSD8GB.png|70px|link=https://files.embeddedTS.com/ts-arm-sbc/ts-7553-V2-linux/distributions/ts7553-V2-latest.tar.bz2]]
| [ftp://ftp.embeddedarm.com/ts-arm-sbc/ts-7553-V2-linux/binaries/ts-images/ts7553-V2-latest.dd.bz2 Click to download the latest 4GB SD card image.]
| [https://files.embeddedTS.com/ts-arm-sbc/ts-7553-V2-linux/distributions/ts7553-V2-latest.tar.bz2 Click to download the latest tarball.]
|}
|}


''' Using another Linux workstation '''
Most SD cards ship with a single partition, which is ideal. However the instructions below will destroy the partition table and use 'parted' to recreate it and make a single partition. Note that any other preferred tool can be used instead, however the partition table must be "MBR" format for U-Boot to properly parse it.


If you do not have an SD card that can boot to the initramfs, you can download the [ftp://ftp.embeddedarm.com/ts-arm-sbc/ts-7553-V2-linux/binaries/ts-images/ts7553-V2-latest.dd.bz2 latest SD card image] and rewrite this from a Linux workstation.  A USB MicroSD adapter can be used to access the card.  First, you must find out which /dev/ device corresponds with your USB reader/writer. 
{{:Host_ID_SD_Card_Generic_4GB}}


Step 1 Option 1 (lsblk)
----


Newer distributions include a utility called "lsblk" which allows simple identification of the intended card:
The instructions below use the [[#Stock_Images|latest stock image]], but it is also possible to use this process to update the TS-7553-V2 to the [[#Linux_4.9.y_Images|Linux 4.9 kernel with Debian Stretch]] image.
<source lang=bash>
lsblk
</source>
  NAME  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
  sdY      8:0    0  400G  0 disk
  ├─sdY1  8:1    0  398G  0 part /
  ├─sdY2  8:2    0    1K  0 part
  └─sdY5  8:5    0    2G  0 part [SWAP]
  sr0    11:0    1  1024M  0 rom 
  sdX      8:32  1  3.9G  0 disk
  ├─sdX1  8:33  1  7.9M  0 part
  ├─sdX2  8:34  1    2M  0 part
  ├─sdX3  8:35  1    2M  0 part
  └─sdX4  8:36  1  3.8G  0 part 


In this case the SD card is 4GB, so sdX is the target device. Note that on your system, sdX will not be a real device, it could be sda, sdb, mmcblk0, etc.  Technologic Systems is not responsible for any damages cause by using the improper device node for imaging an SD card.
The following commands will reformat the first partition of the SD card, and unpack the latest filesystem on there. Replace the "/dev/sdX" on the first line with the correct whole disk device node!


Step 1 Option 2 (dmesg)
<source lang=bash>
----
# Update this variable to match the specific device node as it appears on your PC!
export SD_DEV="/dev/sdX"


After plugging in the device, you can use dmesg to list
# Verify nothing else has this mounted
sudo umount "${SD_DEV}"1


  scsi 54:0:0:0: Direct-Access    Generic  Storage Device  0.00 PQ: 0 ANSI: 2
# Remove, and re-set the partition table, ensuring there is a single partition. Additional partitions can be added, however U-Boot expects the 1st partition to have the root filesystem tarball.
  sd 54:0:0:0: Attached scsi generic sg2 type 0
sudo dd if=/dev/zero bs=512 count=1 of="${SD_DEV}"
  sd 54:0:0:0: [sdX] 3862528 512-byte logical blocks: (3.97 GB/3.84 GiB)
sudo parted -s -a optimal "${SD_DEV}" mklabel msdos
sudo parted -s -a optimal "${SD_DEV}" mkpart primary ext3 0% 100%
sudo mkfs.ext3 -F "${SD_DEV}"1


In this case, sdXc is shown as a 3.97GB card. Note that on your system, sdX will not be a real device, it could be sda, sdb, mmcblk0, etc. Technologic Systems is not responsible for any damages cause by using the improper device node for imaging an SD card.
# Mount, unpack filesystem tarball, and flush all cached data
 
sudo mkfs.ext3 "${SD_DEV}"1
Step 2
sudo mkdir /mnt/sd
----
sudo mount "${SD_DEV}"1 /mnt/sd/
wget https://files.embeddedTS.com/ts-arm-sbc/ts-7553-V2-linux/distributions/ts7553-V2-latest.tar.bz2
sudo tar -xf ts7553-V2-latest.tar.bz2 -C /mnt/sd
sudo umount /mnt/sd
sync
</source>
{{:U-Boot ext4 warning}}


Once you have the target /dev/ device you can use "dd" to backup/restore the cardTo restore the board to stock, or rewrite to the latest SD image:
Once written, the files on disk can be verified to ensure they are the same as the source files in the archiveReinsert the disk to flush the block cache completely, then run the following commands (Note that this expects to have the bash variable still set up from above):
<source lang=bash>
<source lang=bash>
wget ftp://ftp.embeddedarm.com/ts-arm-sbc/ts-7553-V2-linux/binaries/ts-images/ts7553-V2-latest.dd.bz2
sudo mount "${SD_DEV}"1 /mnt/sd
 
cd /mnt/sd/
# Specify your block device instead of /dev/sdX
sudo md5sum --quiet -c md5sums.txt
# Note that this is a whole disk image, so use /dev/sdX instead of
cd -
# using /dev/sdX1
sudo umount /mnt/sd
bzcat ts7553-V2-latest.dd.bz2 | dd conv=fsync bs=4M of=/dev/sdX
sync
</source>
</source>


To take a backup of your entire SD card, you can switch the input file and the output file:
The md5sum command will report what differences there are, if any, and return if it passed or failed.
<source lang=bash>
# Specify your block device instead of /dev/sdX
dd if=/dev/sdX conv=fsync bs=4M | bzip2 > backup.dd.bz2
</source>

Latest revision as of 17:15, 17 January 2022

MicroSD8GB.png Click to download the latest tarball.

Most SD cards ship with a single partition, which is ideal. However the instructions below will destroy the partition table and use 'parted' to recreate it and make a single partition. Note that any other preferred tool can be used instead, however the partition table must be "MBR" format for U-Boot to properly parse it.

Using other OSs

At this time, we're unable to provide assistance with writing SD cards for our products from non-Linux based operating systems. We acknowledge however, that there are methods to write images and files from a variety of difference operating systems. If a native installation of Linux is unavailable, we recommend using a Virtual Machine. See the Getting Started section for links to common virtualization software and Linux installation.

Using a Linux workstation

An SD card can be written to allow it to be bootable. Download the above file and write this from a Linux workstation using the information below. A USB SD adapter can be used to access the card; or if the workstation supports direct connection of SD cards, that can be used instead. Once inserted in to the workstation, it is necessary to discover which /dev/ device corresponds with the inserted SD card before the image can be written.

Option 1: using 'lsblk'


Newer distributions include a utility called 'lsblk' which allows simple identification of the intended card.

Note: This command may need to be run as the root user:
$ lsblk

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sdY      8:0    0   400G  0 disk 
├─sdY1   8:1    0   398G  0 part /
├─sdY2   8:2    0     1K  0 part 
└─sdY5   8:5    0     2G  0 part [SWAP]
sr0     11:0    1  1024M  0 rom  
sdX      8:32   1   3.9G  0 disk 
├─sdX1   8:33   1   7.9M  0 part 
├─sdX2   8:34   1     2M  0 part 
├─sdX3   8:35   1     2M  0 part 
└─sdX4   8:36   1   3.8G  0 part

In this case the, SD card is 4GB, so sdX is the target device and already contains 4 partitions. Note that sdX is not a real device, it could be sda, sdb, mmcblk0, etc. Technologic Systems is not responsible for any damages cause by using the improper device node for imaging an SD card. The instructions below to write to the device will destroy the partition table and any existing data!

Option 2: Using 'dmesg'


After plugging in the device, the 'dmesg' command can be used to list recent kernel events. When inserting a USB adapter, the last few lines of 'dmesg' output will be similar to the following (note that this command may need to be run as the root user):

$ dmesg
...
scsi 54:0:0:0: Direct-Access     Generic  Storage Device   0.00 PQ: 0 ANSI: 2
sd 54:0:0:0: Attached scsi generic sg2 type 0
sd 54:0:0:0: [sdX] 3862528 512-byte logical blocks: (3.97 GB/3.84 GiB)
...

In this case, sdX is shown as a 3.97GB card with a single partition. Note that sdX is not a real device, it could be sda, sdb, mmcblk0, etc. Technologic Systems is not responsible for any damages cause by using the improper device node for imaging an SD card. The instructions below to write to the device will destroy the partition table and any existing data!


The instructions below use the latest stock image, but it is also possible to use this process to update the TS-7553-V2 to the Linux 4.9 kernel with Debian Stretch image.

The following commands will reformat the first partition of the SD card, and unpack the latest filesystem on there. Replace the "/dev/sdX" on the first line with the correct whole disk device node!

# Update this variable to match the specific device node as it appears on your PC!
export SD_DEV="/dev/sdX"

# Verify nothing else has this mounted
sudo umount "${SD_DEV}"1

# Remove, and re-set the partition table, ensuring there is a single partition. Additional partitions can be added, however U-Boot expects the 1st partition to have the root filesystem tarball.
sudo dd if=/dev/zero bs=512 count=1 of="${SD_DEV}"
sudo parted -s -a optimal "${SD_DEV}" mklabel msdos
sudo parted -s -a optimal "${SD_DEV}" mkpart primary ext3 0% 100%
sudo mkfs.ext3 -F "${SD_DEV}"1

# Mount, unpack filesystem tarball, and flush all cached data
sudo mkfs.ext3 "${SD_DEV}"1
sudo mkdir /mnt/sd
sudo mount "${SD_DEV}"1 /mnt/sd/
wget https://files.embeddedTS.com/ts-arm-sbc/ts-7553-V2-linux/distributions/ts7553-V2-latest.tar.bz2
sudo tar -xf ts7553-V2-latest.tar.bz2 -C /mnt/sd
sudo umount /mnt/sd
sync
Note: The ext4 filesystem can be used instead of ext3, but it may require additional options. U-Boot does not support the 64bit addressing added as the default behavior in recent revisions of mkfs.ext4. If using e2fsprogs 1.43 or newer, the options "-O ^64bit,^metadata_csum" must be used with ext4 for proper compatibility. Older versions of e2fsprogs do not need these options passed nor are they needed for ext3.

Once written, the files on disk can be verified to ensure they are the same as the source files in the archive. Reinsert the disk to flush the block cache completely, then run the following commands (Note that this expects to have the bash variable still set up from above):

sudo mount "${SD_DEV}"1 /mnt/sd
cd /mnt/sd/
sudo md5sum --quiet -c md5sums.txt
cd -
sudo umount /mnt/sd
sync

The md5sum command will report what differences there are, if any, and return if it passed or failed.