wiki:HackInstall

HackInstall

HackInstall is a bash script, created to automagicise the uSD installation process. It's still considered very beta, hence may eat your data and kill your dog, so beware! You were warned!

Nevertheless, the script has been tested against installing h1-rev2 and h1-rev3+fix on a uSD card on Kubuntu. There are some pitfalls, though, see Known Issues below.

Dependancies

The script does not check for needed binaries. Not yet. To run it, you need these in your $PATH:

  • bash (obviously)
  • egrep
  • expect (installable on Debian and derivatives by simple apt-get install expect, probably similarly on other distros)
  • fdisk
  • head
  • mkfs.vfat
  • mkfs.ext2
  • mount
  • tail
  • umount

Usage

Just download the attached script, save it somewhere handy and run it, with the uSD device, fat tar archive and ext2 tar archive (and, optionally, ext2-fix tar archive) as arguments.

You have to run it as root or through sudo!

Example:

chmod a+x hackinstall.sh
./hackinstall.sh /dev/mmcblk0 h1-fat_partition.tgz h1-ext2_partition-rev2.tar.gz

...or, for rev3+fix:

chmod a+x hackinstall.sh
./hackinstall.sh /dev/mmcblk0 h1-fat_partition-rev3.tgz h1-ext2_partition-rev3.tar.gz h1-ext2_partition-rev3-fix1.tar.gz

The above is just an example, please use device and file names appropriate on your system!

The output should look along the lines of:

# ./hackinstall.sh /dev/mmcblk0 h1-fat_partition.tgz h1-ext2_partition-rev2.tar.gz

Hackable1 uSD Automated Installer
(c) 2009 Michał 'rysiek' Woźniak
    licensed under GPL ver.3 or any later

If you choose to proceed, ALL AND ANY data on the /dev/mmcblk0 device
WILL BE IRREVERSIBLY DELETED! Choose wisely!

proceed? (y/N): y
proceeding...

+- re-partitioning /dev/mmcblk0:
   - clearing the partition table... done
   - creating the fat partition... done
   - creating the ext partition... done
   - writing changes to disk... done.
+- discovering partition devices:
   - fat partition device: /dev/mmcblk0p1
   - ext partition device: /dev/mmcblk0p2
+- formatting:
   - /dev/mmcblk0p1 as vfat... done.
   - /dev/mmcblk0p2 as ext2... done.
+- creating mount points:
   - /tmp/fat.1238629212.883747396... done.
   - /tmp/ext.1238629212.883747396... done.
+- mounting:
   - /dev/mmcblk0p1 to /tmp/fat.1238629212.883747396... done.
   - /dev/mmcblk0p2 to /tmp/ext.1238629212.883747396... done.
+- untaring:
   - h1-fat_partition.tgz to /tmp/fat.1238629212.883747396... done.
   - h1-ext2_partition-rev2.tar.gz to /tmp/ext.1238629212.883747396... done.
+- unmounting:
   - /dev/mmcblk0p1... done.
   - /dev/mmcblk0p2... done.
+- removing mountpoints:
   - /tmp/fat.1238629212.883747396... done.
   - /tmp/ext.1238629212.883747396... done.
all done.

Known Issues

After encountering an error on any stage of the installation process, the script exits with error message displayed on standard output. It does NOT perform cleanup in such a case. You will have to manually unmount disks and delete temporary mountpoints (in /tmp). Yes, this is on the ToDo list.

Attachments