{"id":14424,"date":"2026-02-25T11:36:48","date_gmt":"2026-02-25T02:36:48","guid":{"rendered":"https:\/\/pilink.jp\/?p=14424"},"modified":"2026-02-25T11:36:48","modified_gmt":"2026-02-25T02:36:48","slug":"ubuntu-partition-overlay","status":"publish","type":"post","link":"https:\/\/pilink.jp\/en\/ubuntu-partition-overlay\/","title":{"rendered":"OverlayFS for Data Persistence, Storage Longevity, and Power-Loss Protection"},"content":{"rendered":"\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:25%\"><\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:50%\">\n<p>A typical Raspberry Pi uses a microSD card to write the operating system, which is a convenient but easily damaged storage medium. eMMC is used in industrial applications such as CM5 because it is more robust than a microSD card. One of the reasons eMMC is used in industrial applications such as CM5 is because it is a more robust storage medium than microSD cards.<\/p>\n\n\n\n<p>By making the OS part of a microSD card or other storage media read-only, the amount of writing to the storage media can be greatly reduced, thereby extending the life of the storage media. In addition, it increases the probability of preventing damage to the OS section in the event of a sudden power failure.<\/p>\n\n\n\n<p>Raspberry Pi has a method called &#8220;Overlay File System&#8221; that can be easily configured from raspi-config. It has been available for configuration from <code>raspi-config<\/code>for quite some time now.<\/p>\n\n\n\n<p>OverlayFS is a mechanism that treats the system (OS) as read-only (RO) and makes the entire system look like a single file system by copying and storing only files where writing occurs to another writable area (upper layer).<\/p>\n\n\n\n<p>This writable area is expanded in memory as tmpfs and will disappear when the power is turned back on.<br>At first glance, the system can be treated as if it has been modified &amp; saved, but the system part is read-only and has not been modified.<br>So, if you turn off the power, nothing is lost.<br>This means that the system reverts back to the point at which it was made read-only.<\/p>\n\n\n\n<p>We would like to retain and use at least a minimum number of files after the reboot.<br>While using Overlayfs, this is achieved by evacuating data with a symbolic link to a separate partition.<br>In this case, we focused only on network-related changes and saving the home folder.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Test environment for this test<\/h2>\n\n\n\n<p>The environment we tested this time is as follows.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>32 GB microSD card (64 GB or more recommended)<\/li>\n\n\n\n<li>Ubuntu Desktop 25.10 (64-bit)<\/li>\n\n\n\n<li>Split \/data into a separate partition<\/li>\n\n\n\n<li>Save to \/data using a symbolic link (symlink)<\/li>\n\n\n\n<li>Network uses NetworkManager<\/li>\n\n\n\n<li>OverlayFS is configured manually by editing cmdline.txt<\/li>\n\n\n\n<li>Tests were performed on an actual Pi 5 machine (this method is equally applicable to PL-R5 with CM5)<\/li>\n<\/ul>\n\n\n\n<p>We are trying to split the microSD card with 10 GB of \/data space.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"700\" src=\"https:\/\/pilink.jp\/wp-content\/uploads\/2026\/02\/utm-ubuntu2510-disks-1-1024x700.webp\" alt=\"\" class=\"wp-image-14336\" srcset=\"https:\/\/pilink.jp\/wp-content\/uploads\/2026\/02\/utm-ubuntu2510-disks-1-1024x700.webp 1024w, https:\/\/pilink.jp\/wp-content\/uploads\/2026\/02\/utm-ubuntu2510-disks-1-300x205.webp 300w, https:\/\/pilink.jp\/wp-content\/uploads\/2026\/02\/utm-ubuntu2510-disks-1-768x525.webp 768w, https:\/\/pilink.jp\/wp-content\/uploads\/2026\/02\/utm-ubuntu2510-disks-1-370x253.webp 370w, https:\/\/pilink.jp\/wp-content\/uploads\/2026\/02\/utm-ubuntu2510-disks-1-540x369.webp 540w, https:\/\/pilink.jp\/wp-content\/uploads\/2026\/02\/utm-ubuntu2510-disks-1-600x410.webp 600w, https:\/\/pilink.jp\/wp-content\/uploads\/2026\/02\/utm-ubuntu2510-disks-1.webp 1392w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The method of partitioning a partition is the same as the method of partitioning a partition in which the <a href=\"https:\/\/pilink.jp\/en\/r5-partitioning\/\" target=\"_blank\" rel=\"noreferrer noopener\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">How to split the partition where the OS is installed<\/mark><\/a> for details.<\/p>\n\n\n\n<p>After booting Ubuntu, which has been partitioned for evacuation, complete the update.<br>In this state, we will proceed with the next steps.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Configuration Flow<\/h3>\n\n\n\n<p>The general flow of the setup is as follows<\/p>\n\n\n\n<p>1. Write Ubuntu <br>2. Boot on the actual machine and complete the initial setup and updates. <br>3. Read the microSD card once on another machine and partition it (about 10GB for saving data) <br>4. Preparation work before Overlayfs <br>5. Enable Overlayfs<\/p>\n\n\n\n<p>Now that we have finished up to 3, we continue with preparations for the final Overlayfs.<br>Finally, with Overlayfs enabled, check the network settings for changes, etc.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Mount another partition<\/h2>\n\n\n\n<p>We will work on the split partition after it is mounted. <br>lsblk checks that the split partition is not mounted yet. ( <code>mmcblk0p3<\/code>)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS\nmmcblk0     179:0    0  29.7G  0 disk \n\u251c\u2500mmcblk0p1 179:1    0   512M  0 part \/boot\/firmware\n\u251c\u2500mmcblk0p2 179:2    0  19.9G  0 part \/\n\u2514\u2500mmcblk0p3 179:3    0   9.3G  0 part <\/code><\/pre>\n\n\n\n<p>Create \/data under root and mount mmcblk0p3 there.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mkdir -p \/data\nsudo mount \/dev\/mmcblk0p3 \/data<\/code><\/pre>\n\n\n\n<p><code>\u2514\u2500mmcblk0p3 179:3 0 9.3G 0 part \/data<\/code>It is OK if the<\/p>\n\n\n\n<p>To have it automatically mounted at startup, append to fstab. blkid or the next coman to find out the UUID.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo blkid -s UUID -o value \/dev\/mmcblk0p3<\/code><\/pre>\n\n\n\n<p>or<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>lsblk -f \/dev\/mmcblk0<\/code><\/pre>\n\n\n\n<p>Copy the UUID and then append it to fstab at <code>sudo nano \/etc\/fstab<\/code>. (UUID should be read as.)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>UUID=f3afb6b2-a959-4c4b-bdb6-3c38a0fe33be \/data ext4 defaults 0 2<\/code><\/pre>\n\n\n\n<p>Update and remount and check the MOUNT status.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl daemon-reload\nsudo mount -a\nmount | grep \/data<\/code><\/pre>\n\n\n\n<p><code>\/dev\/mmcblk0p3 on \/data type ext4 (rw,relatime,errors=remount-ro)<\/code>is displayed, it is OK.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Role of the \/data Partition<\/h2>\n\n\n\n<p>Eventually, \/data will be made writable (rw), so the network settings will be moved to this \/data area.<br>The \/home directory is also saved in the \/data area.<\/p>\n\n\n\n<p>The rootfs of the system should be Overlayfs, which is read-only (ro) at the end.<\/p>\n\n\n\n<p>At this time, there are two general methods of saving data.<br>There are two methods: the symbolic link (symlink) method and the bind mount method.<\/p>\n\n\n\n<p>This time it is a symbolic link.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Overlayfs + symbolic links<\/h2>\n\n\n\n<p>The workflow for symbolic links is as follows<\/p>\n\n\n\n<p>1. Create a directory as a limbic link destination and make it a mount point. <br>2. Copy the original files. <br>3. Create a symbolic link. <br>4. Confirm the symbolic link.<\/p>\n\n\n\n<p>After the symbolic links are properly set up, we will convert them to Overlayfs.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. create directories for mount points<\/h3>\n\n\n\n<p>Prepare only an empty directory before executing the symbolic link. Mount point.<\/p>\n\n\n\n<p>In this case, the following five are to be symbolically linked.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\/etc\/NetworkManager<\/li>\n\n\n\n<li>\/var\/lib\/NetworkManager<\/li>\n\n\n\n<li>\/home<\/li>\n\n\n\n<li>\/etc\/hostname<\/li>\n\n\n\n<li>\/etc\/hosts<\/li>\n\n\n\n<li>Create a directory for mounting in \/etc\/netplan \/data.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mkdir -p \/data\/etc\/NetworkManager\nsudo mkdir -p \/data\/var\/lib\/NetworkManager\nsudo mkdir -p \/data\/home\nsudo mkdir -p \/data\/etc\/netplan<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. copying files<\/h3>\n\n\n\n<p>Copy the original data to the \/data side.<br>The directory designation in the command should include a trailing slash because, in this case, we want to copy only the contents into a directory that already exists.<br>If you make a mistake in this area, you will get stuck with nested directories.<\/p>\n\n\n\n<p>-Trailing slash for &#8220;include contents&#8221; <br>-None for &#8220;create an entire folder&#8221;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Copy NetworkManager configuration\nsudo rsync -a \/etc\/NetworkManager\/ \/data\/etc\/NetworkManager\/\nsudo rsync -a \/var\/lib\/NetworkManager\/ \/data\/var\/lib\/NetworkManager\/\n\n# Copy netplan configuration\nsudo rsync -a \/etc\/netplan\/ \/data\/etc\/netplan\/\n\n# Copy the home directory\nsudo rsync -a \/home\/ \/data\/home\/\n\n# Copy configuration files\nsudo cp -a \/etc\/hosts \/data\/etc\/hosts\nsudo cp -a \/etc\/hostname \/data\/etc\/hostname<\/code><\/pre>\n\n\n\n<p>hosts and hostname are one file. So the <code>cp -a<\/code>command is fine. <br>*netplan\/ has Wi-Fi connection information.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. creating symbolic links<\/h3>\n\n\n\n<p>Delete the original group of files before creating a symbolic link.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo rm -rf \/etc\/NetworkManager\nsudo ln -s \/data\/etc\/NetworkManager \/etc\/NetworkManager\n\nsudo rm -rf \/var\/lib\/NetworkManager\nsudo ln -s \/data\/var\/lib\/NetworkManager \/var\/lib\/NetworkManager\n\nsudo rm -rf \/etc\/netplan\nsudo ln -s \/data\/etc\/netplan \/etc\/netplan\n\n# Move to the root directory before modifying \/home\ncd \/\nsudo rm -rf \/home\nsudo ln -s \/data\/home \/home\n\nsudo ln -sf \/data\/etc\/hosts \/etc\/hosts\nsudo ln -sf \/data\/etc\/hostname \/etc\/hostname<\/code><\/pre>\n\n\n\n<p>We will check it once here.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -l \/etc\/NetworkManager\nls -l \/var\/lib\/NetworkManager\nls -l \/etc\/netplan\nls -l \/home\nls -l \/etc\/hostname\nls -l \/etc\/hosts<\/code><\/pre>\n\n\n\n<p>For example, the display should look something like this<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>lrwxrwxrwx 1 root root 24 Feb  7 21:08 \/etc\/NetworkManager -&gt; \/data\/etc\/NetworkManager\nlrwxrwxrwx 1 root root 28 Feb  7 21:09 \/var\/lib\/NetworkManager -&gt; \/data\/var\/lib\/NetworkManager\nlrwxrwxrwx 1 root root 17 Feb  9 09:40 \/etc\/netplan -&gt; \/data\/etc\/netplan\nlrwxrwxrwx 1 root root 10 Feb  7 21:09 \/home -&gt; \/data\/home\nlrwxrwxrwx 1 root root 18 Feb  7 21:10 \/etc\/hostname -&gt; \/data\/etc\/hostname\nlrwxrwxrwx 1 root root 15 Feb  7 21:10 \/etc\/hosts -&gt; \/data\/etc\/hosts<\/code><\/pre>\n\n\n\n<p>Check to see if NetworkManager and others are using the \/data side with symbolic links.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>realpath \/etc\/NetworkManager\nrealpath \/etc\/NetworkManager\nrealpath \/var\/lib\/NetworkManager<\/code><\/pre>\n\n\n\n<p>As a result, it is OK if the realpath command also shows the path on the \/data side.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/data\/etc\/NetworkManager\n\/data\/var\/lib\/NetworkManager<\/code><\/pre>\n\n\n\n<p>The mounted \/data partition will eventually look like this.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"1024\" src=\"https:\/\/pilink.jp\/wp-content\/uploads\/2026\/02\/tree-data-ubuntu-710x1024.webp\" alt=\"\" class=\"wp-image-14340\" srcset=\"https:\/\/pilink.jp\/wp-content\/uploads\/2026\/02\/tree-data-ubuntu-710x1024.webp 710w, https:\/\/pilink.jp\/wp-content\/uploads\/2026\/02\/tree-data-ubuntu-208x300.webp 208w, https:\/\/pilink.jp\/wp-content\/uploads\/2026\/02\/tree-data-ubuntu-768x1108.webp 768w, https:\/\/pilink.jp\/wp-content\/uploads\/2026\/02\/tree-data-ubuntu-370x534.webp 370w, https:\/\/pilink.jp\/wp-content\/uploads\/2026\/02\/tree-data-ubuntu-465x670.webp 465w, https:\/\/pilink.jp\/wp-content\/uploads\/2026\/02\/tree-data-ubuntu-600x865.webp 600w, https:\/\/pilink.jp\/wp-content\/uploads\/2026\/02\/tree-data-ubuntu.webp 893w\" sizes=\"auto, (max-width: 710px) 100vw, 710px\" \/><\/figure>\n\n\n\n<p>The copy is ready on the \/data side, which is writable.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. install and update Overlayfs<\/h3>\n\n\n\n<p>At this point, we are ready to go.<br>Install overlayroot and update initramfs.<\/p>\n\n\n\n<p>1. install Overlayfs (overlayroot) <br>2. add to cmdline.txt <br>3. change network settings with Overlayfs and check if it is permanent<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update\nsudo apt install overlayroot\nsudo update-initramfs -u\nsudo reboot<\/code><\/pre>\n\n\n\n<p>The initramfs will display something like this when the update is complete.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>update-initramfs: Generating \/boot\/initrd.img-6.17.0-1007-raspi\nUsing DTB: bcm2712-rpi-5-b.dtb\nInstalling \/lib\/firmware\/6.17.0-1007-raspi\/device-tree\/broadcom\/bcm2712-rpi-5-b.dtb into \/boot\/dtbs\/6.17.0-1007-raspi\/.\/bcm2712-rpi-5-b.dtb\nTaking backup of bcm2712-rpi-5-b.dtb.\nInstalling new bcm2712-rpi-5-b.dtb.\nflash-kernel: installing version 6.17.0-1007-raspi\nCopying kernel assets to \/boot\/firmware\/new\/\nCopying boot firmware to \/boot\/firmware\/new\/\nCopying device trees to \/boot\/firmware\/new\/\nCopying device tree overlays to \/boot\/firmware\/new\/overlays\/\nPlease be aware next reboot will boot twice<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">5. Add to cmdline.txt<\/h3>\n\n\n\n<p>When we return from the reboot, we want to keep only \/data as rw, so we add it with an option to exclude another block.<br>The path to cmdline.txt differs from the Raspberry Pi OS.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nano \/boot\/firmware\/current\/cmdline.txt<\/code><\/pre>\n\n\n\n<p>Append to the beginning of cmdline.txt. <br>Note: cmdline.txt must be written on a single line. No line breaks. Space between items.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>overlayroot=tmpfs:recurse=0<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>overlayroot=tmpfs:recurse=0 zswap.enabled=1 zswap.compressor=zstd multipath=off dwc_otg.lpm_enable=0 console=tty1 root=LABEL=writable rootfstype=ext4 panic=10 rootwait fixrtc quiet splash<\/code><\/pre>\n\n\n\n<p>After writing, reboot.<\/p>\n\n\n\n<p>This completes the entire setup.<br>Reboot to see if only bootfs is now read-only (ro).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Check read-only and writable.<\/h2>\n\n\n\n<p>After rebooting, make sure that Overlayfs is properly enabled on the rootfs side.<br>Conversely, \/data is also checked for writability.<\/p>\n\n\n\n<p>First of all, the result of lsblk is that rootfs is now properly overlayfs. (\/media\/root-ro) <br>\/data is rw as it is.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mmcblk0     179:0    0  29.7G  0 disk \n\u251c\u2500mmcblk0p1 179:1    0   512M  0 part \/boot\/firmware\n\u251c\u2500mmcblk0p2 179:2    0  19.9G  0 part \/media\/root-ro\n\u2514\u2500mmcblk0p3 179:3    0   9.3G  0 part \/data<\/code><\/pre>\n\n\n\n<p>When you connect to SSH in a terminal, you can often see it because it is displayed when you connect. overlay is indicated.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tmpfs-root \/media\/root-rw tmpfs rw,relatime,inode64 0 0\noverlayroot \/ overlay rw,relatime,lowerdir=\/media\/root-ro,upperdir=\/media\/root-rw\/overlay,workdir=\/media\/root-rw\/overlay-workdir\/_,uuid=on,nouserxattr 0 0\n\/dev\/mmcblk0p2 \/media\/root-ro ext4 ro,relatime 0 0<\/code><\/pre>\n\n\n\n<p>We will check with them individually.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mount | grep \" on \/ \"\nmount | grep \/data\nls -l \/etc | grep NetworkManager\nls -l \/ | grep \/home<\/code><\/pre>\n\n\n\n<p>Expected Results:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mount | grep \" on \/ \"\noverlayroot on \/ type overlay (rw,relatime,lowerdir=\/media\/root-ro,upperdir=\/media\/root-rw\/overlay,workdir=\/media\/root-rw\/overlay-workdir\/_,uuid=on,nouserxattr)\n\nmount | grep \/data\n\/dev\/mmcblk0p3 on \/data type ext4 (rw,relatime)\n\nls -l \/etc | grep NetworkManager\nlrwxrwxrwx 1 root                 root                    24 Feb  7 21:08 NetworkManager -&gt; \/data\/etc\/NetworkManager\n\nls -l \/ | grep \/home\nlrwxrwxrwx   1 root    root            10 Feb  7 21:09 home -&gt; \/data\/home<\/code><\/pre>\n\n\n\n<p>Did you see the expected results?\u3000Overlayfs is now complete.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">I&#8217;ll do a final test.<\/h2>\n\n\n\n<p>I&#8217;ll test a couple of things.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Change Wi-Fi destination<\/h3>\n\n\n\n<p>We will change the Wi-Fi destination even in the Overlayfs state and verify if this is still reflected after the reboot.<\/p>\n\n\n\n<p>Wi-Fi connection information exists in \/etc\/netplan in yaml format.<br>Since this is also a symbolic link, the \/data side is rewritten and the original \/etc should also refer to it.<\/p>\n\n\n\n<p>There is one yaml named 90-NM-~ before the change.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo ls -l \/data\/etc\/netplan\/\n\n-rw------- 1 root root 157 Oct  7 11:52 50-cloud-init.yaml\n-rw------- 1 root root 706 Oct  7 11:55 90-NM-32f4a827-cc10-4a0e-aae9-64158b7a33e7.yaml<\/code><\/pre>\n\n\n\n<p>I changed from 5g Wi-Fi to 2g Wi-Fi using the GUI controls on the desktop. <br>As a result, I have one more. Of course, it is connected to Wi-Fi.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>-rw------- 1 root root 157 Oct  7 11:52 50-cloud-init.yaml\n-rw------- 1 root root 706 Feb  9 09:54 90-NM-201e82b9-74eb-4783-a9db-48e3a5d7f14e.yaml\n-rw------- 1 root root 706 Oct  7 11:55 90-NM-32f4a827-cc10-4a0e-aae9-64158b7a33e7.yaml<\/code><\/pre>\n\n\n\n<p>If the two are maintained in the same way after rebooting in this state, it is OK. They were indeed maintained.<\/p>\n\n\n\n<p>Now we can change the Wi-Fi connection information even in Overlayfs state.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">If the file is gone after rebooting, OK.<\/h3>\n\n\n\n<p>Finally, verify the writing of the file with Overlayfs in place.<br>Let&#8217;s create a test-file directly under root.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo touch \/test_file<\/code><\/pre>\n\n\n\n<p>Since rootfs is an overlayfs, it behaves as if it has been modified in memory. At this point, you can write to it. <br>But this is just written in tmpfs, so it will be gone after reboot.<\/p>\n\n\n\n<p>If the file itself disappears and is gone after reboot, then Overlayfs is working.<\/p>\n\n\n\n<p>Reboot and check with <code>ls -l \/test_file<\/code>etc. <br>It should be gone.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">To undo overlayfs<\/h2>\n\n\n\n<p>Thus, in the Overlayfs state, rebooting will return the system to the point at which it was made Overlayfs.<br>This is because the original rootfs area is read-only (ro) and behaves as (tmpfs) expanded in memory on its upper layer.<br>The tmpfs will disappear after a reboot.<\/p>\n\n\n\n<p>To return rootfs read-only to normal read\/write, delete <code>overlayroot=tmpfs:recurse=0<\/code>appended to cmdline.txt. <br>Then reboot and it will be back to normal.<\/p>\n\n\n\n<p>If you want to convert to Overlayfs again, you can simply add the same information to cmdline.txt.<br>This can be done because bootfs remains writable.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Minimal data persistence<\/h2>\n\n\n\n<p>This time, in an Overlayfs environment, we fled some network-related and \/home directories to a separate partition.<br>The changes were properly maintained, so the data was successfully persisted.<\/p>\n\n\n\n<p>Symbolic links work fine for some files.<\/p>\n\n\n\n<p>However, it does not make much sense to persist a whole group of files that are often accessed. This is especially true in this case because the partitions are just cut off in the same storage media. <br>It is no good if the rootfs is made read-only with Overlayfs, but the same media is accessed more and more.<\/p>\n\n\n\n<p>The purpose of exporting configuration data or saving files generated even in Overlayfs state would be desirable.<br>I would like to pinpoint the setting as much as possible.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Supplement 1<\/h2>\n\n\n\n<p>Actually, with Raspberry Pi OS I couldn&#8217;t get this means, I thought it was a problem with Trixie, but apparently it was possible until bullseye, and the same procedure can&#8217;t be done from bookworm.<\/p>\n\n\n\n<p>As far as I have been able to find out and verify, neither symlinks nor bindmounts have produced the expected results; it appears that they are being forced deep within the Raspberry Pi OS.<\/p>\n\n\n\n<p>In particular, the bind mount has been changed to a block-by-block mount and has been downgraded to a simple mount. <br>I am not a Raspberry Pi OS developer in this area, so I do not know why. It may be a way to prevent beginners from accidentally destroying the system.<\/p>\n\n\n\n<p>Ubuntu was fine as far as I tested.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Supplement 2<\/h2>\n\n\n\n<p>Changing the hostname in the overlayfs state was possible as far as I tried with the hostnamectl command, but the SSH connection remains an issue and the connection can only be made with the hostname before the change. After connecting, the hostname is also changed, only SSH seems to be picking up the pretty hostname. It seems that it would be better to change the hostname after disabling overlayfs.<\/p>\n\n\n\n<p>Note that the SSH server is not initially installed on Ubuntu. It must be installed and activated with the following command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install openssh-server\nsudo systemctl enable ssh\nsudo systemctl start ssh<\/code><\/pre>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:25%\"><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-medium is-resized\"><a href=\"https:\/\/raspida.com\/\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"300\" src=\"https:\/\/pilink.jp\/wp-content\/uploads\/2024\/09\/raspida-red-profile-300x300.png\" alt=\"\" class=\"wp-image-6246\" style=\"width:150px\" srcset=\"https:\/\/pilink.jp\/wp-content\/uploads\/2024\/09\/raspida-red-profile-300x300.png 300w, https:\/\/pilink.jp\/wp-content\/uploads\/2024\/09\/raspida-red-profile-600x600.png 600w, https:\/\/pilink.jp\/wp-content\/uploads\/2024\/09\/raspida-red-profile-100x100.png 100w, https:\/\/pilink.jp\/wp-content\/uploads\/2024\/09\/raspida-red-profile-150x150.png 150w, https:\/\/pilink.jp\/wp-content\/uploads\/2024\/09\/raspida-red-profile-370x370.png 370w, https:\/\/pilink.jp\/wp-content\/uploads\/2024\/09\/raspida-red-profile-540x540.png 540w, https:\/\/pilink.jp\/wp-content\/uploads\/2024\/09\/raspida-red-profile.png 759w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/figure>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:70%\">\n<p>Article contributed by Raspida<\/p>\n\n\n\n<p>Raspberry Pi information site that even non-engineers can enjoy using <a href=\"https:\/\/raspida.com\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong> raspida.com<\/strong><\/a> a Raspberry Pi information site that even non-engineers can enjoy and handle. He also contributes <a href=\"https:\/\/pilink.jp\/en\/technical-blog\/\" data-type=\"page\" data-id=\"4315\">technical blog articles<\/a> to the PiLink site on the Raspberry Pi for industrial use.<\/p>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:25%\"><\/div>\n<\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>By making the OS part read-only, writing to storage is greatly reduced, extending the life of the storage media. In addition, it increases the probability of preventing damage to the OS part in the event of a sudden power failure.<\/p>\n","protected":false},"author":6,"featured_media":14334,"comment_status":"closed","ping_status":"closed","sticky":true,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[87],"tags":[249,256,402],"class_list":["post-14424","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technical","tag-cm5-en","tag-image-en","tag-ubuntu-en"],"acf":[],"_links":{"self":[{"href":"https:\/\/pilink.jp\/en\/wp-json\/wp\/v2\/posts\/14424","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pilink.jp\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pilink.jp\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pilink.jp\/en\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/pilink.jp\/en\/wp-json\/wp\/v2\/comments?post=14424"}],"version-history":[{"count":4,"href":"https:\/\/pilink.jp\/en\/wp-json\/wp\/v2\/posts\/14424\/revisions"}],"predecessor-version":[{"id":14430,"href":"https:\/\/pilink.jp\/en\/wp-json\/wp\/v2\/posts\/14424\/revisions\/14430"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pilink.jp\/en\/wp-json\/wp\/v2\/media\/14334"}],"wp:attachment":[{"href":"https:\/\/pilink.jp\/en\/wp-json\/wp\/v2\/media?parent=14424"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pilink.jp\/en\/wp-json\/wp\/v2\/categories?post=14424"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pilink.jp\/en\/wp-json\/wp\/v2\/tags?post=14424"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}