operating_systems:raspbian:clean_installation
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| operating_systems:raspbian:clean_installation [2019/05/14 12:07] – maferreira | operating_systems:raspbian:clean_installation [2019/07/22 09:49] (current) – removed maferreira | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Create a clean raspbian image ====== | ||
| - | ===== Clean your sd card ===== | ||
| - | Before writing the raspbian image into your sd card, clean your storage device by turning all its bits into 0. | ||
| - | # dd if=/ | ||
| - | ===== Burn raspbian image into sd card ===== | ||
| - | # dd if=/ | ||
| - | |||
| - | ===== Serial connection and disable first boot autosize ===== | ||
| - | <note important> | ||
| - | |||
| - | ==== Backup cmdline.txt and config.txt ==== | ||
| - | Before modifying **cmdline.txt** and **config.txt**, | ||
| - | $ cp -p cmdline.txt cmdline.txt.original | ||
| - | $ cp -p config.txt config.txt.original | ||
| - | |||
| - | ==== Modify cmdline.txt ==== | ||
| - | Once you have finished, change the output console device and remove the script that autoexpands / partition size at first startup. | ||
| - | $ vi cmdline.txt | ||
| - | console=serial0, | ||
| - | delete init=/ | ||
| - | |||
| - | ==== Modify config.txt ==== | ||
| - | Don't forget to enable this option, otherwise you won't be able to communicate to your raspberry pi throught raspberry debug port (TTL-232R-RPi). | ||
| - | $ vi config.txt | ||
| - | add this : enable_uart=1 | ||
| - | |||
| - | / | ||
| - | devtmpfs | ||
| - | tmpfs | ||
| - | tmpfs | ||
| - | tmpfs | ||
| - | tmpfs | ||
| - | / | ||
| - | tmpfs 93M | ||
| - | |||
| - | ===== Resize / manualy and create /media/data partition ===== | ||
| - | Now, resize the / partition and create a new one. | ||
| - | # fdisk / | ||
| - | Your partition table should look like this : | ||
| - | Device | ||
| - | / | ||
| - | / | ||
| - | Delete the / partition, and create a new one (primary) which starts at **THE SAME POSITION** as the one you have just deleted, in my case **98304**.\\ | ||
| - | |||
| - | In the **fstab**, replace **PARTUUID** by / | ||
| - | # resize2fs / | ||
| - | |||
| - | After creating the partition that will be mounted at / | ||
| - | # mkfs.ext4 / | ||
| - | # mkdir -p /media/data | ||
| - | | ||
| - | # vi /etc/fstab | ||
| - | / | ||
| - | |||
| - | <note important> | ||
| - | |||
| - | Now, it's time to test what you have done. | ||
| - | # mount -a | ||
| - | $ df -h | ||
| - | | ||
| - | Filesystem | ||
| - | / | ||
| - | devtmpfs | ||
| - | tmpfs | ||
| - | tmpfs | ||
| - | tmpfs | ||
| - | tmpfs | ||
| - | tmpfs | ||
| - | tmpfs | ||
| - | tmpfs | ||
| - | tmpfs | ||
| - | / | ||
| - | tmpfs 93M | ||
| - | / | ||
| - | |||
| - | ===== Update raspbian packages and install needed packages ===== | ||
| - | # apt update | ||
| - | # apt upgrade | ||
| - | # apt install --no-install-recommends tree lsof nmap git | ||
| - | |||
| - | ===== Enable ssh ===== | ||
| - | touch /boot/ssh | ||
| - | # systemctl enable ssh | ||
| - | # systemctl start ssh | ||
| - | Reference : https:// | ||
| - | |||
| - | ===== Mount partitions ===== | ||
| - | # vi /etc/fstab | ||
| - | tmpfs / | ||
| - | tmpfs / | ||
| - | tmpfs / | ||
| - | tmpfs / | ||
| - | | ||
| - | # reboot | ||
| - | <note important> | ||
| - | |||
| - | Systemd-hostnamed doest not start | ||
| - | # vi /etc/fstab | ||
| - | tmpfs / | ||
| - | |||
| - | Check if there are any errors | ||
| - | ===== Fix rsyslog / | ||
| - | ==== By unit file ==== | ||
| - | # vi / | ||
| - | | ||
| - | [Unit] | ||
| - | Description=Generate Rsyslog structure | ||
| - | Before=syslog.service | ||
| - | | ||
| - | [Service] | ||
| - | ExecStart=/ | ||
| - | Type=oneshot | ||
| - | | ||
| - | [Install] | ||
| - | WantedBy=default.target | ||
| - | |||
| - | $ vi / | ||
| - | #!/bin/bash | ||
| - | | ||
| - | if [ -r / | ||
| - | WorkDirectory=$(grep " | ||
| - | else | ||
| - | echo " | ||
| - | exit 1 | ||
| - | fi | ||
| - | | ||
| - | if [ ! -d " | ||
| - | mkdir $WorkDirectory | ||
| - | fi | ||
| - | | ||
| - | exit 0 | ||
| - | |||
| - | sudo chmod 664 generateRsyslogStructure.service | ||
| - | chmod a+x generateRsyslogStructure.sh | ||
| - | | ||
| - | # systemctl enable generateRsyslogStructure.service | ||
| - | ==== By tmpfiles.d config files ==== | ||
| - | # vi / | ||
| - | d / | ||
| - | | ||
| - | # mkdir / | ||
| - | |||
| - | Reference: [[http:// | ||
| - | |||
| - | ===== Disable swap ===== | ||
| - | # systemctl stop dphys-swapfile.service | ||
| - | # systemctl disable dphys-swapfile.service | ||
| - | # reboot | ||
| - | |||
| - | ===== Mount system in read-only mode ===== | ||
| - | # vi /etc/fstab | ||
| - | / | ||
| - | / | ||
| - | |||
| - | <note important> | ||
| - | |||
| - | Systemd manual: https:// | ||
| - | |||
| - | ===== Disable apt-daily.service and apt-daily-upgrade.service===== | ||
| - | If you reboot your raspberry pi, you might see that apt-daily-upgrade.service failed to start. This happens because your system is in read-only mode. To solve this, disable it and it's timer. | ||
| - | |||
| - | root@3780:/ | ||
| - | NEXT LEFT | ||
| - | Mon 2019-05-06 20:48:57 CEST 6h left Mon 2019-05-06 08:38:50 CEST 6h ago | ||
| - | Tue 2019-05-07 06:39:25 CEST 15h left Mon 2019-05-06 14:27:48 CEST 19min ago apt-daily-upgrade.timer | ||
| - | Tue 2019-05-07 14:43:08 CEST 23h left Mon 2019-05-06 14:43:08 CEST 3min 45s ago systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service | ||
| - | |||
| - | Now that you have the timer and ther unit name, stop and disable them. | ||
| - | # systemctl stop apt-daily.timer | ||
| - | # systemctl stop apt-daily.service | ||
| - | | ||
| - | # systemctl disable apt-daily.timer | ||
| - | # systemctl disable apt-daily.service | ||
| - | |||
| - | # systemctl stop apt-daily-upgrade.timer | ||
| - | # systemctl stop apt-daily-upgrade.service | ||
| - | | ||
| - | # systemctl disable apt-daily-upgrade.timer | ||
| - | # systemctl disable apt-daily-upgrade.service | ||
| - | |||
| - | ===== systemd-tmpfiles ===== | ||
| - | This service doesn' | ||
| - | # mkdir -p / | ||
| - | # rm -r / | ||
| - | | ||
| - | # ln -s / | ||
operating_systems/raspbian/clean_installation.1557835635.txt.gz · Last modified: 2019/05/14 12:07 by maferreira