Skip to content

Instantly share code, notes, and snippets.

@risaacson
Last active December 16, 2015 09:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save risaacson/5415051 to your computer and use it in GitHub Desktop.
Save risaacson/5415051 to your computer and use it in GitHub Desktop.
Expanding on Gist:5414535 this is a simple script to pull the kernels and ramdisks from a raw image with expected partitions.
#!/usr/bin/env bash
# set -x
# DEBUG='echo'
device=$1
[ ! -f "${device}" ] && exit 1
output_dir=$( echo "${device}" | sed 's/.img//g' )
[ -d "${output_dir}" ] && exit 1
mkdir -p "${output_dir}"
start_block=$( parted ${device} unit b print | grep ' 1 ' | awk '{print $2}' | sed 's/B//g' )
${DEBUG} losetup /dev/loop0 "${device}" -o "${start_block}"
${DEBUG} mount /dev/loop0 /mnt
# ${DEBUG} file -s /dev/loop0
# ls /mnt
${DEBUG} cp /mnt/initr* /mnt/vmlinuz* "${output_dir}"/
${DEBUG} umount /mnt
${DEBUG} losetup -d /dev/loop0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment