Last active
December 16, 2015 09:48
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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