-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtinycore-install
177 lines (137 loc) · 3.91 KB
/
tinycore-install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
###############################################################################
#
# This script installs the tinycore linux from a the Core Bootable ISO. It is
# a very tipical installation, using the whole disk as ext4 primary partition.
#
# 1) Download the Core ISO from http://tinycorelinux.net/downloads.html (11 MB)
#
# 2) Create a virtual machine and boot the ISO. (press [Return] when asked)
#
# 3) Download and run this script:
#
# tce-load -w -i openssl.tcz <- enable ssl (for https)
# wget git.io/tinycore-install <- download script
# sh tinycore-install <- run
#
# 3) What tinycore-install does:
# - Create and format a single partition using whole disk space
# - Install Kernel
# - Install GRUB
# - Setup GRUB to boot from disk
#
# Credits:
# By paulo.amaral(a)gmail(dot)com - https://github.com/paulera
# Based on @smileymattj tutorial: http://www.youtube.com/watch?v=0QMY3V5XLj8
#
###############################################################################
#!/bin/sh
step() {
echo -e "\e[1;36m+++ $1\e[0m";
}
ok() {
echo -e "\e[32m[success] \e[0m\n";
}
err() {
{ set +x; } 2>/dev/null
echo -e "\n\e[1;31mERROR! Check last command output for details.\e[0m";
echo -e "\nInstallation aborted.\n";
exit 1
}
pause() {
echo -e "\e[1;30mPress [return] for next step...\e[0m"
read
}
echo
echo "This will setup your partitions, install kernel and grub, and any"
echo "existing data will be lost. Just make sure you run this in a clean"
echo "environment, from the bootable ISO, and you should be fine."
echo
read -p "Continue (y/n)? " -n 1 -r
echo
echo
if [[ "$REPLY" = "Y" ]] || [[ "$REPLY" = "y" ]]; then
TOTAL=9
# ------------------------------------
step "1 of $TOTAL. Create partition\n"
set -x
sudo sh -c 'echo -e "n\np\n1\n\n\n\n\na\n1\nw" | fdisk /dev/sda' || err
{ set +x; } 2>/dev/null
ok
pause
# ------------------------------------
step "2 of $TOTAL. Format partition\n"
set -x
sudo mkfs.ext4 /dev/sda1 || err
{ set +x; } 2>/dev/null
ok
set -x
sudo rebuildfstab || err
{ set +x; } 2>/dev/null
ok
pause
# ------------------------------------
step "3 of $TOTAL. Mount Disk and CD\n"
set -x
sudo mount /mnt/sda1 || err
{ set +x; } 2>/dev/null
ok
set -x
sudo mount /mnt/sr0 || err
{ set +x; } 2>/dev/null
ok
pause
# ------------------------------------
step "4 of $TOTAL. Create directories\n"
set -x
sudo mkdir -p /mnt/sda1/boot/grub || err
{ set +x; } 2>/dev/null
ok
set -x
sudo mkdir -p /mnt/sda1/tce/optional || err
{ set +x; } 2>/dev/null
ok
pause
# ------------------------------------
step "5 of $TOTAL. Copy kernel\n"
set -x
sudo cp -p /mnt/sr0/boot/core.gz /mnt/sda1/boot/ || err
{ set +x; } 2>/dev/null
ok
set -x
sudo cp -p /mnt/sr0/boot/vmlinuz /mnt/sda1/boot/ || err
{ set +x; } 2>/dev/null
ok
pause
# ------------------------------------
step "7 of $TOTAL. Install grub\n"
set -x
tce-load -w -i grub-0.97-splash.tcz || err
{ set +x; } 2>/dev/null
ok
set -x
sudo cp -p /usr/lib/grub/i386-pc/* /mnt/sda1/boot/grub/ || err
{ set +x; } 2>/dev/null
ok
pause
# ------------------------------------
step "8 of $TOTAL. Create menu for GRUB\n"
echo "This makes /home and /opt persistent in /sda1 . If you don't want this, edit"
echo " /mnt/sda1/boot/grub/menu.lst"
echo "and REMOVE"
echo " opt=sda1 home=sda1"
set -x
sudo sh -c 'echo -e "default 0\ntimeout 0\ntitle MicroCore\nkernel /boot/vmlinuz quiet opt=sda1 home=sda1\ninitrd /boot/core.gz" > /mnt/sda1/boot/grub/menu.lst' || err
{ set +x; } 2>/dev/null
ok
pause
# ------------------------------------
step "9 of $TOTAL. Create master boot record\n"
set -x
sudo sh -c 'echo -e "root (hd0,0)\nsetup (hd0)\nquit" | grub --batch' || err
{ set +x; } 2>/dev/null
ok
pause
# ------------------------------------
step "Done!\n"
echo -e "Script finished. Remove ISO from drive and reboot.\n"
fi