Creating a volatile image
When an .hddimg image is used on a hard disk or flash drive, the target root directory is implemented as a loop device referring to the rootfs.img file contained in that drive. This means it is a true non-volatile file system. Is there a way to make the entire file system volatile?
I'm trying to ensure that my flash drive is written to as rarely as possible. To this end, I'm putting my app's volatile data on a separate partition, and I'd like to run the OS out of a big ramdisk, loading it on startup and then discarding it on shutdown. In other words, I want a Groundhog Day system, which always boots up as though it is a brand new clean install.
I've spent a couple hours trying to decipher various .bbclass files, Googling about the various file systems, and so on, and I haven't seen anything that looks like this capability is already provided somehow in the Yocto system. Is there an easy way to do this? Or is there only a hard way to do it, involving way more expertise in the build system than I've got?
Alternatively, is it practical to make the existing file system readonly? My system is based on core-image-base, with no graphics. What will break if it can't write to anything outside of /tmp or /run or /media/ram or /var/volatile? And is there a built-in way to do that?
Signature · 2 lines
Ciao, Paul D. DeRocco Paul mailto:[email protected]
Quoted 4 lines · Paul D. DeRocco
When an .hddimg image is used on a hard disk or flash drive, the target root directory is implemented as a loop device referring to the rootfs.img file contained in that drive. This means it is a true non-volatile file system. Is there a way to make the entire file system volatile?
Three ways to achieve this goal.
1. If you're using yocto 3.8 kernel, you can enable aufs by add the following line to local.conf. KERNEL_FEATURES_append = " features/aufs/aufs-enable.scc"
This will enable the aufs support and your live image (iso or hddimg) will appear to be writable. This aufs support in live image is added recently.
commit: 29e55997caeb9c6367f9a340e153f829228f36ed
subject: init-live.sh: try to make a union mount when possible
2. If you're using other kernel versions, an option is to use device-mapping. But you might need to write your own recipe to include the dmsetup command into the image. In addition, you need to modify the init-live.sh script a little.
dmsetup is not used in OE/Yocto for now.
ArchLinux uses this method to make its liveCD version work.
3. As a temporary workaround, you can bind mount the directory you need to write to with a tmpfs. e.g.
mkdir -p /var/volatile/lib
mount --bind /var/lib /var/volatile/lib
Best Regards,
Chen Qi
Quoted 18 lines
I'm trying to ensure that my flash drive is written to as rarely as possible. To this end, I'm putting my app's volatile data on a separate partition, and I'd like to run the OS out of a big ramdisk, loading it on startup and then discarding it on shutdown. In other words, I want a Groundhog Day system, which always boots up as though it is a brand new clean install.
I've spent a couple hours trying to decipher various .bbclass files, Googling about the various file systems, and so on, and I haven't seen anything that looks like this capability is already provided somehow in the Yocto system. Is there an easy way to do this? Or is there only a hard way to do it, involving way more expertise in the build system than I've got?
Alternatively, is it practical to make the existing file system readonly? My system is based on core-image-base, with no graphics. What will break if it can't write to anything outside of /tmp or /run or /media/ram or
/var/volatile? And is there a built-in way to do that?
Quoted 4 lines · Paul D. DeRocco
Alternatively, is it practical to make the existing file system readonly? My system is based on core-image-base, with no graphics. What will break if it can't write to anything outside of /tmp or /run or /media/ram or
/var/volatile? And is there a built-in way to do that?
You can set the "read-only-rootfs" image feature (never tried it myself, so YMMV), but if you turn off atime writes to / you won't be making that many writes to / anyway.
Ross
Quoted 4 lines
From: Burton, Ross
You can set the "read-only-rootfs" image feature (never tried it myself, so YMMV),
That would certainly be the simplest thing to try.
Quoted 2 lines
but if you turn off atime writes to / you won't be making that many writes to / anyway.
How does one turn off atime? By modifying /etc/fstab? How is that done? By supplying a different source file to get copied into the image, or by overwriting the built-in one in my own recipe? I need to do that anyway, since I have a second partition to mount.
Signature · 2 lines
Ciao, Paul D. DeRocco Paul mailto:[email protected]
Quoted 7 lines · Paul D. DeRocco
Quoted 2 lines
but if you turn off atime writes to / you won't be making that many writes to / anyway.
How does one turn off atime? By modifying
/etc/fstab? How is that done? By supplying a different source file to get copied into the image, or by overwriting the built-in one in my own recipe? I need to do that anyway, since I have a second partition to mount.
You can override the fstab provided by base-files with your own, and use the mount option "noatime".
Ross