1

Background Info

I have an embedded system running Ubuntu 12.04 which I need to upgrade to patch some security vulnerabilities. The changes will include upgrading to ubuntu 14.04, changing a few config files located in /etc, /var, /media and also updating our application software. There are 1500 or so of these devices that the upgrades will need to be pushed out to so I am leaning towards a solution that does not require physical access to the device.

Disk Info:

root@HBOX-01003d:/dev# sudo fdisk -l

Disk /dev/mmcblk2: 7851 MB, 7851737088 bytes 4 heads, 16 sectors/track, 239616 cylinders, total 15335424 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000

Device Boot      Start         End      Blocks   Id  System /dev/mmcblk2p1   *        2048      100351       49152    c  W95 FAT32 (LBA) /dev/mmcblk2p2          100352     1329151      614400   83  Linux /dev/mmcblk2p3         1329152    15335423     7003136   83  Linux

Disk /dev/mmcblk2rpmb: 0 MB, 131072 bytes 4 heads, 16 sectors/track, 4 cylinders, total 256 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000

Disk /dev/mmcblk2rpmb doesn't contain a valid partition table

Disk /dev/mmcblk2boot1: 2 MB, 2097152 bytes 4 heads, 16 sectors/track, 64 cylinders, total 4096 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000

Disk /dev/mmcblk2boot1 doesn't contain a valid partition table

Disk /dev/mmcblk2boot0: 2 MB, 2097152 bytes 4 heads, 16 sectors/track, 64 cylinders, total 4096 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000

Disk /dev/mmcblk2boot0 doesn't contain a valid partition table root@HBOX-01003d:/dev# sudo parted -l Error: /dev/mmcblk2rpmb: unrecognised disk label

Error: /dev/mmcblk2boot0: unrecognised disk label

Error: /dev/mmcblk2boot1: unrecognised disk label

Model: MMC MMC08G (sd/mmc) Disk /dev/mmcblk2: 7852MB Sector size (logical/physical): 512B/512B Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags  1      1049kB  51.4MB  50.3MB  primary  fat32        boot, lba  2      51.4MB 681MB   629MB   primary  ext3  3      681MB   7852MB  7171MB  primary  ext3

First Imaging Attempt

From this information, I gathered that the mmcblk2 drive was the primary drive used on this system and decided to image this drive. I used dd https://help.ubuntu.com/community/DriveImaging to create the image and the second answer on this post to help write the correct commands: https://unix.stackexchange.com/questions/132797/how-to-dd-a-remote-disk-using-ssh-on-local-machine-and-save-to-a-local-disk

I used the following command to copy, compress, and send the image to a remote server.

dd if=/dev/mmcblk2 | gzip -c --fast | ssh administrator@10.3.5.99 'dd of=/home/administrator/clone/ubuntu14.gz'

This was the output:

15335424+0 records in
15335424+0 records out
7851737088 bytes (7.9 GB) copied, 2038.58 s, 3.9 MB/s
6247083+1 records in
6247083+1 records out
3198506839 bytes (3.2 GB) copied, 2023.36 s, 1.6 MB/s

The first time around, I ran this command to log into the remote system, pull the image, and copy it to the box

ssh administrator@10.3.5.99 'dd if=/home/administrator/clone/hboxClone2.gz' | gunzip -1 - | dd of=/dev/mmcblk2

This obviously did not work as I was booted from the drive I was trying to write to and it bricked the device. Thus, I flashed the device using our existing process (requires a peedi box, serial connection, and a Firmware server) and started over.

Questions

So I have a couple low-level questions that I feel must be answered before I can even proceed with developing a solution.

1) Will imaging the mmcblk2 drive be sufficient for creating a replica of the system? It's hard to tell from the fdisk output whether or not everything is stored solely on the mmcblk2 disk.

2) Can partition 1 or 2 be utilized for the imaging? I am thinking I may be able to image just the first partition, write to one of the other two partitions, and swap which I boot from? I read somewhere online about swapping drives and I'm wondering if this same concept can be applied to the partitions. The other thing I'm concerned with is that there may be something written to those partitions (this is the reason I originally tried imaging the entire drive).

How to fix the UUID in Grub after restore from another machine?

Here is what I have in the fstab file:

# UNCONFIGURED FSTAB FOR BASE SYSTEM
#/dev/mmcblk0p2   /           auto   errors=remount-ro   0   1
#/dev/mmcblk0p1   /boot/uboot auto   defaults            0   2
rootfs               /                    auto       defaults              1  1
proc                 /proc                proc       defaults              0  0
devpts               /dev/pts             devpts     mode=0620,gid=5       0  0
usbdevfs             /proc/bus/usb        usbdevfs   noauto                0  0
tmpfs                /var/volatile        tmpfs      defaults              0  0
tmpfs                /media/ram           tmpfs      defaults              0  0
/hibernateswap           none                             swap           sw
                           0  0
# uncomment this if your device has a SD/MMC/Transflash slot
#/dev/mmcblk0p1       /media/card          auto       defaults,sync,noauto  0  0 

0 Answers0