slitaz-arm view tools/mksd.sh @ rev 153
Tiny edits
author | Paul Issott <paul@slitaz.org> |
---|---|
date | Wed Apr 30 18:36:04 2014 +0100 (2014-04-30) |
parents | 85becc4b89a7 |
children |
line source
1 #!/bin/sh
2 #
3 # Sleep to avoid: "kernel still uses old table: Device or resource busy"
4 #
5 # TODO: handle part number: --part=3 since Raspberry Pi needs 3 parts with
6 # a first FAT32 and Cubie Board only 2 (with / swap) or 1 single part.
7 #
8 . /lib/libtaz.sh
9 check_root
11 dev="$1"
12 [ ! "$dev" ] && echo "Missing device name: $0 dev" && exit 1
13 if ! fdisk -l | grep -q "/dev/${dev}"; then
14 echo "Unable to find: /dev/${dev}"; exit 1
15 fi
17 # Boot: min 33Mb for FAT32
18 echo -n "Creating partition: /dev/${dev}1 /boot"
19 fdisk /dev/${dev} >/dev/null << EOF
20 o
21 n
22 p
23 1
24 1
25 +40M
26 w
27 EOF
28 status
30 # Swap
31 echo -n "Creating partition: /dev/${dev}2 swap"
32 sleep 2
33 fdisk /dev/${dev} 2>&1 >/dev/null << EOF
34 n
35 p
36 2
38 +420M
39 w
40 EOF
41 status
43 # Root
44 echo -n "Creating partition: /dev/${dev}3 / (root)"
45 sleep 2
46 fdisk /dev/${dev} 2>&1 >/dev/null << EOF
47 n
48 p
49 3
52 w
53 EOF
54 status
56 # Boot flag
57 echo -n "Setting boot flag on: /dev/${dev}1"
58 sleep 2
59 fdisk /dev/${dev} 2>&1 >/dev/null << EOF
60 a
61 1
62 w
63 EOF
64 status
66 # Mkfs: Buggy fat32
67 if [ "$mkfs" ]; then
68 if fdisk -l /dev/${dev} | grep -q "^/dev/${dev}1"; then
69 echo -n "Creating: /boot FAT32 filesystem"
70 mkfs.fat -v -F32 -I -n " " /dev/${dev}1 \
71 >>/tmp/mksd.log 2>&1; status
72 fi
73 if fdisk -l /dev/${dev} | grep -q "^/dev/${dev}2"; then
74 echo -n "Creating: swap memory filesystem"
75 mkswap /dev/${dev}2 >>/tmp/mksd.log; status
76 fi
77 if fdisk -l /dev/${dev} | grep -q "^/dev/${dev}3"; then
78 fs="ext4"
79 [ "$btrfs" ] && fs="btrfs -f"
80 echo -n "Creating: root $fs filesystem"
81 mkfs.${fs} -L "SliTazSD" /dev/${dev}3 >>/tmp/mksd.log 2>&1
82 status
83 fi
84 fi
86 exit 0