diff options
author | VG <vg@devys.org> | 2016-11-06 20:04:54 +0100 |
---|---|---|
committer | VG <vg@devys.org> | 2016-11-06 20:04:54 +0100 |
commit | cf0edd94c05a9fc0c609758016a697c24dd913a0 (patch) | |
tree | 568d7345b0d6e438769c4f2ef1b7ecdb66576259 /rpi2-debian-stdkernel/format-sdcard.py | |
parent | fb6fa99c0da96a45d458b2ffa0b9b2fe8890ac36 (diff) | |
download | debootstrap-scripts-cf0edd94c05a9fc0c609758016a697c24dd913a0.tar.gz debootstrap-scripts-cf0edd94c05a9fc0c609758016a697c24dd913a0.tar.bz2 debootstrap-scripts-cf0edd94c05a9fc0c609758016a697c24dd913a0.zip |
add other debootstrap scripts and older instructions
Diffstat (limited to 'rpi2-debian-stdkernel/format-sdcard.py')
-rwxr-xr-x | rpi2-debian-stdkernel/format-sdcard.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/rpi2-debian-stdkernel/format-sdcard.py b/rpi2-debian-stdkernel/format-sdcard.py new file mode 100755 index 0000000..ea08728 --- /dev/null +++ b/rpi2-debian-stdkernel/format-sdcard.py @@ -0,0 +1,33 @@ +#!/usr/bin/python3 + +import json +import subprocess +import sys + +def run(*l, **d): + print('run:', *l, d) + return subprocess.run(*l, **d) + +def main(): + if len(sys.argv) < 2: + print('Usage: {} <device>'.format(sys.argv[0]), file=sys.stderr) + raise SystemExit(1) + device = sys.argv[1] + # first, clean possible gpt tables + run(['sudo', 'sgdisk', '--zap-all', device]) + part_commands = ''' + mklabel msdos + mkpart primary fat32 1M 99M + mkpart primary ext4 100M -1M + set 1 boot on + print + ''' + run(['sudo', 'parted', device], + check=True, input=part_commands.encode('utf8')) + run(['sudo', 'mkfs.vfat', '-n', 'boot', device + '1', ], check=True) + run(['sudo', 'mkfs.ext4', '-q', '-F', '-L', 'root', device + '2'], + check=True) + + +if __name__ == '__main__': + main() |