WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Disable backup / restore (persistence layer) completely  (Read 7159 times)

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Disable backup / restore (persistence layer) completely
« on: July 08, 2020, 06:20:37 PM »
Hi,

My use-case demands avoiding accidental writes to the disk of whatever kind. So much, that I am working towards un-mounting the second partition automatically upon boot.

Can I change the piCore-11 config anywhere which will result in effectively disabling the persistent layer i.e. attempt to restore certain files upon boot & attempt to save certain files upon shutdown?

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1244
Re: Disable backup / restore (persistence layer) completely
« Reply #1 on: July 08, 2020, 07:59:53 PM »
You can prevent loading at boot, but not prevent it from being ran.  whatever you are doing is such a fringe case, you would be best served by making your own initrd image(remastering in the wiki) and not using extensions at all.   Adding or removing files from the initrd as yo see fit.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11639
Re: Disable backup / restore (persistence layer) completely
« Reply #2 on: July 08, 2020, 08:56:13 PM »
Hi ashfame
...  disabling the persistent layer i.e. attempt to restore certain files upon boot ...
Use the  norestore  boot code.

Quote
... & attempt to save certain files upon shutdown?
If you use the  Exit  icon to shut down, it defaults to running a backup. If you change:
Code: [Select]
export BACKUP=1to:
Code: [Select]
export BACKUP=0in  ~/.profile  then clicking  Exit  will default to not running a backup. Since your  /home  directory won't be persistent, you will need
to make the change in the  initrd  in the  /etc/skel/.profile  file.

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Re: Disable backup / restore (persistence layer) completely
« Reply #3 on: July 09, 2020, 05:31:24 PM »
Since your  /home  directory won't be persistent, you will need
to make the change in the  initrd  in the  /etc/skel/.profile  file.

Thanks again Rich :)

Do you mean to say `/etc/skel/.profile` is the file that becomes `~/.profile` upon boot? And that's where I should modify it for the change to be permanent?

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Re: Disable backup / restore (persistence layer) completely
« Reply #4 on: July 09, 2020, 06:41:37 PM »
You can prevent loading at boot, but not prevent it from being ran.  whatever you are doing is such a fringe case, you would be best served by making your own initrd image(remastering in the wiki) and not using extensions at all.   Adding or removing files from the initrd as yo see fit.

Hi Paul, I am building an air-gapped device running on an immutable/ephemeral operating system, hence stringent needs of specific behavior.

Right now, I only want to change bits to make it work as I require. Having my own program packaged as extension & need of display server + webcam support etc, I don't mind using extensions at all, unless you can give me a reason why I shouldn't do things the way I am doing :)

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Re: Disable backup / restore (persistence layer) completely
« Reply #5 on: July 09, 2020, 07:20:05 PM »
Use the  norestore  boot code.
Hi Rich,

I added this boot code and bunch of others like noswap, showapps to cmdline.txt in partition1, but that didn't do the trick.

Contents of cmdline.txt:
Code: [Select]
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/ram0 elevator=deadline rootwait quiet nortc loglevel=3 noembed
and config.txt file uses it, few lines from the top of it:
Code: [Select]
[PI0]
initramfs 11.0.gz,4.19.81-piCore.gz followkernel
kernel kernel41981.img
cmdline cmdline.txt

Pretty sure this is where I need to specify it. Is there another file which is used in place of this one?

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Re: Disable backup / restore (persistence layer) completely
« Reply #6 on: July 09, 2020, 07:40:00 PM »
I created a video to see kernel messages on the screen before they go quickly off and saw this on playback:

1)
Code: [Select]
Ignoring swap partition(s) seek as requested
This means noswap bootcode did its thing. But when I run `free -m`, I still see swap reserving 100MB of space. So not sure what's happening here.

2)
Code: [Select]
Skipping restore as requested from the command line
I also don't see any message "backing up" when rebooting even though I have not changed the .profile file yet. So `norestore` bootcode must be effectively disabling both backup and restore functionality. Right?

3)
Also, I am now seeing this error, before I get the logged in prompt:

Code: [Select]
Loading extensions...

Mounting extensions
----------------------

Traceback (most recent call last):
  File "/usr/bin/tce-bootload", line 97, in <module>
TypeError: extra keyword arguments given

Because of this no extension is loaded from onboot.lst

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Re: Disable backup / restore (persistence layer) completely
« Reply #7 on: July 09, 2020, 07:50:18 PM »
Also, I am now seeing this error, before I get the logged in prompt:

Code: [Select]
Loading extensions...

Mounting extensions
----------------------

