SMR Flash Disk Cloning

From Rsewiki
Jump to: navigation, search

Some of the SMR's now have solid-state flash memory disks, instead of the laptop, 2.5" disks used on older models.

This wiki page contains some notes describing how to write a bootable flash disk image (Slackware Linux) to a memory card. It assumes a Linux PC with USB flash card reader/writer, available as /dev/sda.

The commands below is implemented in this script [Clone script]. Usage:

clone <from_file.tar.gz> <to device>

<to device> can be both the USB bus (/dev/sdx) or a IDE device (/dev/hdx)

The script will place a file .cloned-at on the Flash Disk with time information for the cloning.

If you put the Flash Disk on the IDE bus and the computer will not boot (LILO - Timestamp mismatch) then the MBR on the Flash Disk must be erased as follows:

dd if=/dev/zero of=/dev/hdx bs=1 count=512


Writing an image

Format the disk, with one large Linux partition:

sfdisk -L /dev/sda <<EOF
,,L,*
EOF

Create a filesystem:

mke2fs /dev/sda1 -L /

Mount the new, empty partition:

mkdir -p /tmp/u
mount /dev/sda1 /tmp/u

Write a previously created image from flash.tar.gz

zcat flash.tar.gz |
tar --extract --file - --directory /tmp/u --preserve-permissions

Create a patched lilo.conf, so that we can run LILO with the flash card mounted via USB. (This won't be necessary if the image written above already contains such a file.)

patch -o /tmp/u/etc/lilo_usb.conf /tmp/u/etc/lilo.conf <<EOF
*** /tmp/u/etc/lilo.conf        Tue Nov  4 21:34:44 2003
--- lilo_usb.conf       Thu Dec 11 11:50:55 2003
***************
*** 4,6 ****
  # Start LILO global section
! boot = /dev/hda
  message = /boot/boot_message.txt
--- 4,7 ----
  # Start LILO global section
! boot = /dev/sda
! disk = /dev/sda bios=0x80
  message = /boot/boot_message.txt
EOF

Run LILO:

chroot /tmp/u lilo -v -C /etc/lilo_usb.conf

All done:

umount /dev/sda1
eject /dev/sda

Reading an image

Mount as above:

mkdir -p /tmp/u
mount /dev/sda1 /tmp/u

Read the partition:

tar --create --file - --directory /tmp/u --one-file-system --exclude lost+found . |
gzip > flash.tar.gz

or

tar -zcf - -C /tmp/u --one-file-system --exclude lost+found . > flash.tar.gz

All done:

umount /dev/sda1
eject /dev/sda
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox