Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It don't understand what's the big deal about it. To make the system immutable, isn't it enough during boot to just

    1. create a ram-backed filesystem
    2. copy `/`s contents to that new filesystem
    3. Optional: Unmount `/`
    4. Mount the ram-backed filesystem on `/`
?

You can easily do that from the initramfs during booting. I'm applying this patch to the roofs created by debootstrapping Debian Buster. You can use the system just fine and make changes as you please. But when you shut it down, it's all lost. Everything I want to keep (like the permanent storage this system makes available over sshfs, NFS) is on seperate disks anyway. Sure, you need enough RAM to hold the entire rootfs (1.2G in case of Debian Buster) and it increases boot time a bit. For server applications, I don't care at all.

    --- a/usr/share/initramfs-tools/scripts/local   2021-11-05 12:50:23.541088057 +0100
    +++ b/usr/share/initramfs-tools/scripts/local   2021-11-05 13:02:14.483203576 +0100
    @@ -180,9 +180,20 @@
     
        # Mount root
        # shellcheck disable=SC2086
    -   if ! mount ${roflag} ${FSTYPE:+-t "${FSTYPE}"} ${ROOTFLAGS} "${ROOT}" "${rootmnt?}"; then
    -       panic "Failed to mount ${ROOT} as root file system."
    -   fi
    +   #if ! mount ${roflag} ${FSTYPE:+-t "${FSTYPE}"} ${ROOTFLAGS} "${ROOT}" "${rootmnt?}"; then
    +   #   panic "Failed to mount ${ROOT} as root file system."
    +   #fi
    +
    +   mkdir --parents /tmp/diskroot
    +   mount -t ${FSTYPE} ${roflag} ${ROOTFLAGS} ${ROOT} /tmp/diskroot
    +
    +   mount -t tmpfs -o size=6G none ${rootmnt?}
    +   chmod 755 ${rootmnt}
    +
    +   cp --force --archive --verbose /tmp/diskroot/* ${rootmnt}
    +
    +   umount /tmp/diskroot
    +   rm -r --force /tmp/diskroot
     }
     
     local_mount_fs()


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: