RPi: Customized Unattended Installation
by Gosse Adema in Circuits > Raspberry Pi
6714 Views, 21 Favorites, 0 Comments
RPi: Customized Unattended Installation
This Instructable is about modifying the Raspberry Pi Noobs Installer.
The default Raspberry Pi (Noobs/Raspbian) installation has a lot of pre-installed software. And Raspbian needs a 8 Gbyte SD-card, to install all these packages. But do you really need all this software for your Raspberry Pi project?
There are probably also several background processes which are not useful for your project. And they all take CPU power and memory from your limited resources. You can disable these processes, but uninstalling unneeded software also removes these processes.
We'll start with modifying the original Noobs-files to enable the silent installer. This will allow an unattended installation, without keyboard and monitor. This makes it very easy to install a Raspberry Zero!
Then we'll change the network setting inside the Installer-files. This will give a fixed IP address, and an automatic Wifi connection, right after installation.
Next step is to configure and minimize the installed software. My first goal is to be able to install on a 4 GByte SD-card.
And, after customizing the OS, it's time to create your own installer: Instructables + Raspbian = Instructian.
Finally, it's time to install Raspbian on a 1 Gbyte SD-card!
Changing the Noobs Installer
Download the latest Noobs installer from the RaspberryPi.org website. The current version is 1.8. (I've used the following modifications since version 1.5.)
Create a copy and open the archive-file with 7zip. Keep this file open, until all steps are completed.
Edit the recovery.cmdline-file in the root-folder. And append "silentinstall" to the end of the arguments list. Save the file and close the editor. There will be a message that the recovery.cmdline was modified. Choose "OK" to update the archive.
------------------------------------- /recovery.cmdline (add silentinstall) ------------------------------------- runinstaller quiet ramdisk_size=32768 root=/dev/ram0 init=/init vt.cur_default=1 elevator=deadline silentinstall
Now open the "Os" folder. This folder contains the Raspbian operating system. Opening the Raspbian folder shows the following files:
slides_vga (folder) root.tar.xz release_notes.txt Raspbian.png partition_setup.sh partitions.json os.json boot.tar.xz
The root.tar.xz and the boot.tar.xz files contain compressed disk images. These are extracted to linux partitions during installation.
Both json-files contain information needed by the installer. You can change the default password (raspberry) by editing the os.json-file:
{ "name": "Raspbian", "version": "jessie", "release_date": "2016-02-26", "kernel": "4.1", "description": "A community-created port of Debian jessie for the Raspberry Pi", "url": "http://www.raspbian.org/", "username": "pi", "password": "raspberry", "supported_models": ["Pi Model","Pi 2","Pi Zero","Pi 3"] }
Next step is to configure a fixed IP-address and WIFI.
We need to alter two files inside the root.tar.xz-file. Open (inside 7Zip) the root.tar.xz-file. And open (also inside 7Zip) the root.tar-file. This will take a while to extract to a temporary location. Browse to the /etc/network-folder and modify the interfaces-file. Replace the wlan0 part with those settings needed for your network:
allow-hotplug wlan0 iface wlan0 inet static address 192.168.1.11 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.1 wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
Save the changes, close the editor and update the archive. Next file to edit is the wpa_supplicant.conf inside the /etc/wpa_supplicant folder. Append your WIFI setting to the end of this file. Close the file and update the archive (again).
network={ ssid="WifiAtHome" psk="Password"}
Browse Up (icon left to the folder name) until you get the message that the root.tar file was modified. Choose "OK" to update the archive (this will take a while). Next step is to update the root.tar.xz-file (this takes less time than the root.tar file).
Use SDformatter for formating a SD-card. And extract the modified NOOBS-file onto the SD-card. Insert the card into the Raspberry Pi and wait until the operating system is installed (the green led wil stop blinking).
Now we have an Customized Unattended Installer. And now it is time to start experimenting. Just use this, newly created installer, when something goes wrong.
It All Depends...
The default Noobs/Raspbian installation has has much preinstalled software. But how do you determine which packages you really need?
I have used two methods to find the minimum required packages:
- Query all installed packages with "apt list". Each package has a "Priority" and a "Section".
- Raspbian is based on Debian. Installing a "minimal" Debian provides a "needed" package list.
Beware, you can't just start removing files from the SD-card. Most files and packages have dependencies with other files or packages. Use APT (Advanced Package Tool) to remove unwanted software. And there are two ways to remove packages with APT:
- Remove: Packages installed are removed (Does NOT include configuration files).
- Purge: Identical to remove except that any configuration files are deleted too.
Priority
The following bash-script returns all installed packages with their priority:
for i in `apt list --installed | sed 's/\/.*$//' | grep -v "Listing..."` do j=`apt-cache show $i | grep "^Priority:"` echo $i": "$j done > priority.txt
This script creates a priority.txt-file with the following content:
acl: Priority: optional adduser: Priority: important adwaita-icon-theme: Priority: optional alacarte: Priority: optional alsa-base: Priority: optional ... xz-utils: Priority: required zenity: Priority: optional zenity-common: Priority: optional zlib1g: Priority: required zlib1g-dev: Priority: optional
There are 1147 installed packages. The Noobs 1.8 Excel file contains a list of all installed packages. I've used this file to select al unwanted packages.
Downloads
8 Gbyte SD Card - Default
After installation the following partitions are created on the SD-card:
Device Boot Start End Sectors Size Id Type /dev/mmcblk0p1 8192 2261718 2253527 1.1G e W95 FAT16 (LBA) /dev/mmcblk0p2 2261719 15523839 13262121 6.3G 5 Extended /dev/mmcblk0p5 2269184 2334717 65534 32M 83 Linux /dev/mmcblk0p6 2334720 2463743 129024 63M c W95 FAT32 (LBA) /dev/mmcblk0p7 2465792 15523839 13058048 6.2G 83 Linux
Not all partitions are used by Linux. The first partition is the recovery-partition. It is used for booting the Raspberry Pi. And also contains a recovery-copy of the Raspbian operating system. These are the files which are modified in step 1 of this Instructable.
The second partition is an extended partition. This contains the partitions which are used by Linux.
The /etc/fstab-file shows which files are mounted after booting:
proc /proc proc defaults 0 0 /dev/mmcblk0p6 /boot vfat defaults 0 2 /dev/mmcblk0p7 / ext4 defaults,noatime 0 1 # a swapfile is not a swap partition, no line here # use dphys-swapfile swap[on|off] for that
The mmcblk0p6 and mmcblk0p7 are partitions created by the installer and all files from boot.tar.xz and root.tar.xz are copied to these partitions.
Te root-partition (/) has a size of 6.2 Gbyte. And "df -k" shows that 58% of the file system is in use:
Filesystem 1K-blocks Used Available Use% Mounted on /dev/root 6295280 3423868 2528580 58% / devtmpfs 469708 0 469708 0% /dev tmpfs 474028 0 474028 0% /dev/shm tmpfs 474028 6436 467592 2% /run tmpfs 5120 4 5116 1% /run/lock tmpfs 474028 0 474028 0% /sys/fs/cgroup /dev/mmcblk0p6 64366 19948 44418 31% /boot tmpfs 94808 0 94808 0% /run/user/1000 /dev/mmcblk0p5 30701 397 28011 2% /media/pi/SETTINGS
Notice partition 5 (/dev/mmcblk0p5). This partition doesn't show up in the /etc/fstab-file. It is automatically mounted after booting (just like any other USB-storage).
Summary
A default installation has the following partitions on the SD-card:
- Partition 1: Boot and recovery files (1.1 Gbyte).
- Partition 2: Extended partition which contains partition 5, 6 and 7.
- Partition 5: Configuration files
- Partition 6: Boot-partition
- Partition 7: Root-partition (6.2 Gbyte, 58% in use).
The default Noobs installation will never fit on a 4 Gbyte SD-card. This requires 58% of 6.2Gbyte = 3,6 Gbyte for the Linux files and 1.1 Gbyte for the installer.
4 Gbyte SD Card - I Don't Need a GUI
After installing NOOBS there are about 110 active processes (ps -ef | wc -l). Some of these processes are required for the graphical interface. Because my projects don't require a graphical interface, it's time to turn this off:
sudo raspi-config
2 - Change User Password 3 - boot options: No need for graphical interface: B1 Console 9 - Advanced options: Hostname : chronos
Reboot your Raspberry Pi, now there are 86 active processes.
Next step is to remove all unnecessary packages.
The first, to delete, packages are the "non-free/devel" packages. They are all optional, and are the largest section (second image).
df -h / Filesystem Size Used Avail Use% Mounted on /dev/root 6295280 3423868 2528580 58% / sudo apt purge oracle-java8-jdk wolfram-engine df -k / Filesystem 1K-blocks Used Available Use% Mounted on /dev/root 6295280 2805012 3147436 48% /
And the used space in the root-partition went from 58% to 48%.
I've also uninstalled all GUI (and other unneeded) packages, using my Excel-file, except libx11-data and x11-common (these files still have dependencies).
sudo apt purge adwaita-icon-theme coinor-libcbc3 coinor-libcgl1 coinor-libclp1 coinor-libcoinutils3 coinor-libosi1 dbus-x11 dc desktop-base epiphany-browser epiphany-browser-data galculator gnome-desktop3-data gnome-icon-theme gnome-icon-theme-symbolic gnome-menus gnome-themes-standard gnome-themes-standard-data gpicview gsettings-desktop-schemas gtk2-engines gtk2-engines-clearlookspix gtk2-engines-pixbuf gvfs-backends gvfs-fuse libgnome-menu-3-0 libreoffice libreoffice-base libreoffice-base-drivers libreoffice-gtk libreoffice-sdbc-hsqldb lightdm lightdm-gtk-greeter lp-solve lxappearance lxappearance-obconf lxde-common lxde-icon-theme lxinput lxmenu-data lxpanel lxpanel-data lxrandr lxsession lxtask lxterminal minecraft-pi nuscratch omxplayer openbox penguinspuzzle pi-package pi-package-data pi-package-session pipanel python-minecraftpi python3-minecraftpi raspberrypi-artwork raspberrypi-ui-mods scratch scrot smartsim va-driver-all vdpau-va-driver x11-utils x11-xkb-utils x11-xserver-utils x2x xarchiver xauth xcompmgr xfonts-utils xinit xkb-data xserver-common xserver-xorg xserver-xorg-core xserver-xorg-input-all xserver-xorg-input-evdev xserver-xorg-input-synaptics xserver-xorg-video-fbdev xserver-xorg-video-fbturbo zenity zenity-common sudo apt-get autoremove df -k / Filesystem 1K-blocks Used Available Use% Mounted on /dev/root 6295280 2340092 3612356 40% /
We saved about 1 Gbyte, and the total size of all software is now 2,3 Gbyte. The original installer used 1.1 Gbyte. Giving a total size below 4 Gbyte.
Before continuing clean up some directories in the pi-home folder.
cd /home/pi rm -rf .asoundrc .cache .config .dbus Desktop Documents Downloads .gstreamer-0.10 .local Music Pictures Public python_games Templates .themes Videos .Xauthority .xsession-errors
Cleaning the package listing also saves several Kbytes:
apt-get clean
At this moment we have an Raspbian Operating System which is able to run on a 4 Gbyte SD-card.
4 Gbyte SD Card - Recreating the Installer
It's time to create our own installer. Shutdown the Raspberry Pi, and remove the SD card. Place a second SD-card with the Raspbian image in step 1.
After booting, connect a NTFS-formatted USB-storage (8 Gbyte) and the modified SD-card (using a SD-card reader) to the Raspberry Pi. The following partitions are automatically mounted:
/dev/sda1 7.5G 128K 7.5G 1% /media/pi/DATADISK /dev/sdc5 30M 397K 28M 2% /media/pi/SETTINGS1 /dev/sdc6 63M 20M 44M 31% /media/pi/boot /dev/sdc7 6.1G 2.3G 3.5G 39% /media/pi/root0
The /media/pi/root0 folder contains our modified Operating System. And the /media/pi/boot-folder contains the files needed for booting the new Operating System. We have to compress both folders, to replace the original ones (inside the Noobs installer).
Because we're using an used Linux system, we might need to clear some old log files first:
cd /media/pi/root0 > /var/log/dpkg.log > /var/log/bootstrap.log > /var/log/alternatives.log > /var/log/apt/history.log > /var/log/apt/term.log > /var/log/apt/user.log > /var/log/apt/kern.log > /var/log/alternatives.log > /var/log/auth.log > /var/log/bootstrap.log > /var/log/daemon.log > /var/log/dpkg.log > /var/log/kern.log > /var/log/regen_ssh_keys.log > /var/log/user.log > /var/log/messages
Now check if the following folders are empty (clean shutdown):
- proc
- sys
- dev/pts
The root.tar Linux partition contains all Linux files including all applications/software. Make a tar-archive, and compress this using maximum compression (tar -J uses the value 6)
cd /media/pi/root0 tar -cpf /media/pi/DATADISK/root.tar . xz -9 -e /media/pi/DATADISK/root.tar
Compressing the archive takes a while on a Raspberry Pi. But it saves a lot of space:
-rw-r--r-- 1 pi pi 2170398720 Mar 9 13:43 /media/pi/DATADISK/root.tar -rw-r--r-- 1 pi pi 665949608 Mar 9 13:43 /media/pi/DATADISK/root.tar.xz
The boot.tar partition is a FAT32 partition. This partition contains the files needed for booting the Raspberry Pi:
cd /media/pi/boot tar -cpf /media/pi/DATADISK/boot.tar . xz -9 -e /media/pi/DATADISK/boot.tar
The old and the new size of the tar-archive:
-rw-r--r-- 1 pi pi 20398080 Mar 9 13:33 /media/pi/DATADISK/boot.tar -rw-r--r-- 1 pi pi 11094836 Mar 9 13:31 /media/pi/DATADISK/boot.tar.xz
Unmount the DATADISK (or shutdown the Raspberry Pi), and remove the USB-storage.
Open the Noobs installer with 7zip (just like step 1), and replace both files inside the Raspbian folder.
After replacing the boot.tar.xz and root.tar.xz files the noobs installer can be placed on a 4 Gbyte SD-card. Finally open the partitions.json-file using 7zip:
{ "partitions": [ { "label": "boot", "filesystem_type": "FAT", "partition_size_nominal": 63, "want_maximised": false, "uncompressed_tarball_size": 21 }, { "label": "root", "filesystem_type": "ext4", "partition_size_nominal": 3551, "want_maximised": true, "mkfs_options": "-O ^huge_file", "uncompressed_tarball_size": 3151 } ] }
Modify the values for the root-partition. (I've used the values 2653 and 2253, because we cleared 1 Gbyte). Extract all files on an empty 4Gb SD card. Insert the card in a Raspberry Pi and wait until all files are installed.
1 Gbyte SD Card - the Pi Diet
We ended with a root-file system of 2.3 Gbyte, after removing the entire GUI and some other packages.
Filesystem 1K-blocks Used Available Use% Mounted on /dev/root 6.1G 2.3G 3.5G 39% /
It's time to remove entire software "sections", which are not considered "required" or "important". Else we'll never reach a 1 Gbyte install base.
java Programming python ruby
sudo apt purge bluej dh-python greenfoot idle idle-python2.7 idle-python3.4 idle3 java-common libpython-stdlib libpython2.7-minimal libpython2.7-stdlib libpython3-stdlib libpython3.4-minimal libpython3.4-stdlib libreoffice libservlet2.5-java libtcltk-ruby1.9.1 lxkeymap pypy-setuptools pypy-upstream pypy-upstream-dev python python-apt-common python-cairo python-chardet python-colorama python-dbus python-dbus-dev python-distlib python-gi python-gpiozero python-gtk2 python-html5lib python-minimal python-ndg-httpsclient python-numpy python-openssl python-picamera python-pifacecommon python-pifacedigitalio python-pil python-pip python-pkg-resources python-pyasn1 python-pygame python-requests python-rpi.gpio python-rtimulib python-sense-hat python-serial python-setuptools python-six python-spidev python-support python-talloc python-tk python-urllib3 python-wheel python-xklavier python2.7 python2.7-minimal python3 python3-apt python3-chardet python3-colorama python3-debian python3-dev python3-distlib python3-gpiozero python3-html5lib python3-minimal python3-numpy python3-pgzero python3-picamera python3-pifacecommon python3-pifacedigital-scratch-handler python3-pifacedigitalio python3-pil python3-pip python3-pkg-resources python3-pygame python3-requests python3-rpi.gpio python3-rtimulib python3-sense-hat python3-serial python3-setuptools python3-six python3-spidev python3-tk python3-uno python3-urllib3 python3-wheel python3.4 python3.4-dev python3.4-minimal ri1.9.1 ruby ruby1.9.1 ruby1.9.1-dev ruby1.9.1-examples ruby1.9.1-full ruby1.9.3 ruby2.1 rubygems-integration sudo apt-get autoremove
This will free 426 and 161 MByte.
Filesystem Size Used Avail Use% Mounted on /dev/root 6.1G 1.5G 4.3G 26% /
debug devel fonts sound text vcs xfce
sudo apt purge alsa-base alsa-utils aspell aspell-en binutils build-essential debconf-utils desktop-file-utils dictionaries-common esound-common fontconfig fontconfig-config fonts-dejavu fonts-dejavu-core fonts-dejavu-extra fonts-freefont-ttf fonts-opensymbol fonts-roboto fonts-sil-gentium-basic freepats g++ g++-4.9 gcc gcc-4.9 gdb gdbserver git git-core gsfonts gsfonts-x11 jackd jackd2 libc6-dbg libexttextcat-data libreoffice libruby1.9.1-dbg libscsynth1 libvisual-0.4-plugins libxfce4util-bin libxfce4util-common libxfce4util6 linux-libc-dev make patch pkg-config qjackctl sgml-base squeak-plugins-scratch supercollider supercollider-common supercollider-ide supercollider-language supercollider-server supercollider-supernova timidity xfce-keyboard-shortcuts xfconf xfonts-100dpi xfonts-encodings xml-core xpdf sudo apt-get autoremove
This will free 350 and 152 MByte.
Filesystem Size Used Avail Use% Mounted on /dev/root 6.1G 972M 4.8G 17% /
doc editors interpreters introspection metapackages mail oldlibs web
sudo apt purge claws-mail cpp cpp-4.9 curl debian-reference-common debian-reference-en dillo ed emacsen-common gir1.2-atk-1.0 gir1.2-freedesktop gir1.2-gdkpixbuf-2.0 gir1.2-glib-2.0 gir1.2-gmenu-3.0 gir1.2-gtk-3.0 gir1.2-pango-1.0 git-man javascript-common leafpad libhsqldb1.8.0-java libjs-jquery libjs-prettify libluajit-5.1-common libpango1.0-0 libpangox-1.0-0 libreoffice libreoffice-base-core libreoffice-calc libreoffice-common libreoffice-core libreoffice-draw libreoffice-impress libreoffice-java-common libreoffice-math libreoffice-style-galaxy libreoffice-writer lua5.1 luajit lxde lxde-core manpages-dev netsurf-common netsurf-gtk nodejs nodejs-legacy nodered pypy-upstream-doc python-gobject python-gobject-2 sonic-pi squeak-vm tcl8.5 tk8.5 sudo apt-get autoremove
This will free 107 MByte.
Filesystem Size Used Avail Use% Mounted on /dev/root 6.4G 853M 5.2G 14% /
Almost there, remove some large libraries
sudo apt purge gstreamer0.10-alsa gstreamer0.10-plugins-base gstreamer1.0-alsa gstreamer1.0-libav gstreamer1.0-plugins-bad gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-x gvfs gvfs-common gvfs-daemons gvfs-libs libaspell15 libavcodec56 libavformat56 libavresample2 libavutil54 libcairo-gobject2 libcairo2 libclucene-contribs1 libclucene-core1 libdirectfb-1.2-9 libflite1 libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa libgles1-mesa libgles2-mesa libgtk-3-0 libgtk-3-bin libgtk-3-common libgtk2.0-0 libgtk2.0-bin libgtk2.0-common libmwaw-0.3-3 libopencv-calib3d2.4 libopencv-contrib2.4 libopencv-core2.4 libopencv-features2d2.4 libopencv-flann2.4 libopencv-highgui2.4 libopencv-imgproc2.4 libopencv-legacy2.4 libopencv-ml2.4 libopencv-objdetect2.4 libopencv-video2.4 libqt4-dbus sudo libqt4-network libqt4-xml libqt4-xmlpatterns libqtcore4 libqtdbus4 libqtgui4 libreoffice libruby1.9.1 libruby2.1 libwebkitgtk-3.0-0 libwebkitgtk-3.0-common sudo apt-get autoremove
Now we're at 788 Mbyte:
Filesystem Size Used Avail Use% Mounted on /dev/root 6.4G 788M 5.3G 13% /
Clean the APT-cache saves a few Mbyte.
sudo apt-get clean
Finally, the root-folder is below 700 Mbyte:
Filesystem Size Used Avail Use% Mounted on /dev/root 6.4G 685M 5.4G 12% /
Unfortunately it is not possible to install this operating system, with Noobs, using a 1 Gbyte SD-card. But the next step shows how to install this OS on a 1 GByte SD-card.
1 Gbyte SD Card - Juggling With Partitions
Shutdown, and boot with an other SD-card. Attach the USB storage and the SD-card from the previous step.
Check if the filesystems are mounted (df -h):
/dev/sdc7 6.4G 685M 5.4G 12% /media/pi/root0 /dev/sdc6 63M 20M 44M 31% /media/pi/boot /dev/sdc5 30M 397K 28M 2% /media/pi/SETTINGS /dev/sda1 7.5G 1.5G 6.1G 20% /media/pi/DATADISK
The following commands must be started as root-user:
sudo su -
Empty the logfiles:
cd /media/pi/root0 > /var/log/dpkg.log > /var/log/bootstrap.log > /var/log/alternatives.log > /var/log/apt/history.log > /var/log/apt/term.log > /var/log/apt/user.log > /var/log/apt/kern.log > /var/log/alternatives.log > /var/log/auth.log > /var/log/bootstrap.log > /var/log/daemon.log > /var/log/dpkg.log > /var/log/kern.log > /var/log/regen_ssh_keys.log > /var/log/user.log > /var/log/messages
Backup all Linux filesystems:
tar -cpf /media/pi/DATADISK/root1G.tar . cd /media/pi/boot tar -cpf /media/pi/DATADISK/boot1G.tar . cd /media/pi/SETTINGS tar -cpf /media/pi/DATADISK/settings1G.tar . cd /media/pi/DATADISK
Don't forget the first recovery-partition. Remove the recovery directory for Raspbian.
mkdir /media/pi/dos mount /dev/sdc1 /media/pi/dos cd /media/pi/dos tar -cpf /media/pi/DATADISK/dos1G.tar . cd os rm -rf Raspbian cd .. tar -cpf /media/pi/DATADISK/dos1Gminimal.tar .
There is no need to compress the files, we are not going to build an installer.
-rw-r--r-- 1 pi pi 20398080 Mar 9 22:25 boot1G.tar -rw-r--r-- 1 pi pi 29184000 Mar 10 06:48 dos1Gminimal.tar -rw-r--r-- 1 pi pi 658565120 Mar 9 22:24 root1G.tar -rw-r--r-- 1 pi pi 10240 Mar 9 22:25 settings1G.tar
Take a look at the partitions on the 8 Gbyte SD card. These must be made on the 1 Gbyte SD-card.
Disk /dev/sdc: 7.4 GiB, 7948206080 bytes, 15523840 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x00031f85 Device Boot Start End Sectors Size Id Type /dev/sdc1 8192 1580078 1571887 767.5M e W95 FAT16 (LBA) /dev/sdc2 1580079 15523839 13943761 6.7G 5 Extended /dev/sdc5 1581056 1646589 65534 32M 83 Linux /dev/sdc6 1646592 1775615 129024 63M c W95 FAT32 (LBA) /dev/sdc7 1777664 15523839 13746176 6.6G 83 Linux
Remove the 8 Gbyte SD card and insert a 1 Gbyte SD card. Create the following partitions (fdisk /dev/sdb):
Disk /dev/sdb: 968.8 MiB, 1015808000 bytes, 1984000 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x00000000 Device Boot Start End Sectors Size Id Type /dev/sdb1 8192 137215 129024 63M e W95 FAT16 (LBA) /dev/sdb2 137217 1983999 1846783 901.8M 5 Extended /dev/sdb5 139265 204799 65535 32M 83 Linux /dev/sdb6 206848 335871 129024 63M e W95 FAT16 (LBA) /dev/sdb7 337920 1983999 1646080 803.8M 83 Linux
Listing with all fdisk commands used:
d (delete all partitions) n p 1 8192 +129024 t e n e 2 137217 13833999 (=default maximum) n l 139265 +65534 t 5 83 n l 206848 (=default) +129024 t 6 e n l 337920 (=default) 13833999 (=default maximum) p w
Now create filesystems and mount them:
mkfs.msdos /dev/sdb1 mkfs.ext4 /dev/sdb5 mkfs.msdos /dev/sdb6 mkfs.ext4 /dev/sdb7 mkdir -p /media/pi/dos1G mkdir -p /media/pi/settings1G mkdir -p /media/pi/boot1G mkdir -p /media/pi/root1G mount /dev/sdb1 /media/pi/dos1G mount /dev/sdb5 /media/pi/settings1G mount /dev/sdb6 /media/pi/boot1G mount /dev/sdb7 /media/pi/root1G
It's time to restore the files:
cd /media/pi/dos1G tar -xpf /media/pi/DATADISK/dos1Gminimal.tar . cd /media/pi/settings1G tar -xpf /media/pi/DATADISK/settings1G.tar . cd /media/pi/boot1G tar -xpf /media/pi/DATADISK/boot1G.tar . (ignore change owner errors) cd /media/pi/root1G tar -xpf /media/pi/DATADISK/root1G.tar .
With all files restored it's time to remove the SD card and use it as boot device.
Although it was very technical. I hope you liked my Instructable.