diff options
author | P. J. McDermott <pj@pehjota.net> | 2014-12-07 23:42:54 (EST) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2014-12-07 23:42:54 (EST) |
commit | 69c72f4579645599f1cff47b0b50dd3b5154f5e7 (patch) | |
tree | f1a1456e479f3a55605bcd7e5fd7a7ca24426616 | |
parent | d67f89a24d6de539ec904380eec91197d15a692a (diff) |
Make partitions and file systems
-rw-r--r-- | debeagle.sh | 42 |
1 files changed, 31 insertions, 11 deletions
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 "${@}" |