WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Howto keep mmcblk0p2 read only  (Read 2606 times)

Offline syrekron

  • Newbie
  • *
  • Posts: 6
Howto keep mmcblk0p2 read only
« on: November 13, 2015, 03:20:13 PM »
Hi Folks.  I've been enjoying my time over the past few days diving into the core with my pi.
I'm working on a customization based on 6.1 for a model B pi where I'd like to keep the filesystem that hosts /tce mounted read only.
I'm admittedly paranoid about power interruptions and and want to avoid writes to my flash cards.
I've checked the boot codes and skimmed the core book but not seen a preferred method to accomplish this.
So, my question is this: is there a preferred method to keep /mnt/mmcblk0p2 mounted read only and if not what would be a clean way to do this?


TIA
-syrekron

Online curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11049
Re: Howto keep mmcblk0p2 read only
« Reply #1 on: November 13, 2015, 04:15:43 PM »
If you're not afraid of boot-time power interruption, you can remount it read-only in bootsync.sh.

Always mounting it read-only means editing the boot scripts and remastering, or using a read-only FS for the partition (yes, you are allowed to use squashfs for real partitions).
The only barriers that can stop you are the ones you create yourself.

Offline syrekron

  • Newbie
  • *
  • Posts: 6
Re: Howto keep mmcblk0p2 read only
« Reply #2 on: November 13, 2015, 04:33:09 PM »
curaga,
Thanks for the response.  I'll look into those options.  I'm guessing the read only FS would be the easiest....
I'm hoping to make this solar powered at some point (with minimal energy storage) so a power interruption during boot is certainly possible.
-syrekron

Offline jgrulich

  • Sr. Member
  • ****
  • Posts: 341
    • GRULICH DESIGN - R&D Lab.
Re: Howto keep mmcblk0p2 read only
« Reply #3 on: November 13, 2015, 04:39:25 PM »
Even when used read-only ext4 second partition, the power interruption sometimes causes data corruption. Tested.
I've solved this system safety with only one FAT partition on SD card without the ext4 one.
It needs to remaster the *.gz file on the SD card with addition of all the needed .tcz installations.
 The SD card is than read-only and accessed only at boot and is not mounted than.
The only disadvantage is that there is no data storage capability.
I'm using this way for a months, several cycles per day with only power ON/OFF control, means without any regular system termination and didn't found any SD card inconsistency, or even data corruption.

Offline Greg Erskine

  • Sr. Member
  • ****
  • Posts: 404
Re: Howto keep mmcblk0p2 read only
« Reply #4 on: November 13, 2015, 06:54:41 PM »
hi syrekron,

I help sbp develop piCorePlayer and I can assure you that corruption of the SD card is very unlikely. I have made hundreds of SD cards with piCore and can't recall one corruption. We have hundreds of users that just pull the power to turn it off. :o I assume you application doesn't write to the SD card as you have asked for it to be readonly.

Further, if you use the copy2fs.flg to copy extensions to RAM rather than loop mount, you can unmount /mnt/mmcblk0p2 if no files are open. This works for our application. You can even remove the SD card though I don't recommend it.

Obviously, if you make it readonly or load into RAM doing backups requires extra steps.

regards
Greg