Traceback (most recent call last):
  File "/usr/bin/tce-bootload", line 97, in <module>
TypeError: extra keyword arguments given

Because of this no extension is loaded from onboot.lst

Ok, apparently `showapps` bootcode broke it. Removing that made extensions functional again. So, please ignore #3

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11639
Re: Disable backup / restore (persistence layer) completely
« Reply #8 on: July 09, 2020, 07:57:56 PM »
Hi ashfame
... This means noswap bootcode did its thing. But when I run `free -m`, I still see swap reserving 100MB of space. So not sure what's happening here. ...
It's setting up compressed swap space in RAM. If you wish to disable this, add the  nozswap  boot code.

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Re: Disable backup / restore (persistence layer) completely
« Reply #9 on: July 09, 2020, 08:12:52 PM »
Hi ashfame
... This means noswap bootcode did its thing. But when I run `free -m`, I still see swap reserving 100MB of space. So not sure what's happening here. ...
It's setting up compressed swap space in RAM. If you wish to disable this, add the  nozswap  boot code.

That did it. I didn't realize it would still require nozswap when noswap is already specified. Oh well. Thanks again :)

Also, should I bother with that .profile change (/etc/skel/.profile file) that you mentioned earlier, now that, `norestore` seems to be disabling backup as well. Any way to confirm this other than just the messages on tty1 when shutdown/reboot is issued?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11639
Re: Disable backup / restore (persistence layer) completely
« Reply #10 on: July 09, 2020, 08:43:47 PM »
Hi ashfame
I would not expect the  norestore  command to disable the backup, but I can't say for sure.
...  Any way to confirm this other than just the messages on tty1 when shutdown/reboot is issued?
If  shutdown/reboot  is done using the  Exit  icon, the popup window contains a  Backup Options  field. If it's set to  None , then it's not
doing a backup.

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Re: Disable backup / restore (persistence layer) completely
« Reply #11 on: July 09, 2020, 09:06:39 PM »
Hi ashfame
I would not expect the  norestore  command to disable the backup, but I can't say for sure.
...  Any way to confirm this other than just the messages on tty1 when shutdown/reboot is issued?
If  shutdown/reboot  is done using the  Exit  icon, the popup window contains a  Backup Options  field. If it's set to  None , then it's not
doing a backup.

oh I see, will try that. I have only been using "sudo poweroff" & "sudo reboot" commands till now and that's how I was able to see the messages.

Since your  /home  directory won't be persistent, you will need
to make the change in the  initrd  in the  /etc/skel/.profile  file.

Thanks again Rich :)

Do you mean to say `/etc/skel/.profile` is the file that becomes `~/.profile` upon boot? And that's where I should modify it for the change to be permanent?

Could you clarify this bit please?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11639
Re: Disable backup / restore (persistence layer) completely
« Reply #12 on: July 09, 2020, 09:21:39 PM »
Hi ashfame
... oh I see, will try that. I have only been using "sudo poweroff" & "sudo reboot" commands till now  ...
Those are both Linux system commands. No backup will be performed by running either one of those.

Quote
Do you mean to say `/etc/skel/.profile` is the file that becomes `~/.profile` upon boot? And that's where I should modify it for the change to be permanent?
Yes.

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1244
Re: Disable backup / restore (persistence layer) completely
« Reply #13 on: July 09, 2020, 10:21:40 PM »
Hi Paul, I am building an air-gapped device running on an immutable/ephemeral operating system, hence stringent needs of specific behavior.

Right now, I only want to change bits to make it work as I require. Having my own program packaged as extension & need of display server + webcam support etc, I don't mind using extensions at all, unless you can give me a reason why I shouldn't do things the way I am doing :)

Not doing automatic backups would not prevent someone manually doing a backup and that would write to your card.  You would need to either remove the backup programs, or change the ownership of the files such that you cannot run them.  However security on TC is not meant for higher security.  For example, user tc is automatically logged in, and user tc has passwordless sudo access.  With sudo access someone can easily mount the boot partition and change all of your bootcodes.  To change all of this behavior would require editing files that are contained in the initrd.  Hence my comment to remaster it.

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Re: Disable backup / restore (persistence layer) completely
« Reply #14 on: July 10, 2020, 04:37:19 AM »
Hi ashfame
Those are both Linux system commands. No backup will be performed by running either one of those.
Oh, I see. I thought the backup is linked to a shutdown script of some sort. I guess it then comes down to how my OS would be powered off. And since my application would run in a kiosk mode, that's where I would provide the shutdown option either explicit or inactivity based.