No capability to remove boot media with a savefile

Please reproduce your error on a second machine before posting, and check the error by running without saved changes or extra modules (See FAQ No. 13, "How to report a bug"). For unstable Porteus versions (alpha, beta, rc) please use the relevant thread in our "Development" section.
User avatar
Rava
Contributor
Contributor
Posts: 5416
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

No capability to remove boot media with a savefile

Post#16 by Rava » 31 Aug 2023, 03:34

^
That settles it, then. The solution already exists, you are just unable to find it.

Still you request me coding it anew. Quick audacious of you, instead of, you know, doing the obvious and finding and looking at the already existing solution.
Cheers!
Yours Rava

User avatar
Ed_P
Contributor
Contributor
Posts: 8374
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

No capability to remove boot media with a savefile

Post#17 by Ed_P » 31 Aug 2023, 03:43

You are by far the better coder and even have a whole thread backing that up: Ravas coding goodies. I don't.
Ed

User avatar
Rava
Contributor
Contributor
Posts: 5416
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

No capability to remove boot media with a savefile

Post#18 by Rava » 31 Aug 2023, 03:47

Ed_P wrote:
31 Aug 2023, 03:43
You are by far the better coder and even have a whole thread backing that up
That might be, but you ignore the elephant in the room:
Rava wrote:
31 Aug 2023, 03:34
The solution already exists […]
[D]oing the obvious and finding and looking at the already existing solution.
Please answer the obvious and no moving the goalpost.
Cheers!
Yours Rava

User avatar
Ed_P
Contributor
Contributor
Posts: 8374
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

No capability to remove boot media with a savefile

Post#19 by Ed_P » 31 Aug 2023, 05:37

I believe the system shutdown uses the /etc/rc.d/rc.6 and /mnt/live/cleanup files. A reference to changes-exit.conf is on lines 38 and 40 of the cleanup file.
Ed

User avatar
Rava
Contributor
Contributor
Posts: 5416
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

No capability to remove boot media with a savefile

Post#20 by Rava » 31 Aug 2023, 06:36

Ed_P wrote:
31 Aug 2023, 05:37
I believe the system shutdown uses the /etc/rc.d/rc.6 and /mnt/live/cleanup files. A reference to changes-exit.conf is on lines 38 and 40 of the cleanup file.
indeed, it is the section of

Code: Select all

# Save 'changes=EXIT:' session:
There you have the code you need to examine:

Code: Select all

  if [ "$ans" = "" ]; then
	DEST=`cat /tmp/changes-exit`; NAME=`basename $DEST`; MNAME=/memory/images/changes; FOLDERS=`grep '^/' /union/etc/changes-exit.conf | sed s/^.//g`
	echo "saving changes to $NAME - do not power off the PC"
	cd /memory/changes; rm -rf var/lock/subsys/* var/run/laptop-mode-tools/* `grep '^!' /union/etc/changes-exit.conf | sed s/^..//g | tr "\n" " "`
and the following lines. :)

Added in 55 seconds:
Maybe how /tmp/changes-exit is set up is also of importance.
Cheers!
Yours Rava

User avatar
Ed_P
Contributor
Contributor
Posts: 8374
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

No capability to remove boot media with a savefile

Post#21 by Ed_P » 02 Sep 2023, 05:27

Rava wrote:
31 Aug 2023, 06:37
Maybe how /tmp/changes-exit is set up is also of importance.
/mnt/live/init & /mnt/live/linuxrc Lines 154, 273, 284.
Ed

User avatar
Rava
Contributor
Contributor
Posts: 5416
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

No capability to remove boot media with a savefile

Post#22 by Rava » 02 Sep 2023, 07:25

^

Code: Select all

root@porteus:/# head -n 3 /mnt/live/init
#!/bin/sh
### linuxrc script by brokenman <http://www.porteus.org>

root@porteus:/# 
Wow. made by our famous (now retired) brokenman himself, seemingly without any needed changes.

Added in 1 minute 3 seconds:
At least there are no documented changes according to the initial code lines.
Cheers!
Yours Rava

User avatar
Ed_P
Contributor
Contributor
Posts: 8374
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

No capability to remove boot media with a savefile

Post#23 by Ed_P » 07 Sep 2023, 21:42

Rava wrote:
30 Aug 2023, 05:09
Cave! Be aware that most likely in /home there are quite some files you do not want to save, e.g. the often quite large ~/.cache/ .
It looks like this would be easier to impliment.
https://forum.porteus.org/viewtopic.php?p=86214#p86214 wrote:
Rapha_ wrote:
19 Dec 2021, 18:36
- excluding the cache folder
:o I like this idea Rapha_. :happy62: :good:

In my changes.sh script I changed my

Code: Select all

sudo -S find /mnt/live/memory/changes  -iname "*" -mmin -$X
line to be

Code: Select all

sudo -S find /mnt/live/memory/changes  -not -path "*/.cache/*"  -iname "*" -mmin -$X
Ed

User avatar
KingJames
White ninja
White ninja
Posts: 25
Joined: 26 Nov 2022, 17:20
Distribution: porteus5.0

No capability to remove boot media with a savefile

Post#24 by KingJames » 17 Nov 2023, 17:59

I've been playing around with the /mnt/live/init file, trying to figure out a way to trick the system into setting up saving changes on exit without binding the USB drive permanently. However, I am still very much a script kiddie, and I can't decipher it all.

I did create a custom script that rsync'd all changes in my home folder to the rootcopy directory on my drive, and it worked marvelously. However, I'd like to be able to save changes to the whole system, and I can't rsync the whole system. That would be prohibitively time consuming to copy to ram. Usually, I just save changes to a .xzm file if I change a system file, so it wasn't a problem. However, I'm trying to migrate to a fat32 thumb drive, and I need to sync file permissions too, which requires either a savefile or a module. I can create a savefile, but I don't know how to save to a .dat file manually. I also don't know how to save to a .xzm file without decompressing it, editing it, then recompressing it, which takes quite a while to do (I suspect ~30 seconds if I put it in a script. Too long on shutdown).

What I really want to do is edit some of the startup scripts to trick the built in changes system into thinking there was a drive mounted for changes on exit when there actually isn't. I can then edit the /etc/rc.d/rc.local_shutdown to remount to drive to the correct location so that the /mnt/live/cleanup file can save changes as it normally would.

If anyone has any wisdom to spare I'd really appreciate it!
Porteus 5.0. I'm still learning linux. I hate Big Tech spying on me and I like open source. I am really enjoying Porteus. I keep it on a thumb drive and I copy to ram in less time than it takes Windows on my hard drive to boot up.

User avatar
Ed_P
Contributor
Contributor
Posts: 8374
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

No capability to remove boot media with a savefile

Post#25 by Ed_P » 17 Nov 2023, 18:29

KingJames wrote:
17 Nov 2023, 17:59
I also don't know how to save to a .xzm file without decompressing it, editing it, then recompressing it, which takes quite a while to do (I suspect ~30 seconds if I put it in a script. Too long on shutdown).
KingJames wrote:
17 Nov 2023, 17:59
I can then edit the /etc/rc.d/rc.local_shutdown to remount to drive to the correct location so that the /mnt/live/cleanup file can save changes as it normally would.
How long do you think this will take when the shutdown finds the USB drive hasn't been reinserted and you have to find it before the system shuts down? As for saving the changes to an .xzm file why decompress the old/current one and rebuild it? Rename the old one and create a new one. I rename mine to mychanges.xyzm and then build a new one when I update the module.

The problem that comes into play is manually remembering to use the USB drive and save changes when shutting down when you don't use the changes=EXIT cheatcode. Of course not all runs of Porteus create things that need to be saved.
Ed

User avatar
KingJames
White ninja
White ninja
Posts: 25
Joined: 26 Nov 2022, 17:20
Distribution: porteus5.0

No capability to remove boot media with a savefile

Post#26 by KingJames » 17 Nov 2023, 22:05

Yeah, if I haven't inserted the drive, it'll take a second to plug it in, but this a minor inconvenience compared to leaving the drive plugged in all the time. The script I currently use searches for the drive by UUID and automatically mounts it. If it's not found, it prompts the user asking whether to continue without saving or re-search (presumably after he has plugged in the drive). That part isn't a problem, even for this basic scripter 😂

I would rather have a prompt on shutdown asking whether or not I wish to save changes for this boot. I could just open the porteus savefile manager and save changes to a file when i want, but it's rather inconvenient to have to do on every boot I change something. If there is absolutely no way to do what I want, then that's fine, don't waste too much time on it, I'll keep trying on my own until I get it.

Alternatively, is there a way I can invoke the porteus manager to save to a file directly from a terminal? If I could do that, I could just invoke it in /etc/rc.d/rc_local_shutdown and rename the old one, as you suggest, problem solved. It'll be kinda slow to create a new changes file every time, I'd rather sync it somehow, but I could live with it.
Porteus 5.0. I'm still learning linux. I hate Big Tech spying on me and I like open source. I am really enjoying Porteus. I keep it on a thumb drive and I copy to ram in less time than it takes Windows on my hard drive to boot up.

User avatar
KingJames
White ninja
White ninja
Posts: 25
Joined: 26 Nov 2022, 17:20
Distribution: porteus5.0

No capability to remove boot media with a savefile

Post#27 by KingJames » 17 Nov 2023, 22:08

rc.local_shutdown*
Porteus 5.0. I'm still learning linux. I hate Big Tech spying on me and I like open source. I am really enjoying Porteus. I keep it on a thumb drive and I copy to ram in less time than it takes Windows on my hard drive to boot up.

beny
Full of knowledge
Full of knowledge
Posts: 2098
Joined: 02 Jan 2011, 11:33
Location: italy

No capability to remove boot media with a savefile

Post#28 by beny » 17 Nov 2023, 22:45

hi,you can use the save-changes script: you have to run this script just before you have to shutdown,porteus or the usb key do not shutdown if it have something to write and if you have a script like rsync maybe work...but

Code: Select all

#!/bin/bash
# Save changes into a module.
# Author: Brokenman <brokenman@porteus.org>

# Switch to root
if [ `whoami` != "root" ]; then
    echo "Please enter your root password below"
    su - -c "/opt/porteus-scripts/save-changes $1"
    exit
fi

echo
ch=/mnt/live/memory/changes

usage(){
echo
echo "save-changes /path/to/resulting/module.xzm"
echo
echo "You must give a path to save your changes to."
}

if [ "$1" == "" -o "$1" == "-h" -o "$1" == "--help" ]; then
  usage
  exit
fi

# Make sure given path ends in .xzm
if [ `echo $1|awk -F. '{print$NF}'` != "xzm" ]; then
  echo 
  echo "Your path must end in .xzm"
  echo "Example: /tmp/changes.xzm"
  echo
  exit
fi

#dir2xzm $ch $1
mksquashfs $ch $1 -e dev tmp mnt

echo
echo "Your changes module has been created!"
echo "$1"
echo
exit
                                         

User avatar
Ed_P
Contributor
Contributor
Posts: 8374
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

No capability to remove boot media with a savefile

Post#29 by Ed_P » 17 Nov 2023, 22:57

Does rc.local.shutdown get executed if changes=EXIT is not used? When I reboot in my safe system I don't pay much attention to the shutdown screen.

Does the changes script you reference beny use the /etc/changes-exit.conf file when it is run?
Ed

beny
Full of knowledge
Full of knowledge
Posts: 2098
Joined: 02 Jan 2011, 11:33
Location: italy

No capability to remove boot media with a savefile

Post#30 by beny » 17 Nov 2023, 23:07

hi Ed_P no this script a lot of time ago is used to make the packages of nvidia and other huge software in a clean system,so it is another task,but you can use to manage the changes

Post Reply