##// END OF EJS Templates
Added to README: Understanding the script
drtyhlpr -
r64:80185bd93dd9
parent child
Show More
@@ -1,176 +1,206
1 1 # rpi2-gen-image
2 2 ## Introduction
3 3 `rpi2-gen-image.sh` is an advanced Debian Linux bootstrapping shell script for generating Debian OS images for the Raspberry 2 (RPi2) computer. The script at this time only supports the bootstrapping of the current stable Debian 8 "jessie" release.
4 4
5 5 ## Build dependencies
6 6 The following list of Debian packages must be installed on the build system because they are essentially required for the bootstrapping process. The script will check if all required packages are installed and missing packages will be installed automatically if confirmed by the user.
7 7
8 8 ```debootstrap debian-archive-keyring qemu-user-static dosfstools rsync bmap-tools whois git-core```
9 9
10 10 ## Command-line parameters
11 11 The script accepts certain command-line parameters to enable or disable specific OS features, services and configuration settings. These parameters are passed to the `rpi2-gen-image.sh` script via (simple) shell-variables. Unlike environment shell-variables (simple) shell-variables are defined at the beginning of the command-line call of the `rpi2-gen-image.sh` script.
12 12
13 13 #####Command-line examples:
14 14 ```shell
15 15 ENABLE_UBOOT=true ./rpi2-gen-image.sh
16 16 ENABLE_CONSOLE=false ENABLE_IPV6=false ./rpi2-gen-image.sh
17 17 ENABLE_WM=xfce4 ENABLE_FBTURBO=true ENABLE_MINBASE=true ./rpi2-gen-image.sh
18 18 ENABLE_HARDNET=true ENABLE_IPTABLES=true /rpi2-gen-image.sh
19 19 APT_SERVER=ftp.de.debian.org APT_PROXY="http://127.0.0.1:3142/" ./rpi2-gen-image.sh
20 20 ENABLE_MINBASE=true ./rpi2-gen-image.sh
21 21 ```
22 22
23 23 #### APT settings:
24 24 ##### `APT_SERVER`="ftp.debian.org"
25 25 Set Debian packages server address. Choose a server from the list of Debian worldwide [mirror sites](https://www.debian.org/mirror/list). Using a nearby server will probably speed-up all required downloads within the bootstrapping process.
26 26
27 27 ##### `APT_PROXY`=""
28 28 Set Proxy server address. Using a local Proxy-Cache like `apt-cacher-ng` will speed-up the bootstrapping process because all required Debian packages will only be downloaded from the Debian mirror site once.
29 29
30 30 ##### `APT_INCLUDES`=""
31 31 A comma seperated list of additional packages to be installed during bootstrapping.
32 32
33 33 #### General system settings:
34 34 ##### `HOSTNAME`="rpi2-jessie"
35 35 Set system host name. It's recommended that the host name is unique in the corresponding subnet.
36 36
37 37 ##### `PASSWORD`="raspberry"
38 38 Set system `root` password. The same password is used for the created user `pi`. It's **STRONGLY** recommended that you choose a custom password.
39 39
40 40 ##### `DEFLOCAL`="en_US.UTF-8"
41 41 Set default system locale. This setting can also be changed inside the running OS using the `dpkg-reconfigure locales` command. The script variant `minbase` (ENABLE_MINBASE=true) doesn't install `locales`.
42 42
43 43 ##### `TIMEZONE`="Europe/Berlin"
44 44 Set default system timezone. All available timezones can be found in the `/usr/share/zoneinfo/` directory. This setting can also be changed inside the running OS using the `dpkg-reconfigure tzdata` command.
45 45
46 46 ##### `EXPANDROOT`=true
47 47 Expand the root partition and filesystem automatically on first boot.
48 48
49 49 #### Keyboard settings:
50 50 These options are used to configure keyboard layout in `/etc/default/keyboard` for console and Xorg. These settings can also be changed inside the running OS using the `dpkg-reconfigure keyboard-configuration` command.
51 51
52 52 ##### `XKBMODEL`=""
53 53 Set the name of the model of your keyboard type.
54 54
55 55 ##### `XKBLAYOUT`=""
56 56 Set the supported keyboard layout(s).
57 57
58 58 ##### `XKBVARIANT`=""
59 59 Set the supported variant(s) of the keyboard layout(s).
60 60
61 61 ##### `XKBOPTIONS`=""
62 62 Set extra xkb configuration options.
63 63
64 64 #### Networking settings (DHCP)
65 65 This setting is used to set up networking auto configuration in `/etc/systemd/network/eth.network`.
66 66
67 67 #####`ENABLE_DHCP`=true
68 68 Set the system to use DHCP. This requires an DHCP server.
69 69
70 70 #### Networking settings (static)
71 71 These settings are used to set up a static networking configuration in /etc/systemd/network/eth.network. The following static networking settings are only supported if `ENABLE_DHCP` was set to `false`.
72 72
73 73 #####`NET_ADDRESS`=""
74 74 Set a static IPv4 or IPv6 address and its prefix, separated by "/", eg. "192.169.0.3/24".
75 75
76 76 #####`NET_GATEWAY`=""
77 77 Set the IP address for the default gateway.
78 78
79 79 #####`NET_DNS_1`=""
80 80 Set the IP address for the first DNS server.
81 81
82 82 #####`NET_DNS_2`=""
83 83 Set the IP address for the second DNS server.
84 84
85 85 #####`NET_DNS_DOMAINS`=""
86 86 Set the default DNS search domains to use for non fully qualified host names.
87 87
88 88 #####`NET_NTP_1`=""
89 89 Set the IP address for the first NTP server.
90 90
91 91 #####`NET_NTP_2`=""
92 92 Set the IP address for the second NTP server.
93 93
94 94 #### Basic system features:
95 95 ##### `ENABLE_CONSOLE`=true
96 96 Enable serial console interface. Recommended if no monitor or keyboard is connected to the RPi2. In case of problems fe. if the network (auto) configuration failed - the serial console can be used to access the system.
97 97
98 98 ##### `ENABLE_IPV6`=true
99 99 Enable IPv6 support. The network interface configuration is managed via systemd-networkd.
100 100
101 101 ##### `ENABLE_SSHD`=true
102 102 Install and enable OpenSSH service. The default configuration of the service doesn't allow `root` to login. Please use the user `pi` instead and `su -` or `sudo` to execute commands as root.
103 103
104 104 ##### `ENABLE_RSYSLOG`=true
105 105 If set to false, disable and uninstall rsyslog (so logs will be available only
106 106 in journal files)
107 107
108 108 ##### `ENABLE_SOUND`=true
109 109 Enable sound hardware and install Advanced Linux Sound Architecture.
110 110
111 111 ##### `ENABLE_HWRANDOM`=true
112 112 Enable Hardware Random Number Generator. Strong random numbers are important for most network based communications that use encryption. It's recommended to be enabled.
113 113
114 114 ##### `ENABLE_MINGPU`=false
115 115 Minimize the amount of shared memory reserved for the GPU. It doesn't seem to be possible to fully disable the GPU.
116 116
117 117 ##### `ENABLE_DBUS`=true
118 118 Install and enable D-Bus message bus. Please note that systemd should work without D-bus but it's recommended to be enabled.
119 119
120 120 ##### `ENABLE_XORG`=false
121 121 Install Xorg open-source X Window System.
122 122
123 123 ##### `ENABLE_WM`=""
124 124 Install a user defined window manager for the X Window System. To make sure all X related package dependencies are getting installed `ENABLE_XORG` will automatically get enabled if `ENABLE_WM` is used. The `rpi2-gen-image.sh` script has been tested with the following list of window managers: `blackbox`, `openbox`, `fluxbox`, `jwm`, `dwm`, `xfce4`, `awesome`.
125 125
126 #### Advanced sytem features:
126 #### Advanced system features:
127 127 ##### `ENABLE_MINBASE`=false
128 128 Use debootstrap script variant `minbase` which only includes essential packages and apt. This will reduce the disk usage by about 65 MB.
129 129
130 130 ##### `ENABLE_UBOOT`=false
131 131 Replace default RPi2 second stage bootloader (bootcode.bin) with U-Boot bootloader. U-Boot can boot images via the network using the BOOTP/TFTP protocol.
132 132
133 133 ##### `ENABLE_FBTURBO`=false
134 134 Install and enable the hardware accelerated Xorg video driver `fbturbo`. Please note that this driver is currently limited to hardware accelerated window moving and scrolling.
135 135
136 136 ##### `ENABLE_IPTABLES`=false
137 137 Enable iptables IPv4/IPv6 firewall. Simplified ruleset: Allow all outgoing connections. Block all incoming connections except to OpenSSH service.
138 138
139 139 ##### `ENABLE_USER`=true
140 140 Create pi user with password raspberry
141 141
142 142 ##### `ENABLE_ROOT`=true
143 143 Set root user password so root login will be enabled
144 144
145 145 ##### `ENABLE_ROOT_SSH`=true
146 146 Enable password root login via SSH. May be a security risk with default
147 147 password, use only in trusted environments.
148 148
149 149 ##### `ENABLE_HARDNET`=false
150 150 Enable IPv4/IPv6 network stack hardening settings.
151 151
152 152 ##### `CHROOT_SCRIPTS`=""
153 153 Path to a directory with scripts that should be run in the chroot before the image is finally built. Every executable file in this direcory is run in lexicographical order.
154 154
155 155 #### Kernel compilation:
156 156 ##### `BUILD_KERNEL`=false
157 157 Build and install the latest RPi2 linux kernel. Currently only the default RPi2 kernel configuration is used. Detailed configuration parameters for customizing the kernel and minor bug fixes still need to get implemented. feel free to help.
158 158
159 159 ##### `KERNEL_HEADERS`=true
160 160 If true, also install kernel headers with built kernel.
161 161
162 ## Understanding the script
163 The functions of this script that are required for the different stages of the bootstrapping are split up into single files located inside the `bootstrap.d` directory. During the bootstrapping every script in this directory gets executed in lexicographical order:
164
165 | Script | Description |
166 | --- | --- |
167 | `10-bootstrap.sh` | Debootstrap basic system |
168 | `11-apt.sh` | Setup APT repositories |
169 | `12-locale.sh` | Setup Locales and keyboard settings |
170 | `13-kernel.sh` | Build and install RPi2 Kernel |
171 | `20-networking.sh` | Setup Networking |
172 | `21-firewall.sh` | Setup iptables Firewall |
173 | `30-security.sh` | Setup users and security settings |
174 | `31-logging.sh` | Setup logging |
175 | `41-uboot.sh` | Build and Setup Uboot |
176 | `42-fbturbo.sh` | Buld and Setup fbturbo Xorg driver |
177 | `50-firstboot.sh` | First boot actions |
178
179 All the required configuration files that will be copied to the generated OS image are located inside the `files` directory. It is not recommended to modify these configuration files manually.
180
181 | Directory | Description |
182 | --- | --- |
183 | `boot` | Boot and RPi2 configuration files |
184 | `firstboot` | Scripts that get executed on first boot |
185 | `iptables` | Firewall configuration files |
186 | `modprobe.d` | Kernel Module Blacklist configuration |
187 | `mount` | Fstab configuration |
188 | `network` | Networking configuration files |
189 | `sysctl.d` | Swapping and Network Hardening configuration |
190 | `xorg` | fbturbo Xorg driver configuration |
191
162 192 ## Logging of the bootstrapping process
163 193 All information related to the bootstrapping process and the commands executed by the `rpi2-gen-image.sh` script can easily be saved into a logfile. The common shell command `script` can be used for this purpose:
164 194
165 195 ```shell
166 196 script -c 'APT_SERVER=ftp.de.debian.org ./rpi2-gen-image.sh' ./build.log
167 197 ```
168 198
169 199 ## Flashing the image file
170 200 After the image file was successfully created by the `rpi2-gen-image.sh` script it can be copied to the microSD card that will be used by the RPi2 computer. This can be performed by using the tools `bmaptool` or `dd`. Using `bmaptool` will probably speed-up the copy process because `bmaptool` copies more wisely than `dd`.
171 201
172 202 #####Flashing examples:
173 203 ```shell
174 204 bmaptool copy ./images/jessie/2015-12-13-debian-jessie.img /dev/mmcblk0
175 205 dd bs=4M if=./images/jessie/2015-12-13-debian-jessie.img of=/dev/mmcblk0
176 206 ```
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant