##// END OF EJS Templates
Updated: Moved fstab stuff to new file 14-fstab.sh
drtyhlpr -
r141:c9fa0b77637b
parent child
Show More
@@ -0,0 +1,56
1 #
2 # Setup fstab and initramfs
3 #
4
5 # Load utility functions
6 . ./functions.sh
7
8 # Install and setup fstab
9 install_readonly files/mount/fstab "${ETC_DIR}/fstab"
10
11 # Add usb/sda disk root partition to fstab
12 if [ "$ENABLE_SPLITFS" = true ] && [ "$ENABLE_CRYPTFS" = false ] ; then
13 sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/fstab"
14 fi
15
16 # Add encrypted root partition to fstab and crypttab
17 if [ "$ENABLE_CRYPTFS" = true ] ; then
18 # Replace fstab root partition with encrypted partition mapping
19 sed -i "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING}/" "${ETC_DIR}/fstab"
20
21 # Add encrypted partition to crypttab and fstab
22 install_readonly files/mount/crypttab "${ETC_DIR}/crypttab"
23 echo "${CRYPTFS_MAPPING} /dev/mmcblk0p2 none luks" >> "${ETC_DIR}/crypttab"
24
25 if [ "$ENABLE_SPLITFS" = true ] ; then
26 # Add usb/sda disk to crypttab
27 sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/crypttab"
28 fi
29 fi
30
31 # Generate initramfs file
32 if [ "$BUILD_KERNEL" = true ] && [ "$ENABLE_INITRAMFS" = true ] ; then
33 if [ "$ENABLE_CRYPTFS" = true ] ; then
34 # Include initramfs scripts to auto expand encrypted root partition
35 if [ "$EXPANDROOT" = true ] ; then
36 install_exec files/initramfs/expand_encrypted_rootfs "${ETC_DIR}/initramfs-tools/scripts/init-premount/expand_encrypted_rootfs"
37 install_exec files/initramfs/expand-premount "${ETC_DIR}/initramfs-tools/scripts/local-premount/expand-premount"
38 install_exec files/initramfs/expand-tools "${ETC_DIR}/initramfs-tools/hooks/expand-tools"
39 fi
40
41 # Disable SSHD inside initramfs
42 printf "#\n# DROPBEAR: [ y | n ]\n#\n\nDROPBEAR=n\n" >> "${ETC_DIR}/initramfs-tools/initramfs.conf"
43
44 # Dummy mapping required by mkinitramfs
45 echo "0 1 crypt $(echo ${CRYPTFS_CIPHER} | cut -d ':' -f 1) ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 7:0 4096" | chroot_exec dmsetup create "${CRYPTFS_MAPPING}"
46
47 # Generate initramfs with encrypted root partition support
48 chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}"
49
50 # Remove dummy mapping
51 chroot_exec cryptsetup close "${CRYPTFS_MAPPING}"
52 else
53 # Generate initramfs without encrypted root partition support
54 chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}"
55 fi
56 fi
@@ -1,421 +1,422
1 # rpi23-gen-image
1 # rpi23-gen-image
2 ## Introduction
2 ## Introduction
3 `rpi23-gen-image.sh` is an advanced Debian Linux bootstrapping shell script for generating Debian OS images for Raspberry Pi 2 (RPi2) and Raspberry Pi 3 (RPi3) computers. The script at this time supports the bootstrapping of the Debian (armhf) releases `jessie` and `stretch`. Raspberry Pi 3 images are currently generated for 32-bit mode only.
3 `rpi23-gen-image.sh` is an advanced Debian Linux bootstrapping shell script for generating Debian OS images for Raspberry Pi 2 (RPi2) and Raspberry Pi 3 (RPi3) computers. The script at this time supports the bootstrapping of the Debian (armhf) releases `jessie` and `stretch`. Raspberry Pi 3 images are currently generated for 32-bit mode only.
4
4
5 ## Build dependencies
5 ## Build dependencies
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.
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 ```debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus```
8 ```debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus```
9
9
10 It is recommended to configure the `rpi23-gen-image.sh` script to build and install the latest Raspberry Pi Linux kernel. For the RPi3 this is mandetory. Kernel compilation and linking will be performed on the build system using an ARM (armhf) cross-compiler toolchain.
10 It is recommended to configure the `rpi23-gen-image.sh` script to build and install the latest Raspberry Pi Linux kernel. For the RPi3 this is mandetory. Kernel compilation and linking will be performed on the build system using an ARM (armhf) cross-compiler toolchain.
11
11
12 The script has been tested using the default `crossbuild-essential-armhf` toolchain meta package on Debian Linux `jessie` and `stretch` build systems. Please check the [Debian CrossToolchains Wiki](https://wiki.debian.org/CrossToolchains) for further information.
12 The script has been tested using the default `crossbuild-essential-armhf` toolchain meta package on Debian Linux `jessie` and `stretch` build systems. Please check the [Debian CrossToolchains Wiki](https://wiki.debian.org/CrossToolchains) for further information.
13
13
14 If a Debian Linux `jessie` build system is used it will be required to add the [Debian Cross-toolchains repository](http://emdebian.org/tools/debian/) first:
14 If a Debian Linux `jessie` build system is used it will be required to add the [Debian Cross-toolchains repository](http://emdebian.org/tools/debian/) first:
15
15
16 ```
16 ```
17 echo "deb http://emdebian.org/tools/debian/ jessie main" > /etc/apt/sources.list.d/crosstools.list
17 echo "deb http://emdebian.org/tools/debian/ jessie main" > /etc/apt/sources.list.d/crosstools.list
18 sudo -u nobody wget -O - http://emdebian.org/tools/debian/emdebian-toolchain-archive.key | apt-key add -
18 sudo -u nobody wget -O - http://emdebian.org/tools/debian/emdebian-toolchain-archive.key | apt-key add -
19 dpkg --add-architecture armhf
19 dpkg --add-architecture armhf
20 apt-get update
20 apt-get update
21 ```
21 ```
22
22
23 ## Command-line parameters
23 ## Command-line parameters
24 The script accepts certain command-line parameters to enable or disable specific OS features, services and configuration settings. These parameters are passed to the `rpi23-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 `rpi23-gen-image.sh` script.
24 The script accepts certain command-line parameters to enable or disable specific OS features, services and configuration settings. These parameters are passed to the `rpi23-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 `rpi23-gen-image.sh` script.
25
25
26 #####Command-line examples:
26 #####Command-line examples:
27 ```shell
27 ```shell
28 ENABLE_UBOOT=true ./rpi23-gen-image.sh
28 ENABLE_UBOOT=true ./rpi23-gen-image.sh
29 ENABLE_CONSOLE=false ENABLE_IPV6=false ./rpi23-gen-image.sh
29 ENABLE_CONSOLE=false ENABLE_IPV6=false ./rpi23-gen-image.sh
30 ENABLE_WM=xfce4 ENABLE_FBTURBO=true ENABLE_MINBASE=true ./rpi23-gen-image.sh
30 ENABLE_WM=xfce4 ENABLE_FBTURBO=true ENABLE_MINBASE=true ./rpi23-gen-image.sh
31 ENABLE_HARDNET=true ENABLE_IPTABLES=true /rpi23-gen-image.sh
31 ENABLE_HARDNET=true ENABLE_IPTABLES=true /rpi23-gen-image.sh
32 APT_SERVER=ftp.de.debian.org APT_PROXY="http://127.0.0.1:3142/" ./rpi23-gen-image.sh
32 APT_SERVER=ftp.de.debian.org APT_PROXY="http://127.0.0.1:3142/" ./rpi23-gen-image.sh
33 ENABLE_MINBASE=true ./rpi23-gen-image.sh
33 ENABLE_MINBASE=true ./rpi23-gen-image.sh
34 BUILD_KERNEL=true ENABLE_MINBASE=true ENABLE_IPV6=false ./rpi23-gen-image.sh
34 BUILD_KERNEL=true ENABLE_MINBASE=true ENABLE_IPV6=false ./rpi23-gen-image.sh
35 BUILD_KERNEL=true KERNELSRC_DIR=/tmp/linux ./rpi23-gen-image.sh
35 BUILD_KERNEL=true KERNELSRC_DIR=/tmp/linux ./rpi23-gen-image.sh
36 ENABLE_MINBASE=true ENABLE_REDUCE=true ENABLE_MINGPU=true BUILD_KERNEL=true ./rpi23-gen-image.sh
36 ENABLE_MINBASE=true ENABLE_REDUCE=true ENABLE_MINGPU=true BUILD_KERNEL=true ./rpi23-gen-image.sh
37 ENABLE_CRYPTFS=true CRYPTFS_PASSWORD=changeme EXPANDROOT=false ENABLE_MINBASE=true ENABLE_REDUCE=true ENABLE_MINGPU=true BUILD_KERNEL=true ./rpi23-gen-image.sh
37 ENABLE_CRYPTFS=true CRYPTFS_PASSWORD=changeme EXPANDROOT=false ENABLE_MINBASE=true ENABLE_REDUCE=true ENABLE_MINGPU=true BUILD_KERNEL=true ./rpi23-gen-image.sh
38 RELEASE=stretch BUILD_KERNEL=true ./rpi23-gen-image.sh
38 RELEASE=stretch BUILD_KERNEL=true ./rpi23-gen-image.sh
39 RPI_MODEL=3 ENABLE_WIRELESS=true ENABLE_MINBASE=true BUILD_KERNEL=true ./rpi23-gen-image.sh
39 RPI_MODEL=3 ENABLE_WIRELESS=true ENABLE_MINBASE=true BUILD_KERNEL=true ./rpi23-gen-image.sh
40 RELEASE=stretch RPI_MODEL=3 ENABLE_WIRELESS=true ENABLE_MINBASE=true BUILD_KERNEL=true ./rpi23-gen-image.sh
40 RELEASE=stretch RPI_MODEL=3 ENABLE_WIRELESS=true ENABLE_MINBASE=true BUILD_KERNEL=true ./rpi23-gen-image.sh
41 ```
41 ```
42
42
43 ## Configuration template files
43 ## Configuration template files
44 To avoid long lists of command-line parameters and to help to store the favourite parameter configurations the `rpi23-gen-image.sh` script supports so called configuration template files (`CONFIG_TEMPLATE`=template). These are simple text files located in the `./templates` directory that contain the list of configuration parameters that will be used. New configuration template files can be added to the `./templates` directory.
44 To avoid long lists of command-line parameters and to help to store the favourite parameter configurations the `rpi23-gen-image.sh` script supports so called configuration template files (`CONFIG_TEMPLATE`=template). These are simple text files located in the `./templates` directory that contain the list of configuration parameters that will be used. New configuration template files can be added to the `./templates` directory.
45
45
46 #####Command-line examples:
46 #####Command-line examples:
47 ```shell
47 ```shell
48 CONFIG_TEMPLATE=rpi3stretch ./rpi23-gen-image.sh
48 CONFIG_TEMPLATE=rpi3stretch ./rpi23-gen-image.sh
49 CONFIG_TEMPLATE=rpi2stretch ./rpi23-gen-image.sh
49 CONFIG_TEMPLATE=rpi2stretch ./rpi23-gen-image.sh
50 ```
50 ```
51
51
52 ## Supported parameters and settings
52 ## Supported parameters and settings
53 #### APT settings:
53 #### APT settings:
54 ##### `APT_SERVER`="ftp.debian.org"
54 ##### `APT_SERVER`="ftp.debian.org"
55 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.
55 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.
56
56
57 ##### `APT_PROXY`=""
57 ##### `APT_PROXY`=""
58 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.
58 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.
59
59
60 ##### `APT_INCLUDES`=""
60 ##### `APT_INCLUDES`=""
61 A comma separated list of additional packages to be installed during bootstrapping.
61 A comma separated list of additional packages to be installed during bootstrapping.
62
62
63 ---
63 ---
64
64
65 #### General system settings:
65 #### General system settings:
66 ##### `RPI_MODEL`=2
66 ##### `RPI_MODEL`=2
67 Specifiy the target Raspberry Pi hardware model. The script at this time supports the Raspberry Pi models `2` and `3`. `BUILD_KERNEL`=true will automatically be set if the Raspberry Pi model `3` is used.
67 Specifiy the target Raspberry Pi hardware model. The script at this time supports the Raspberry Pi models `2` and `3`. `BUILD_KERNEL`=true will automatically be set if the Raspberry Pi model `3` is used.
68
68
69 ##### `RELEASE`="jessie"
69 ##### `RELEASE`="jessie"
70 Set the desired Debian release name. The script at this time supports the bootstrapping of the Debian releases "jessie" and "stretch". `BUILD_KERNEL`=true will automatically be set if the Debian release `stretch` is used.
70 Set the desired Debian release name. The script at this time supports the bootstrapping of the Debian releases "jessie" and "stretch". `BUILD_KERNEL`=true will automatically be set if the Debian release `stretch` is used.
71
71
72 ##### `HOSTNAME`="rpi$RPI_MODEL-$RELEASE"
72 ##### `HOSTNAME`="rpi$RPI_MODEL-$RELEASE"
73 Set system host name. It's recommended that the host name is unique in the corresponding subnet.
73 Set system host name. It's recommended that the host name is unique in the corresponding subnet.
74
74
75 ##### `PASSWORD`="raspberry"
75 ##### `PASSWORD`="raspberry"
76 Set system `root` password. It's **STRONGLY** recommended that you choose a custom password.
76 Set system `root` password. It's **STRONGLY** recommended that you choose a custom password.
77
77
78 ##### `USER_PASSWORD`="raspberry"
78 ##### `USER_PASSWORD`="raspberry"
79 Set password for the created non-root user `USER_NAME`=pi. Ignored if `ENABLE_USER`=false. It's **STRONGLY** recommended that you choose a custom password.
79 Set password for the created non-root user `USER_NAME`=pi. Ignored if `ENABLE_USER`=false. It's **STRONGLY** recommended that you choose a custom password.
80
80
81 ##### `DEFLOCAL`="en_US.UTF-8"
81 ##### `DEFLOCAL`="en_US.UTF-8"
82 Set default system locale. This setting can also be changed inside the running OS using the `dpkg-reconfigure locales` command. Please note that on using this parameter the script will automatically install the required packages `locales`, `keyboard-configuration` and `console-setup`.
82 Set default system locale. This setting can also be changed inside the running OS using the `dpkg-reconfigure locales` command. Please note that on using this parameter the script will automatically install the required packages `locales`, `keyboard-configuration` and `console-setup`.
83
83
84 ##### `TIMEZONE`="Europe/Berlin"
84 ##### `TIMEZONE`="Europe/Berlin"
85 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.
85 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.
86
86
87 ##### `EXPANDROOT`=true
87 ##### `EXPANDROOT`=true
88 Expand the root partition and filesystem automatically on first boot.
88 Expand the root partition and filesystem automatically on first boot.
89
89
90 ---
90 ---
91
91
92 #### Keyboard settings:
92 #### Keyboard settings:
93 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.
93 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.
94
94
95 ##### `XKB_MODEL`=""
95 ##### `XKB_MODEL`=""
96 Set the name of the model of your keyboard type.
96 Set the name of the model of your keyboard type.
97
97
98 ##### `XKB_LAYOUT`=""
98 ##### `XKB_LAYOUT`=""
99 Set the supported keyboard layout(s).
99 Set the supported keyboard layout(s).
100
100
101 ##### `XKB_VARIANT`=""
101 ##### `XKB_VARIANT`=""
102 Set the supported variant(s) of the keyboard layout(s).
102 Set the supported variant(s) of the keyboard layout(s).
103
103
104 ##### `XKB_OPTIONS`=""
104 ##### `XKB_OPTIONS`=""
105 Set extra xkb configuration options.
105 Set extra xkb configuration options.
106
106
107 ---
107 ---
108
108
109 #### Networking settings (DHCP):
109 #### Networking settings (DHCP):
110 This parameter is used to set up networking auto configuration in `/etc/systemd/network/eth.network`. The default location of network configuration files in the Debian `stretch` release was changed to `/lib/systemd/network`.`
110 This parameter is used to set up networking auto configuration in `/etc/systemd/network/eth.network`. The default location of network configuration files in the Debian `stretch` release was changed to `/lib/systemd/network`.`
111
111
112 #####`ENABLE_DHCP`=true
112 #####`ENABLE_DHCP`=true
113 Set the system to use DHCP. This requires an DHCP server.
113 Set the system to use DHCP. This requires an DHCP server.
114
114
115 ---
115 ---
116
116
117 #### Networking settings (static):
117 #### Networking settings (static):
118 These parameters are used to set up a static networking configuration in `/etc/systemd/network/eth.network`. The following static networking parameters are only supported if `ENABLE_DHCP` was set to `false`. The default location of network configuration files in the Debian `stretch` release was changed to `/lib/systemd/network`.
118 These parameters are used to set up a static networking configuration in `/etc/systemd/network/eth.network`. The following static networking parameters are only supported if `ENABLE_DHCP` was set to `false`. The default location of network configuration files in the Debian `stretch` release was changed to `/lib/systemd/network`.
119
119
120 #####`NET_ADDRESS`=""
120 #####`NET_ADDRESS`=""
121 Set a static IPv4 or IPv6 address and its prefix, separated by "/", eg. "192.169.0.3/24".
121 Set a static IPv4 or IPv6 address and its prefix, separated by "/", eg. "192.169.0.3/24".
122
122
123 #####`NET_GATEWAY`=""
123 #####`NET_GATEWAY`=""
124 Set the IP address for the default gateway.
124 Set the IP address for the default gateway.
125
125
126 #####`NET_DNS_1`=""
126 #####`NET_DNS_1`=""
127 Set the IP address for the first DNS server.
127 Set the IP address for the first DNS server.
128
128
129 #####`NET_DNS_2`=""
129 #####`NET_DNS_2`=""
130 Set the IP address for the second DNS server.
130 Set the IP address for the second DNS server.
131
131
132 #####`NET_DNS_DOMAINS`=""
132 #####`NET_DNS_DOMAINS`=""
133 Set the default DNS search domains to use for non fully qualified host names.
133 Set the default DNS search domains to use for non fully qualified host names.
134
134
135 #####`NET_NTP_1`=""
135 #####`NET_NTP_1`=""
136 Set the IP address for the first NTP server.
136 Set the IP address for the first NTP server.
137
137
138 #####`NET_NTP_2`=""
138 #####`NET_NTP_2`=""
139 Set the IP address for the second NTP server.
139 Set the IP address for the second NTP server.
140
140
141 ---
141 ---
142
142
143 #### Basic system features:
143 #### Basic system features:
144 ##### `ENABLE_CONSOLE`=true
144 ##### `ENABLE_CONSOLE`=true
145 Enable serial console interface. Recommended if no monitor or keyboard is connected to the RPi2/3. In case of problems fe. if the network (auto) configuration failed - the serial console can be used to access the system.
145 Enable serial console interface. Recommended if no monitor or keyboard is connected to the RPi2/3. In case of problems fe. if the network (auto) configuration failed - the serial console can be used to access the system.
146
146
147 ##### `ENABLE_I2C`=false
147 ##### `ENABLE_I2C`=false
148 Enable I2C interface on the RPi2/3. Please check the [RPi2/3 pinout diagrams](http://elinux.org/RPi_Low-level_peripherals) to connect the right GPIO pins.
148 Enable I2C interface on the RPi2/3. Please check the [RPi2/3 pinout diagrams](http://elinux.org/RPi_Low-level_peripherals) to connect the right GPIO pins.
149
149
150 ##### `ENABLE_SPI`=false
150 ##### `ENABLE_SPI`=false
151 Enable SPI interface on the RPi2/3. Please check the [RPi2/3 pinout diagrams](http://elinux.org/RPi_Low-level_peripherals) to connect the right GPIO pins.
151 Enable SPI interface on the RPi2/3. Please check the [RPi2/3 pinout diagrams](http://elinux.org/RPi_Low-level_peripherals) to connect the right GPIO pins.
152
152
153 ##### `ENABLE_IPV6`=true
153 ##### `ENABLE_IPV6`=true
154 Enable IPv6 support. The network interface configuration is managed via systemd-networkd.
154 Enable IPv6 support. The network interface configuration is managed via systemd-networkd.
155
155
156 ##### `ENABLE_SSHD`=true
156 ##### `ENABLE_SSHD`=true
157 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.
157 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.
158
158
159 ##### `ENABLE_NONFREE`=false
159 ##### `ENABLE_NONFREE`=false
160 Allow the installation of non-free Debian packages that do not comply with the DFSG. This is required to install closed-source firmware binary blobs.
160 Allow the installation of non-free Debian packages that do not comply with the DFSG. This is required to install closed-source firmware binary blobs.
161
161
162 ##### `ENABLE_WIRELESS`=false
162 ##### `ENABLE_WIRELESS`=false
163 Download and install the [closed-source firmware binary blob](https://github.com/RPi-Distro/firmware-nonfree/tree/master/brcm80211/brcm) that is required to run the internal wireless interface of the Raspberry Pi model `3`. This parameter is ignored if the specified `RPI_MODEL` is not `3`.
163 Download and install the [closed-source firmware binary blob](https://github.com/RPi-Distro/firmware-nonfree/tree/master/brcm80211/brcm) that is required to run the internal wireless interface of the Raspberry Pi model `3`. This parameter is ignored if the specified `RPI_MODEL` is not `3`.
164
164
165 ##### `ENABLE_RSYSLOG`=true
165 ##### `ENABLE_RSYSLOG`=true
166 If set to false, disable and uninstall rsyslog (so logs will be available only
166 If set to false, disable and uninstall rsyslog (so logs will be available only
167 in journal files)
167 in journal files)
168
168
169 ##### `ENABLE_SOUND`=true
169 ##### `ENABLE_SOUND`=true
170 Enable sound hardware and install Advanced Linux Sound Architecture.
170 Enable sound hardware and install Advanced Linux Sound Architecture.
171
171
172 ##### `ENABLE_HWRANDOM`=true
172 ##### `ENABLE_HWRANDOM`=true
173 Enable Hardware Random Number Generator. Strong random numbers are important for most network based communications that use encryption. It's recommended to be enabled.
173 Enable Hardware Random Number Generator. Strong random numbers are important for most network based communications that use encryption. It's recommended to be enabled.
174
174
175 ##### `ENABLE_MINGPU`=false
175 ##### `ENABLE_MINGPU`=false
176 Minimize the amount of shared memory reserved for the GPU. It doesn't seem to be possible to fully disable the GPU.
176 Minimize the amount of shared memory reserved for the GPU. It doesn't seem to be possible to fully disable the GPU.
177
177
178 ##### `ENABLE_DBUS`=true
178 ##### `ENABLE_DBUS`=true
179 Install and enable D-Bus message bus. Please note that systemd should work without D-bus but it's recommended to be enabled.
179 Install and enable D-Bus message bus. Please note that systemd should work without D-bus but it's recommended to be enabled.
180
180
181 ##### `ENABLE_XORG`=false
181 ##### `ENABLE_XORG`=false
182 Install Xorg open-source X Window System.
182 Install Xorg open-source X Window System.
183
183
184 ##### `ENABLE_WM`=""
184 ##### `ENABLE_WM`=""
185 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 `rpi23-gen-image.sh` script has been tested with the following list of window managers: `blackbox`, `openbox`, `fluxbox`, `jwm`, `dwm`, `xfce4`, `awesome`.
185 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 `rpi23-gen-image.sh` script has been tested with the following list of window managers: `blackbox`, `openbox`, `fluxbox`, `jwm`, `dwm`, `xfce4`, `awesome`.
186
186
187 ---
187 ---
188
188
189 #### Advanced system features:
189 #### Advanced system features:
190 ##### `ENABLE_MINBASE`=false
190 ##### `ENABLE_MINBASE`=false
191 Use debootstrap script variant `minbase` which only includes essential packages and apt. This will reduce the disk usage by about 65 MB.
191 Use debootstrap script variant `minbase` which only includes essential packages and apt. This will reduce the disk usage by about 65 MB.
192
192
193 ##### `ENABLE_REDUCE`=false
193 ##### `ENABLE_REDUCE`=false
194 Reduce the disk space usage by deleting packages and files. See `REDUCE_*` parameters for detailed information.
194 Reduce the disk space usage by deleting packages and files. See `REDUCE_*` parameters for detailed information.
195
195
196 ##### `ENABLE_UBOOT`=false
196 ##### `ENABLE_UBOOT`=false
197 Replace the default RPi2/3 second stage bootloader (bootcode.bin) with [U-Boot bootloader](http://git.denx.de/?p=u-boot.git;a=summary). U-Boot can boot images via the network using the BOOTP/TFTP protocol.
197 Replace the default RPi2/3 second stage bootloader (bootcode.bin) with [U-Boot bootloader](http://git.denx.de/?p=u-boot.git;a=summary). U-Boot can boot images via the network using the BOOTP/TFTP protocol.
198
198
199 ##### `UBOOTSRC_DIR`=""
199 ##### `UBOOTSRC_DIR`=""
200 Path to a directory of [U-Boot bootloader sources](http://git.denx.de/?p=u-boot.git;a=summary) that will be copied, configured, build and installed inside the chroot.
200 Path to a directory of [U-Boot bootloader sources](http://git.denx.de/?p=u-boot.git;a=summary) that will be copied, configured, build and installed inside the chroot.
201
201
202 ##### `ENABLE_FBTURBO`=false
202 ##### `ENABLE_FBTURBO`=false
203 Install and enable the [hardware accelerated Xorg video driver](https://github.com/ssvb/xf86-video-fbturbo) `fbturbo`. Please note that this driver is currently limited to hardware accelerated window moving and scrolling.
203 Install and enable the [hardware accelerated Xorg video driver](https://github.com/ssvb/xf86-video-fbturbo) `fbturbo`. Please note that this driver is currently limited to hardware accelerated window moving and scrolling.
204
204
205 ##### `ENABLE_IPTABLES`=false
205 ##### `ENABLE_IPTABLES`=false
206 Enable iptables IPv4/IPv6 firewall. Simplified ruleset: Allow all outgoing connections. Block all incoming connections except to OpenSSH service.
206 Enable iptables IPv4/IPv6 firewall. Simplified ruleset: Allow all outgoing connections. Block all incoming connections except to OpenSSH service.
207
207
208 ##### `ENABLE_USER`=true
208 ##### `ENABLE_USER`=true
209 Create non-root user with password `USER_PASSWORD`=raspberry. Unless overridden with `USER_NAME`=user, username will be `pi`.
209 Create non-root user with password `USER_PASSWORD`=raspberry. Unless overridden with `USER_NAME`=user, username will be `pi`.
210
210
211 ##### `USER_NAME`=pi
211 ##### `USER_NAME`=pi
212 Non-root user to create. Ignored if `ENABLE_USER`=false
212 Non-root user to create. Ignored if `ENABLE_USER`=false
213
213
214 ##### `ENABLE_ROOT`=false
214 ##### `ENABLE_ROOT`=false
215 Set root user password so root login will be enabled
215 Set root user password so root login will be enabled
216
216
217 ##### `ENABLE_HARDNET`=false
217 ##### `ENABLE_HARDNET`=false
218 Enable IPv4/IPv6 network stack hardening settings.
218 Enable IPv4/IPv6 network stack hardening settings.
219
219
220 ##### `ENABLE_SPLITFS`=false
220 ##### `ENABLE_SPLITFS`=false
221 Enable having root partition on an USB drive by creating two image files: one for the `/boot/firmware` mount point, and another for `/`.
221 Enable having root partition on an USB drive by creating two image files: one for the `/boot/firmware` mount point, and another for `/`.
222
222
223 ##### `CHROOT_SCRIPTS`=""
223 ##### `CHROOT_SCRIPTS`=""
224 Path to a directory with scripts that should be run in the chroot before the image is finally built. Every executable file in this directory is run in lexicographical order.
224 Path to a directory with scripts that should be run in the chroot before the image is finally built. Every executable file in this directory is run in lexicographical order.
225
225
226 ##### `ENABLE_INITRAMFS`=false
226 ##### `ENABLE_INITRAMFS`=false
227 Create an initramfs that that will be loaded during the Linux startup process. `ENABLE_INITRAMFS` will automatically get enabled if `ENABLE_CRYPTFS`=true. This parameter will be ignored if `BUILD_KERNEL`=false.
227 Create an initramfs that that will be loaded during the Linux startup process. `ENABLE_INITRAMFS` will automatically get enabled if `ENABLE_CRYPTFS`=true. This parameter will be ignored if `BUILD_KERNEL`=false.
228
228
229 ##### `ENABLE_IFNAMES`=true
229 ##### `ENABLE_IFNAMES`=true
230 Enable automatic assignment of predictable, stable network interface names for all local Ethernet, WLAN interfaces. This might create complex and long interface names. This parameter is only supported if the Debian release `stretch` is used.
230 Enable automatic assignment of predictable, stable network interface names for all local Ethernet, WLAN interfaces. This might create complex and long interface names. This parameter is only supported if the Debian release `stretch` is used.
231
231
232 ##### `DISABLE_UNDERVOLT_WARNINGS`=
232 ##### `DISABLE_UNDERVOLT_WARNINGS`=
233 Disable RPi2/3 under-voltage warnings and overlays. Setting the parameter to `1` will disable the warning overlay. Setting it to `2` will additionally allow RPi2/3 turbo mode when low-voltage is present.
233 Disable RPi2/3 under-voltage warnings and overlays. Setting the parameter to `1` will disable the warning overlay. Setting it to `2` will additionally allow RPi2/3 turbo mode when low-voltage is present.
234
234
235 ---
235 ---
236
236
237 #### SSH settings:
237 #### SSH settings:
238 ##### `SSH_ENABLE_ROOT`=false
238 ##### `SSH_ENABLE_ROOT`=false
239 Enable password root login via SSH. This may be a security risk with default password, use only in trusted environments. `ENABLE_ROOT` must be set to `true`.
239 Enable password root login via SSH. This may be a security risk with default password, use only in trusted environments. `ENABLE_ROOT` must be set to `true`.
240
240
241 ##### `SSH_DISABLE_PASSWORD_AUTH`=false
241 ##### `SSH_DISABLE_PASSWORD_AUTH`=false
242 Disable password based SSH authentication. Only public key based SSH (v2) authentication will be supported.
242 Disable password based SSH authentication. Only public key based SSH (v2) authentication will be supported.
243
243
244 ##### `SSH_LIMIT_USERS`=false
244 ##### `SSH_LIMIT_USERS`=false
245 Limit the users that are allowed to login via SSH. Only allow user `USER_NAME`=pi and root if `SSH_ENABLE_ROOT`=true to login.
245 Limit the users that are allowed to login via SSH. Only allow user `USER_NAME`=pi and root if `SSH_ENABLE_ROOT`=true to login.
246
246
247 ##### `SSH_ROOT_PUB_KEY`=""
247 ##### `SSH_ROOT_PUB_KEY`=""
248 Add SSH (v2) public key(s) from specified file to `authorized_keys` file to enable public key based SSH (v2) authentication of user `root`. The specified file can also contain multiple SSH (v2) public keys. SSH protocol version 1 is not supported. `ENABLE_ROOT` **and** `SSH_ENABLE_ROOT` must be set to `true`.
248 Add SSH (v2) public key(s) from specified file to `authorized_keys` file to enable public key based SSH (v2) authentication of user `root`. The specified file can also contain multiple SSH (v2) public keys. SSH protocol version 1 is not supported. `ENABLE_ROOT` **and** `SSH_ENABLE_ROOT` must be set to `true`.
249
249
250 ##### `SSH_USER_PUB_KEY`=""
250 ##### `SSH_USER_PUB_KEY`=""
251 Add SSH (v2) public key(s) from specified file to `authorized_keys` file to enable public key based SSH (v2) authentication of user `USER_NAME`=pi. The specified file can also contain multiple SSH (v2) public keys. SSH protocol version 1 is not supported.
251 Add SSH (v2) public key(s) from specified file to `authorized_keys` file to enable public key based SSH (v2) authentication of user `USER_NAME`=pi. The specified file can also contain multiple SSH (v2) public keys. SSH protocol version 1 is not supported.
252
252
253 ---
253 ---
254
254
255 #### Kernel compilation:
255 #### Kernel compilation:
256 ##### `BUILD_KERNEL`=false
256 ##### `BUILD_KERNEL`=false
257 Build and install the latest RPi2/3 Linux kernel. Currently only the default RPi2/3 kernel configuration is used. `BUILD_KERNEL`=true will automatically be set if the Raspberry Pi model `3` is used.
257 Build and install the latest RPi2/3 Linux kernel. Currently only the default RPi2/3 kernel configuration is used. `BUILD_KERNEL`=true will automatically be set if the Raspberry Pi model `3` is used.
258
258
259 ##### `KERNEL_REDUCE`=false
259 ##### `KERNEL_REDUCE`=false
260 Reduce the size of the generated kernel by removing unwanted device, network and filesystem drivers (experimental).
260 Reduce the size of the generated kernel by removing unwanted device, network and filesystem drivers (experimental).
261
261
262 ##### `KERNEL_THREADS`=1
262 ##### `KERNEL_THREADS`=1
263 Number of parallel kernel building threads. If the parameter is left untouched the script will automatically determine the number of CPU cores to set the number of parallel threads to speed the kernel compilation.
263 Number of parallel kernel building threads. If the parameter is left untouched the script will automatically determine the number of CPU cores to set the number of parallel threads to speed the kernel compilation.
264
264
265 ##### `KERNEL_HEADERS`=true
265 ##### `KERNEL_HEADERS`=true
266 Install kernel headers with built kernel.
266 Install kernel headers with built kernel.
267
267
268 ##### `KERNEL_MENUCONFIG`=false
268 ##### `KERNEL_MENUCONFIG`=false
269 Start `make menuconfig` interactive menu-driven kernel configuration. The script will continue after `make menuconfig` was terminated.
269 Start `make menuconfig` interactive menu-driven kernel configuration. The script will continue after `make menuconfig` was terminated.
270
270
271 ##### `KERNEL_REMOVESRC`=true
271 ##### `KERNEL_REMOVESRC`=true
272 Remove all kernel sources from the generated OS image after it was built and installed.
272 Remove all kernel sources from the generated OS image after it was built and installed.
273
273
274 ##### `KERNELSRC_DIR`=""
274 ##### `KERNELSRC_DIR`=""
275 Path to a directory of [RaspberryPi Linux kernel sources](https://github.com/raspberrypi/linux) that will be copied, configured, build and installed inside the chroot.
275 Path to a directory of [RaspberryPi Linux kernel sources](https://github.com/raspberrypi/linux) that will be copied, configured, build and installed inside the chroot.
276
276
277 ##### `KERNELSRC_CLEAN`=false
277 ##### `KERNELSRC_CLEAN`=false
278 Clean the existing kernel sources directory `KERNELSRC_DIR` (using `make mrproper`) after it was copied to the chroot and before the compilation of the kernel has started. This parameter will be ignored if no `KERNELSRC_DIR` was specified or if `KERNELSRC_PREBUILT`=true.
278 Clean the existing kernel sources directory `KERNELSRC_DIR` (using `make mrproper`) after it was copied to the chroot and before the compilation of the kernel has started. This parameter will be ignored if no `KERNELSRC_DIR` was specified or if `KERNELSRC_PREBUILT`=true.
279
279
280 ##### `KERNELSRC_CONFIG`=true
280 ##### `KERNELSRC_CONFIG`=true
281 Run `make bcm2709_defconfig` (and optional `make menuconfig`) to configure the kernel sources before building. This parameter is automatically set to `true` if no existing kernel sources directory was specified using `KERNELSRC_DIR`. This parameter is ignored if `KERNELSRC_PREBUILT`=true.
281 Run `make bcm2709_defconfig` (and optional `make menuconfig`) to configure the kernel sources before building. This parameter is automatically set to `true` if no existing kernel sources directory was specified using `KERNELSRC_DIR`. This parameter is ignored if `KERNELSRC_PREBUILT`=true.
282
282
283 ##### `KERNELSRC_USRCONFIG`=""
283 ##### `KERNELSRC_USRCONFIG`=""
284 Copy own config file to kernel `.config`. If `KERNEL_MENUCONFIG`=true then running after copy.
284 Copy own config file to kernel `.config`. If `KERNEL_MENUCONFIG`=true then running after copy.
285
285
286 ##### `KERNELSRC_PREBUILT`=false
286 ##### `KERNELSRC_PREBUILT`=false
287 With this parameter set to true the script expects the existing kernel sources directory to be already successfully cross-compiled. The parameters `KERNELSRC_CLEAN`, `KERNELSRC_CONFIG`, `KERNELSRC_USRCONFIG` and `KERNEL_MENUCONFIG` are ignored and no kernel compilation tasks are performed.
287 With this parameter set to true the script expects the existing kernel sources directory to be already successfully cross-compiled. The parameters `KERNELSRC_CLEAN`, `KERNELSRC_CONFIG`, `KERNELSRC_USRCONFIG` and `KERNEL_MENUCONFIG` are ignored and no kernel compilation tasks are performed.
288
288
289 ##### `RPI_FIRMWARE_DIR`=""
289 ##### `RPI_FIRMWARE_DIR`=""
290 The directory containing a local copy of the firmware from the [RaspberryPi firmware project](https://github.com/raspberrypi/firmware). Default is to download the latest firmware directly from the project.
290 The directory containing a local copy of the firmware from the [RaspberryPi firmware project](https://github.com/raspberrypi/firmware). Default is to download the latest firmware directly from the project.
291
291
292 ---
292 ---
293
293
294 #### Reduce disk usage:
294 #### Reduce disk usage:
295 The following list of parameters is ignored if `ENABLE_REDUCE`=false.
295 The following list of parameters is ignored if `ENABLE_REDUCE`=false.
296
296
297 ##### `REDUCE_APT`=true
297 ##### `REDUCE_APT`=true
298 Configure APT to use compressed package repository lists and no package caching files.
298 Configure APT to use compressed package repository lists and no package caching files.
299
299
300 ##### `REDUCE_DOC`=true
300 ##### `REDUCE_DOC`=true
301 Remove all doc files (harsh). Configure APT to not include doc files on future `apt-get` package installations.
301 Remove all doc files (harsh). Configure APT to not include doc files on future `apt-get` package installations.
302
302
303 ##### `REDUCE_MAN`=true
303 ##### `REDUCE_MAN`=true
304 Remove all man pages and info files (harsh). Configure APT to not include man pages on future `apt-get` package installations.
304 Remove all man pages and info files (harsh). Configure APT to not include man pages on future `apt-get` package installations.
305
305
306 ##### `REDUCE_VIM`=false
306 ##### `REDUCE_VIM`=false
307 Replace `vim-tiny` package by `levee` a tiny vim clone.
307 Replace `vim-tiny` package by `levee` a tiny vim clone.
308
308
309 ##### `REDUCE_BASH`=false
309 ##### `REDUCE_BASH`=false
310 Remove `bash` package and switch to `dash` shell (experimental).
310 Remove `bash` package and switch to `dash` shell (experimental).
311
311
312 ##### `REDUCE_HWDB`=true
312 ##### `REDUCE_HWDB`=true
313 Remove PCI related hwdb files (experimental).
313 Remove PCI related hwdb files (experimental).
314
314
315 ##### `REDUCE_SSHD`=true
315 ##### `REDUCE_SSHD`=true
316 Replace `openssh-server` with `dropbear`.
316 Replace `openssh-server` with `dropbear`.
317
317
318 ##### `REDUCE_LOCALE`=true
318 ##### `REDUCE_LOCALE`=true
319 Remove all `locale` translation files.
319 Remove all `locale` translation files.
320
320
321 ---
321 ---
322
322
323 #### Encrypted root partition:
323 #### Encrypted root partition:
324 ##### `ENABLE_CRYPTFS`=false
324 ##### `ENABLE_CRYPTFS`=false
325 Enable full system encryption with dm-crypt. Setup a fully LUKS encrypted root partition (aes-xts-plain64:sha512) and generate required initramfs. The /boot directory will not be encrypted. This parameter will be ignored if `BUILD_KERNEL`=false. `ENABLE_CRYPTFS` is experimental. SSH-to-initramfs is currently not supported but will be soon - feel free to help.
325 Enable full system encryption with dm-crypt. Setup a fully LUKS encrypted root partition (aes-xts-plain64:sha512) and generate required initramfs. The /boot directory will not be encrypted. This parameter will be ignored if `BUILD_KERNEL`=false. `ENABLE_CRYPTFS` is experimental. SSH-to-initramfs is currently not supported but will be soon - feel free to help.
326
326
327 ##### `CRYPTFS_PASSWORD`=""
327 ##### `CRYPTFS_PASSWORD`=""
328 Set password of the encrypted root partition. This parameter is mandatory if `ENABLE_CRYPTFS`=true.
328 Set password of the encrypted root partition. This parameter is mandatory if `ENABLE_CRYPTFS`=true.
329
329
330 ##### `CRYPTFS_MAPPING`="secure"
330 ##### `CRYPTFS_MAPPING`="secure"
331 Set name of dm-crypt managed device-mapper mapping.
331 Set name of dm-crypt managed device-mapper mapping.
332
332
333 ##### `CRYPTFS_CIPHER`="aes-xts-plain64:sha512"
333 ##### `CRYPTFS_CIPHER`="aes-xts-plain64:sha512"
334 Set cipher specification string. `aes-xts*` ciphers are strongly recommended.
334 Set cipher specification string. `aes-xts*` ciphers are strongly recommended.
335
335
336 ##### `CRYPTFS_XTSKEYSIZE`=512
336 ##### `CRYPTFS_XTSKEYSIZE`=512
337 Sets key size in bits. The argument has to be a multiple of 8.
337 Sets key size in bits. The argument has to be a multiple of 8.
338
338
339 ---
339 ---
340
340
341 #### Build settings:
341 #### Build settings:
342 ##### `BASEDIR`=$(pwd)/images/${RELEASE}
342 ##### `BASEDIR`=$(pwd)/images/${RELEASE}
343 Set a path to a working directory used by the script to generate an image.
343 Set a path to a working directory used by the script to generate an image.
344
344
345 ##### `IMAGE_NAME`=${BASEDIR}/${DATE}-rpi${RPI_MODEL}-${RELEASE}
345 ##### `IMAGE_NAME`=${BASEDIR}/${DATE}-rpi${RPI_MODEL}-${RELEASE}
346 Set a filename for the output file(s). Note: the script will create $IMAGE_NAME.img if `ENABLE_SPLITFS`=false or $IMAGE_NAME-frmw.img and $IMAGE_NAME-root.img if `ENABLE_SPLITFS`=true.
346 Set a filename for the output file(s). Note: the script will create $IMAGE_NAME.img if `ENABLE_SPLITFS`=false or $IMAGE_NAME-frmw.img and $IMAGE_NAME-root.img if `ENABLE_SPLITFS`=true.
347
347
348 ## Understanding the script
348 ## Understanding the script
349 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:
349 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:
350
350
351 | Script | Description |
351 | Script | Description |
352 | --- | --- |
352 | --- | --- |
353 | `10-bootstrap.sh` | Debootstrap basic system |
353 | `10-bootstrap.sh` | Debootstrap basic system |
354 | `11-apt.sh` | Setup APT repositories |
354 | `11-apt.sh` | Setup APT repositories |
355 | `12-locale.sh` | Setup Locales and keyboard settings |
355 | `12-locale.sh` | Setup Locales and keyboard settings |
356 | `13-kernel.sh` | Build and install RPi2/3 Kernel |
356 | `13-kernel.sh` | Build and install RPi2/3 Kernel |
357 | `14-rpi-config.sh` | Setup RPi2/3 config and cmdline |
357 | `14-fstab.sh` | Setup fstab and initramfs |
358 | `15-rpi-config.sh` | Setup RPi2/3 config and cmdline |
358 | `20-networking.sh` | Setup Networking |
359 | `20-networking.sh` | Setup Networking |
359 | `21-firewall.sh` | Setup Firewall |
360 | `21-firewall.sh` | Setup Firewall |
360 | `30-security.sh` | Setup Users and Security settings |
361 | `30-security.sh` | Setup Users and Security settings |
361 | `31-logging.sh` | Setup Logging |
362 | `31-logging.sh` | Setup Logging |
362 | `32-sshd.sh` | Setup SSH and public keys |
363 | `32-sshd.sh` | Setup SSH and public keys |
363 | `41-uboot.sh` | Build and Setup U-Boot |
364 | `41-uboot.sh` | Build and Setup U-Boot |
364 | `42-fbturbo.sh` | Build and Setup fbturbo Xorg driver |
365 | `42-fbturbo.sh` | Build and Setup fbturbo Xorg driver |
365 | `50-firstboot.sh` | First boot actions |
366 | `50-firstboot.sh` | First boot actions |
366 | `99-reduce.sh` | Reduce the disk space usage |
367 | `99-reduce.sh` | Reduce the disk space usage |
367
368
368 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.
369 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.
369
370
370 | Directory | Description |
371 | Directory | Description |
371 | --- | --- |
372 | --- | --- |
372 | `apt` | APT management configuration files |
373 | `apt` | APT management configuration files |
373 | `boot` | Boot and RPi2/3 configuration files |
374 | `boot` | Boot and RPi2/3 configuration files |
374 | `dpkg` | Package Manager configuration |
375 | `dpkg` | Package Manager configuration |
375 | `etc` | Configuration files and rc scripts |
376 | `etc` | Configuration files and rc scripts |
376 | `firstboot` | Scripts that get executed on first boot |
377 | `firstboot` | Scripts that get executed on first boot |
377 | `initramfs` | Initramfs scripts |
378 | `initramfs` | Initramfs scripts |
378 | `iptables` | Firewall configuration files |
379 | `iptables` | Firewall configuration files |
379 | `locales` | Locales configuration |
380 | `locales` | Locales configuration |
380 | `modules` | Kernel Modules configuration |
381 | `modules` | Kernel Modules configuration |
381 | `mount` | Fstab configuration |
382 | `mount` | Fstab configuration |
382 | `network` | Networking configuration files |
383 | `network` | Networking configuration files |
383 | `sysctl.d` | Swapping and Network Hardening configuration |
384 | `sysctl.d` | Swapping and Network Hardening configuration |
384 | `xorg` | fbturbo Xorg driver configuration |
385 | `xorg` | fbturbo Xorg driver configuration |
385
386
386 ## Custom packages and scripts
387 ## Custom packages and scripts
387 Debian custom packages, i.e. those not in the debian repositories, can be installed by placing them in the `packages` directory. They are installed immediately after packages from the repositories are installed. Any dependencies listed in the custom packages will be downloaded automatically from the repositories. Do not list these custom packages in `APT_INCLUDES`.
388 Debian custom packages, i.e. those not in the debian repositories, can be installed by placing them in the `packages` directory. They are installed immediately after packages from the repositories are installed. Any dependencies listed in the custom packages will be downloaded automatically from the repositories. Do not list these custom packages in `APT_INCLUDES`.
388
389
389 Scripts in the custom.d directory will be executed after all other installation is complete but before the image is created.
390 Scripts in the custom.d directory will be executed after all other installation is complete but before the image is created.
390
391
391 ## Logging of the bootstrapping process
392 ## Logging of the bootstrapping process
392 All information related to the bootstrapping process and the commands executed by the `rpi23-gen-image.sh` script can easily be saved into a logfile. The common shell command `script` can be used for this purpose:
393 All information related to the bootstrapping process and the commands executed by the `rpi23-gen-image.sh` script can easily be saved into a logfile. The common shell command `script` can be used for this purpose:
393
394
394 ```shell
395 ```shell
395 script -c 'APT_SERVER=ftp.de.debian.org ./rpi23-gen-image.sh' ./build.log
396 script -c 'APT_SERVER=ftp.de.debian.org ./rpi23-gen-image.sh' ./build.log
396 ```
397 ```
397
398
398 ## Flashing the image file
399 ## Flashing the image file
399 After the image file was successfully created by the `rpi23-gen-image.sh` script it can be copied to the microSD card that will be used by the RPi2/3 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`.
400 After the image file was successfully created by the `rpi23-gen-image.sh` script it can be copied to the microSD card that will be used by the RPi2/3 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`.
400
401
401 #####Flashing examples:
402 #####Flashing examples:
402 ```shell
403 ```shell
403 bmaptool copy ./images/jessie/2017-01-23-rpi3-jessie.img /dev/mmcblk0
404 bmaptool copy ./images/jessie/2017-01-23-rpi3-jessie.img /dev/mmcblk0
404 dd bs=4M if=./images/jessie/2017-01-23-rpi3-jessie.img of=/dev/mmcblk0
405 dd bs=4M if=./images/jessie/2017-01-23-rpi3-jessie.img of=/dev/mmcblk0
405 ```
406 ```
406 If you have set `ENABLE_SPLITFS`, copy the `-frmw` image on the microSD card, then the `-root` one on the USB drive:
407 If you have set `ENABLE_SPLITFS`, copy the `-frmw` image on the microSD card, then the `-root` one on the USB drive:
407 ```shell
408 ```shell
408 bmaptool copy ./images/jessie/2017-01-23-rpi3-jessie-frmw.img /dev/mmcblk0
409 bmaptool copy ./images/jessie/2017-01-23-rpi3-jessie-frmw.img /dev/mmcblk0
409 bmaptool copy ./images/jessie/2017-01-23-rpi3-jessie-root.img /dev/sdc
410 bmaptool copy ./images/jessie/2017-01-23-rpi3-jessie-root.img /dev/sdc
410 ```
411 ```
411
412
412 ## External links and references
413 ## External links and references
413 * [Debian worldwide mirror sites](https://www.debian.org/mirror/list)
414 * [Debian worldwide mirror sites](https://www.debian.org/mirror/list)
414 * [Debian Raspberry Pi 2 Wiki](https://wiki.debian.org/RaspberryPi2)
415 * [Debian Raspberry Pi 2 Wiki](https://wiki.debian.org/RaspberryPi2)
415 * [Debian CrossToolchains Wiki](https://wiki.debian.org/CrossToolchains)
416 * [Debian CrossToolchains Wiki](https://wiki.debian.org/CrossToolchains)
416 * [Official Raspberry Pi Firmware on github](https://github.com/raspberrypi/firmware)
417 * [Official Raspberry Pi Firmware on github](https://github.com/raspberrypi/firmware)
417 * [Official Raspberry Pi Kernel on github](https://github.com/raspberrypi/linux)
418 * [Official Raspberry Pi Kernel on github](https://github.com/raspberrypi/linux)
418 * [U-BOOT git repository](http://git.denx.de/?p=u-boot.git;a=summary)
419 * [U-BOOT git repository](http://git.denx.de/?p=u-boot.git;a=summary)
419 * [Xorg DDX driver fbturbo](https://github.com/ssvb/xf86-video-fbturbo)
420 * [Xorg DDX driver fbturbo](https://github.com/ssvb/xf86-video-fbturbo)
420 * [RPi3 Wireless interface firmware](https://github.com/RPi-Distro/firmware-nonfree/tree/master/brcm80211/brcm)
421 * [RPi3 Wireless interface firmware](https://github.com/RPi-Distro/firmware-nonfree/tree/master/brcm80211/brcm)
421 * [Collabora RPi2 Kernel precompiled](https://repositories.collabora.co.uk/debian/)
422 * [Collabora RPi2 Kernel precompiled](https://repositories.collabora.co.uk/debian/)
@@ -1,210 +1,160
1 #
1 #
2 # Build and Setup RPi2/3 Kernel
2 # Build and Setup RPi2/3 Kernel
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 # Fetch and build latest raspberry kernel
8 # Fetch and build latest raspberry kernel
9 if [ "$BUILD_KERNEL" = true ] ; then
9 if [ "$BUILD_KERNEL" = true ] ; then
10 # Setup source directory
10 # Setup source directory
11 mkdir -p "${R}/usr/src"
11 mkdir -p "${R}/usr/src"
12
12
13 # Copy existing kernel sources into chroot directory
13 # Copy existing kernel sources into chroot directory
14 if [ -n "$KERNELSRC_DIR" ] && [ -d "$KERNELSRC_DIR" ] ; then
14 if [ -n "$KERNELSRC_DIR" ] && [ -d "$KERNELSRC_DIR" ] ; then
15 # Copy kernel sources
15 # Copy kernel sources
16 cp -r "${KERNELSRC_DIR}" "${R}/usr/src"
16 cp -r "${KERNELSRC_DIR}" "${R}/usr/src"
17
17
18 # Clean the kernel sources
18 # Clean the kernel sources
19 if [ "$KERNELSRC_CLEAN" = true ] && [ "$KERNELSRC_PREBUILT" = false ] ; then
19 if [ "$KERNELSRC_CLEAN" = true ] && [ "$KERNELSRC_PREBUILT" = false ] ; then
20 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" mrproper
20 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" mrproper
21 fi
21 fi
22 else # KERNELSRC_DIR=""
22 else # KERNELSRC_DIR=""
23 # Fetch current raspberrypi kernel sources
23 # Fetch current raspberrypi kernel sources
24 git -C "${R}/usr/src" clone --depth=1 "${KERNEL_URL}"
24 git -C "${R}/usr/src" clone --depth=1 "${KERNEL_URL}"
25 fi
25 fi
26
26
27 # Calculate optimal number of kernel building threads
27 # Calculate optimal number of kernel building threads
28 if [ "$KERNEL_THREADS" = "1" ] && [ -r /proc/cpuinfo ] ; then
28 if [ "$KERNEL_THREADS" = "1" ] && [ -r /proc/cpuinfo ] ; then
29 KERNEL_THREADS=$(grep -c processor /proc/cpuinfo)
29 KERNEL_THREADS=$(grep -c processor /proc/cpuinfo)
30 fi
30 fi
31
31
32 # Configure and build kernel
32 # Configure and build kernel
33 if [ "$KERNELSRC_PREBUILT" = false ] ; then
33 if [ "$KERNELSRC_PREBUILT" = false ] ; then
34 # Remove device, network and filesystem drivers from kernel configuration
34 # Remove device, network and filesystem drivers from kernel configuration
35 if [ "$KERNEL_REDUCE" = true ] ; then
35 if [ "$KERNEL_REDUCE" = true ] ; then
36 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
36 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
37 sed -i\
37 sed -i\
38 -e "s/\(^CONFIG_SND.*\=\).*/\1n/"\
38 -e "s/\(^CONFIG_SND.*\=\).*/\1n/"\
39 -e "s/\(^CONFIG_SOUND.*\=\).*/\1n/"\
39 -e "s/\(^CONFIG_SOUND.*\=\).*/\1n/"\
40 -e "s/\(^CONFIG_AC97.*\=\).*/\1n/"\
40 -e "s/\(^CONFIG_AC97.*\=\).*/\1n/"\
41 -e "s/\(^CONFIG_VIDEO_.*\=\).*/\1n/"\
41 -e "s/\(^CONFIG_VIDEO_.*\=\).*/\1n/"\
42 -e "s/\(^CONFIG_MEDIA_TUNER.*\=\).*/\1n/"\
42 -e "s/\(^CONFIG_MEDIA_TUNER.*\=\).*/\1n/"\
43 -e "s/\(^CONFIG_DVB.*\=\)[ym]/\1n/"\
43 -e "s/\(^CONFIG_DVB.*\=\)[ym]/\1n/"\
44 -e "s/\(^CONFIG_REISERFS.*\=\).*/\1n/"\
44 -e "s/\(^CONFIG_REISERFS.*\=\).*/\1n/"\
45 -e "s/\(^CONFIG_JFS.*\=\).*/\1n/"\
45 -e "s/\(^CONFIG_JFS.*\=\).*/\1n/"\
46 -e "s/\(^CONFIG_XFS.*\=\).*/\1n/"\
46 -e "s/\(^CONFIG_XFS.*\=\).*/\1n/"\
47 -e "s/\(^CONFIG_GFS2.*\=\).*/\1n/"\
47 -e "s/\(^CONFIG_GFS2.*\=\).*/\1n/"\
48 -e "s/\(^CONFIG_OCFS2.*\=\).*/\1n/"\
48 -e "s/\(^CONFIG_OCFS2.*\=\).*/\1n/"\
49 -e "s/\(^CONFIG_BTRFS.*\=\).*/\1n/"\
49 -e "s/\(^CONFIG_BTRFS.*\=\).*/\1n/"\
50 -e "s/\(^CONFIG_HFS.*\=\).*/\1n/"\
50 -e "s/\(^CONFIG_HFS.*\=\).*/\1n/"\
51 -e "s/\(^CONFIG_JFFS2.*\=\)[ym]/\1n/"\
51 -e "s/\(^CONFIG_JFFS2.*\=\)[ym]/\1n/"\
52 -e "s/\(^CONFIG_UBIFS.*\=\).*/\1n/"\
52 -e "s/\(^CONFIG_UBIFS.*\=\).*/\1n/"\
53 -e "s/\(^CONFIG_SQUASHFS.*\=\)[ym]/\1n/"\
53 -e "s/\(^CONFIG_SQUASHFS.*\=\)[ym]/\1n/"\
54 -e "s/\(^CONFIG_W1.*\=\)[ym]/\1n/"\
54 -e "s/\(^CONFIG_W1.*\=\)[ym]/\1n/"\
55 -e "s/\(^CONFIG_HAMRADIO.*\=\).*/\1n/"\
55 -e "s/\(^CONFIG_HAMRADIO.*\=\).*/\1n/"\
56 -e "s/\(^CONFIG_CAN.*\=\).*/\1n/"\
56 -e "s/\(^CONFIG_CAN.*\=\).*/\1n/"\
57 -e "s/\(^CONFIG_IRDA.*\=\).*/\1n/"\
57 -e "s/\(^CONFIG_IRDA.*\=\).*/\1n/"\
58 -e "s/\(^CONFIG_BT_.*\=\).*/\1n/"\
58 -e "s/\(^CONFIG_BT_.*\=\).*/\1n/"\
59 -e "s/\(^CONFIG_WIMAX.*\=\)[ym]/\1n/"\
59 -e "s/\(^CONFIG_WIMAX.*\=\)[ym]/\1n/"\
60 -e "s/\(^CONFIG_6LOWPAN.*\=\).*/\1n/"\
60 -e "s/\(^CONFIG_6LOWPAN.*\=\).*/\1n/"\
61 -e "s/\(^CONFIG_IEEE802154.*\=\).*/\1n/"\
61 -e "s/\(^CONFIG_IEEE802154.*\=\).*/\1n/"\
62 -e "s/\(^CONFIG_NFC.*\=\).*/\1n/"\
62 -e "s/\(^CONFIG_NFC.*\=\).*/\1n/"\
63 -e "s/\(^CONFIG_FB_TFT=.*\=\).*/\1n/"\
63 -e "s/\(^CONFIG_FB_TFT=.*\=\).*/\1n/"\
64 -e "s/\(^CONFIG_TOUCHSCREEN.*\=\).*/\1n/"\
64 -e "s/\(^CONFIG_TOUCHSCREEN.*\=\).*/\1n/"\
65 -e "s/\(^CONFIG_USB_GSPCA_.*\=\).*/\1n/"\
65 -e "s/\(^CONFIG_USB_GSPCA_.*\=\).*/\1n/"\
66 -e "s/\(^CONFIG_DRM.*\=\).*/\1n/"\
66 -e "s/\(^CONFIG_DRM.*\=\).*/\1n/"\
67 "${KERNEL_DIR}/.config"
67 "${KERNEL_DIR}/.config"
68 fi
68 fi
69
69
70 if [ "$KERNELSRC_CONFIG" = true ] ; then
70 if [ "$KERNELSRC_CONFIG" = true ] ; then
71 # Load default raspberry kernel configuration
71 # Load default raspberry kernel configuration
72 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
72 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
73
73
74 if [ ! -z "$KERNELSRC_USRCONFIG" ] ; then
74 if [ ! -z "$KERNELSRC_USRCONFIG" ] ; then
75 cp $KERNELSRC_USRCONFIG ${KERNEL_DIR}/.config
75 cp $KERNELSRC_USRCONFIG ${KERNEL_DIR}/.config
76 fi
76 fi
77
77
78 # Start menu-driven kernel configuration (interactive)
78 # Start menu-driven kernel configuration (interactive)
79 if [ "$KERNEL_MENUCONFIG" = true ] ; then
79 if [ "$KERNEL_MENUCONFIG" = true ] ; then
80 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" menuconfig
80 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" menuconfig
81 fi
81 fi
82 fi
82 fi
83
83
84 # Cross compile kernel and modules
84 # Cross compile kernel and modules
85 make -C "${KERNEL_DIR}" -j${KERNEL_THREADS} ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" zImage modules dtbs
85 make -C "${KERNEL_DIR}" -j${KERNEL_THREADS} ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" zImage modules dtbs
86 fi
86 fi
87
87
88 # Check if kernel compilation was successful
88 # Check if kernel compilation was successful
89 if [ ! -r "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/zImage" ] ; then
89 if [ ! -r "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/zImage" ] ; then
90 echo "error: kernel compilation failed! (zImage not found)"
90 echo "error: kernel compilation failed! (zImage not found)"
91 cleanup
91 cleanup
92 exit 1
92 exit 1
93 fi
93 fi
94
94
95 # Install kernel modules
95 # Install kernel modules
96 if [ "$ENABLE_REDUCE" = true ] ; then
96 if [ "$ENABLE_REDUCE" = true ] ; then
97 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=../../.. modules_install
97 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=../../.. modules_install
98 else
98 else
99 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install
99 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install
100
100
101 # Install kernel firmware
101 # Install kernel firmware
102 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install
102 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install
103 fi
103 fi
104
104
105 # Install kernel headers
105 # Install kernel headers
106 if [ "$KERNEL_HEADERS" = true ] && [ "$KERNEL_REDUCE" = false ] ; then
106 if [ "$KERNEL_HEADERS" = true ] && [ "$KERNEL_REDUCE" = false ] ; then
107 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_HDR_PATH=../.. headers_install
107 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_HDR_PATH=../.. headers_install
108 fi
108 fi
109
109
110 # Prepare boot (firmware) directory
110 # Prepare boot (firmware) directory
111 mkdir "${BOOT_DIR}"
111 mkdir "${BOOT_DIR}"
112
112
113 # Get kernel release version
113 # Get kernel release version
114 KERNEL_VERSION=`cat "${KERNEL_DIR}/include/config/kernel.release"`
114 KERNEL_VERSION=`cat "${KERNEL_DIR}/include/config/kernel.release"`
115
115
116 # Copy kernel configuration file to the boot directory
116 # Copy kernel configuration file to the boot directory
117 install_readonly "${KERNEL_DIR}/.config" "${R}/boot/config-${KERNEL_VERSION}"
117 install_readonly "${KERNEL_DIR}/.config" "${R}/boot/config-${KERNEL_VERSION}"
118
118
119 # Copy dts and dtb device tree sources and binaries
119 # Copy dts and dtb device tree sources and binaries
120 mkdir "${BOOT_DIR}/overlays"
120 mkdir "${BOOT_DIR}/overlays"
121 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/"*.dtb "${BOOT_DIR}/"
121 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/"*.dtb "${BOOT_DIR}/"
122 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/"*.dtb* "${BOOT_DIR}/overlays/"
122 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/"*.dtb* "${BOOT_DIR}/overlays/"
123 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" "${BOOT_DIR}/overlays/README"
123 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" "${BOOT_DIR}/overlays/README"
124
124
125 if [ "$ENABLE_UBOOT" = false ] ; then
125 if [ "$ENABLE_UBOOT" = false ] ; then
126 # Convert and copy zImage kernel to the boot directory
126 # Convert and copy zImage kernel to the boot directory
127 "${KERNEL_DIR}/scripts/mkknlimg" "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/zImage" "${BOOT_DIR}/${KERNEL_IMAGE}"
127 "${KERNEL_DIR}/scripts/mkknlimg" "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/zImage" "${BOOT_DIR}/${KERNEL_IMAGE}"
128 else
128 else
129 # Copy zImage kernel to the boot directory
129 # Copy zImage kernel to the boot directory
130 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/zImage" "${BOOT_DIR}/${KERNEL_IMAGE}"
130 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/zImage" "${BOOT_DIR}/${KERNEL_IMAGE}"
131 fi
131 fi
132
132
133 # Remove kernel sources
133 # Remove kernel sources
134 if [ "$KERNEL_REMOVESRC" = true ] ; then
134 if [ "$KERNEL_REMOVESRC" = true ] ; then
135 rm -fr "${KERNEL_DIR}"
135 rm -fr "${KERNEL_DIR}"
136 else
136 else
137 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" modules_prepare
137 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" modules_prepare
138
139 # Create symlinks for kernel modules
140 ln -sf "${KERNEL_DIR}" "${R}/lib/modules/${KERNEL_VERSION}/build"
141 ln -sf "${KERNEL_DIR}" "${R}/lib/modules/${KERNEL_VERSION}/source"
138 fi
142 fi
139
143
140 else # BUILD_KERNEL=false
144 else # BUILD_KERNEL=false
141 # Kernel installation
145 # Kernel installation
142 chroot_exec apt-get -qq -y --no-install-recommends install linux-image-"${COLLABORA_KERNEL}" raspberrypi-bootloader-nokernel
146 chroot_exec apt-get -qq -y --no-install-recommends install linux-image-"${COLLABORA_KERNEL}" raspberrypi-bootloader-nokernel
143
147
144 # Install flash-kernel last so it doesn't try (and fail) to detect the platform in the chroot
148 # Install flash-kernel last so it doesn't try (and fail) to detect the platform in the chroot
145 chroot_exec apt-get -qq -y install flash-kernel
149 chroot_exec apt-get -qq -y install flash-kernel
146
150
147 # Check if kernel installation was successful
151 # Check if kernel installation was successful
148 VMLINUZ="$(ls -1 ${R}/boot/vmlinuz-* | sort | tail -n 1)"
152 VMLINUZ="$(ls -1 ${R}/boot/vmlinuz-* | sort | tail -n 1)"
149 if [ -z "$VMLINUZ" ] ; then
153 if [ -z "$VMLINUZ" ] ; then
150 echo "error: kernel installation failed! (/boot/vmlinuz-* not found)"
154 echo "error: kernel installation failed! (/boot/vmlinuz-* not found)"
151 cleanup
155 cleanup
152 exit 1
156 exit 1
153 fi
157 fi
154 # Copy vmlinuz kernel to the boot directory
158 # Copy vmlinuz kernel to the boot directory
155 install_readonly "${VMLINUZ}" "${BOOT_DIR}/${KERNEL_IMAGE}"
159 install_readonly "${VMLINUZ}" "${BOOT_DIR}/${KERNEL_IMAGE}"
156 fi
160 fi
157
158 # Create symlinks for kernel modules
159 ln -sf "${KERNEL_DIR}" "${R}/lib/modules/${KERNEL_VERSION}/build"
160 ln -sf "${KERNEL_DIR}" "${R}/lib/modules/${KERNEL_VERSION}/source"
161
162 # Install and setup fstab
163 install_readonly files/mount/fstab "${ETC_DIR}/fstab"
164
165 # Add usb/sda disk root partition to fstab
166 if [ "$ENABLE_SPLITFS" = true ] && [ "$ENABLE_CRYPTFS" = false ] ; then
167 sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/fstab"
168 fi
169
170 # Add encrypted root partition to fstab and crypttab
171 if [ "$ENABLE_CRYPTFS" = true ] ; then
172 # Replace fstab root partition with encrypted partition mapping
173 sed -i "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING}/" "${ETC_DIR}/fstab"
174
175 # Add encrypted partition to crypttab and fstab
176 install_readonly files/mount/crypttab "${ETC_DIR}/crypttab"
177 echo "${CRYPTFS_MAPPING} /dev/mmcblk0p2 none luks" >> "${ETC_DIR}/crypttab"
178
179 if [ "$ENABLE_SPLITFS" = true ] ; then
180 # Add usb/sda disk to crypttab
181 sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/crypttab"
182 fi
183 fi
184
185 # Generate initramfs file
186 if [ "$ENABLE_INITRAMFS" = true ] ; then
187 if [ "$ENABLE_CRYPTFS" = true ] ; then
188 # Include initramfs scripts to auto expand encrypted root partition
189 if [ "$EXPANDROOT" = true ] ; then
190 install_exec files/initramfs/expand_encrypted_rootfs "${ETC_DIR}/initramfs-tools/scripts/init-premount/expand_encrypted_rootfs"
191 install_exec files/initramfs/expand-premount "${ETC_DIR}/initramfs-tools/scripts/local-premount/expand-premount"
192 install_exec files/initramfs/expand-tools "${ETC_DIR}/initramfs-tools/hooks/expand-tools"
193 fi
194
195 # Disable SSHD inside initramfs
196 printf "#\n# DROPBEAR: [ y | n ]\n#\n\nDROPBEAR=n\n" >> "${ETC_DIR}/initramfs-tools/initramfs.conf"
197
198 # Dummy mapping required by mkinitramfs
199 echo "0 1 crypt $(echo ${CRYPTFS_CIPHER} | cut -d ':' -f 1) ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 7:0 4096" | chroot_exec dmsetup create "${CRYPTFS_MAPPING}"
200
201 # Generate initramfs with encrypted root partition support
202 chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}"
203
204 # Remove dummy mapping
205 chroot_exec cryptsetup close "${CRYPTFS_MAPPING}"
206 else
207 # Generate initramfs without encrypted root partition support
208 chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}"
209 fi
210 fi
1 NO CONTENT: file renamed from bootstrap.d/14-rpi-config.sh to bootstrap.d/15-rpi-config.sh
NO CONTENT: file renamed from bootstrap.d/14-rpi-config.sh to bootstrap.d/15-rpi-config.sh
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant