From 69c72f4579645599f1cff47b0b50dd3b5154f5e7 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sun, 07 Dec 2014 23:42:54 -0500 Subject: Make partitions and file systems --- diff --git a/debeagle.sh b/debeagle.sh index ecb7588..1a35986 100644 --- a/debeagle.sh +++ b/debeagle.sh @@ -52,17 +52,7 @@ main() ;; esac - if [ "x${target}" = 'x' ]; then - target="/dev/$(prompt_block_dev)" - elif [ -e "/sys/block/${target#/dev/}" ]; then - printf 'Installing to %s\n' \ - "$(get_block_dev_name "${target#/dev/}")" - else - error 1 'Device %s not found\n' "${target}" - fi - if grep "^${target}" /proc/mounts; then - error 1 'Device %s mounted\n' "${target}" - fi + make_parts_and_fs "${target}" } print_usage() @@ -201,4 +191,34 @@ prompt_block_dev() EOF } +make_parts_and_fs() +{ + local target="${1}" + local part_prefix='' + + if [ "x${target}" = 'x' ]; then + target="/dev/$(prompt_block_dev)" + elif [ -e "/sys/block/${target#/dev/}" ]; then + printf 'Installing to %s\n' \ + "$(get_block_dev_name "${target#/dev/}")" + else + error 1 'Device %s not found\n' "${target}" + fi + if grep "^${target}" /proc/mounts; then + error 1 'Device %s mounted\n' "${target}" + fi + + dd if=/dev/zero of="${target}" bs=512 count=1 + sfdisk "${target}" <<-EOF + ,102400,0x0E,* + ,,0x83,- + EOF + + case "${target}" in + /dev/mmcblk*) part_prefix='p';; + esac + mkdosfs -F 16 "${target}${part_prefix}1" + mke2fs -t ext2 "${target}${part_prefix}2" +} + main "${@}" -- cgit v0.9.1