How to choose from multiple Save-Sessions in the same folder at boot?

versatile 64-bit multi-user Linux distribution

Moderators: kirk, jamesbond, p310don, JakeSFR, step, Forum moderators

Post Reply
Clarity
Posts: 3257
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1342 times
Been thanked: 438 times

How to choose from multiple Save-Sessions in the same folder at boot?

Post by Clarity »

hELLO @fatdog

jamesbond wrote: Sat Jul 08, 2023 3:23 am

...
PS2: Fatdog searches for everything that starts with "fd64save", so it does not matter if your savefile/savedir is named fd64save.ext4, fd64save.ext3, fd64save-old, fd64save-backup ... Fatdog should find it...

This is an old response, but I am now about to venture deeper into v901. So, related, I ask:

  • Assume1: FD will boot where a folder, 'Sessions', exist with multiple sessions saved

  • Assume2: An example of multiple saves copied to that folder such that fd64save.ext4, fd64save.ext3, fd64save-old, fd64save-backup all exist within that folder

  • Assume3: I will boot using this parm on the linux line: savefile=ram:label:Persistence:Sessions/v901

Question:

  • Will FD pause and list each session within, upon discovery, for user selection of "which" session to be used on a boot?

.
Thanks in advance for any insights.

Edit: This ability to list all FD sessions when they are present in the same folder...WORKS!
The last 3 post in this thread verify this ability.

Last edited by Clarity on Fri Mar 01, 2024 9:56 am, edited 2 times in total.
step
Posts: 510
Joined: Thu Aug 13, 2020 9:55 am
Has thanked: 50 times
Been thanked: 179 times
Contact:

Re: Multiple Save-Sessions in the same folder at boot

Post by step »

Clarity wrote: Tue Feb 27, 2024 9:35 am

Will FD pause and list, upon discovery, for user selection of "which" session to be used on a boot?
Thanks in advance for any insights.

The best way to find out is to try. Your configuration seems quite specific to your use case, and I can't tell at first sight if it will work the way you want. I read this FAQ page https://distro.ibiblio.org/fatdog/web/f ... efile.html, and it seems to me that your configuration should not work, I'm afraid. But it could be that the FAQ answer is outdated. This is the paragraph that makes me think your configuration won't work, underlining is mine:

FD 901 FAQ wrote:

Problem #2 usually happens if you renamed the savefile and/or put the savefile in a sub-directory, when you created the savefile. It is important to know that by default, Fatdog only scans for savefiles in the top directory of devices, and then only looks for the default filename of the savefile (without the extension).
The default filename is fd64save.ext4, which means that Fatdog will only find savefiles named fd64save.ext4, fd64save.3fs, fd64save-old.ext2, fd64save-backup.sfs, etc. and only if they are located in the root directory.
It is possible to tell Fatdog to search deeper into sub-directories using the search boot parameter, but this is not recommended as searching is slow. The better way is to tell Fatdog exactly where your savefile is and what its name is, using the savefile boot parameter. Doing this stops Fatdog from doing any search at all, instead it will use the given device and given directory and given filename as its savefile. If this fails, it will simply boot without a savefile.

According to the above, when you add savefile boot parameter, there is no search, hence there can't be a prompt. If you find out otherwise, please let us know and we will amend the FAQ.

On a side note, very respectfully said, please don't mention user @fatdog in your posts as user @fatdog is only used for announcements. Mention dev team members' directly, if you must. Thank you.

fatdoguser
Posts: 175
Joined: Sat Aug 05, 2023 10:54 am
Has thanked: 22 times
Been thanked: 79 times

Re: Multiple Save-Sessions in the same folder at boot

Post by fatdoguser »

I see that there is a

savefile=ask

boot option listed in Fatdog help. Never used it myself, know nowt about it. Just thought I'd mention the observation as it may be relevant/appropriate?

I also see that there's a bbshell boot option that drops you to busybox shell/cli before the base sfs is loaded, so I guess could be used to ls (list).. possible different choices of basesfs to use (or copy a particular one/choice into fd64.sfs before its read/used).

Clarity
Posts: 3257
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1342 times
Been thanked: 438 times

Re: Multiple Save-Sessions in the same folder at boot

Post by Clarity »

Even as I KNOW FD is not aligned with Puppy processing, AND knowing that Puppy Linux has this feature when psave (their equivalent to FD's savefile parm) is specified, it will list the sessions when more than 1 is present within the folder. The gives the user a choice of which session to boot. The benefit is that the user 'may' choose which based upon the name the session was saved without having to make errors in typing the full name from memory.

P.S. This is NOT a request to change anything in FD. It is more along the lines when I need different sessions because of the different layout for various session requirements. I am asking because if the feature or similar exist, I wondering if/how to take advantage via proper FD parm use. If development perceives benefit, it will surface later...if not currently present.

fatdoguser
Posts: 175
Joined: Sat Aug 05, 2023 10:54 am
Has thanked: 22 times
Been thanked: 79 times

Re: Multiple Save-Sessions in the same folder at boot

Post by fatdoguser »

Clarity wrote: Tue Feb 27, 2024 8:40 pm

Even as I KNOW FD is not aligned with Puppy processing, AND knowing that Puppy Linux has this feature when psave (their equivalent to FD's savefile parm) is specified, it will list the sessions when more than 1 is present within the folder. The gives the user a choice of which session to boot. The benefit is that the user 'may' choose which based upon the name the session was saved without having to make errors in typing the full name from memory.

P.S. This is NOT a request to change anything in FD. It is more along the lines when I need different sessions because of the different layout for various session requirements. I am asking because if the feature or similar exist, I wondering if/how to take advantage via proper FD parm use. If development perceives benefit, it will surface later...if not currently present.

init inside initrd contains a find_and_choose_device function, that appears to prompt for which of several files if more than one is found, so I suspect it works along the lines you anticipate @Clarity

Code: Select all

### utilities - find the device and savefile to use
# find local devices that has savefile pattern in all known block devices
# $1 - name of return variable (for device)
# $2 - basesfs / savefile path (cannot be blank)
# $3 - filter based on readlink value of /sys/block
# $4 - name of return variable (for savefile path)
find_and_choose_local_device() {	
	local dev spath sname blockdev partitions
	local result p count choose
	local prevmount mntpoint mountdev
	
spath=${2%/*}; sname=${2##*/}; sname=${sname%.*}
[ "$spath" = "$2" ] && spath=	# special case - no path specified
count=0; result=

# look for all savefiles in all devices
mkdir -p /mnt/tmp
echo -n "Looking in "
for blockdev in $(ls /sys/block | grep -vE "^loop|^nbd|^ram|^nand"); do
	partitions=$(ls -d /sys/block/$blockdev/${blockdev}* | sed "s_/sys/block/$blockdev/__")
	partitions=${partitions:-$blockdev}
	for dev in $partitions; do
		echo -n "$dev "	
		if readlink /sys/block/$blockdev | grep -q "$3"; then

			# mount device if not mounted, otherwise use existing mount
			mntpoint=/mnt/tmp mountdev=/dev/$dev
			prevmount=$(awk -v mountdev="$mountdev" '$1 == mountdev { print $2; exit }' /proc/mounts)
			[ $prevmount ] && mntpoint=$prevmount || mount $mountdev $mntpoint 
			
			# look for and record all savefiles found
			while read -r p; do
				if [ "$p" ]; then
					count=$(($count + 1))
					result="$result\n$p"
				fi
			done << EOF
			$(find $mntpoint/$spath -maxdepth $SEARCH_DEPTH -name "$sname*" | sed "s|^${mntpoint}/|${mountdev}:|")
EOF
				[ -z $prevmount ] && umount -f $mntpoint
			fi
		done
	done
	echo
	rmdir /mnt/tmp
	
# choose device and savefile
if [ $count -ne 0 ]; then
	if [ $count -eq 1 ];then
		choose=1
	else
		bold="\e[1m"; unbold="\e[0m"
		echo -e "\n${bold}Please choose savefile to use:${unbold}"
		
		# this complicated-looking code gets the device labels and prints the choices
		{ busybox blkid | sed '/LABEL/ !d; s/ .*LABEL="//; s/".*$//'
		  echo ===savefile===; echo -e $result
		} | awk -F: ' { 
			if ($0 ~ /===savefile===/) count=1
			else if (count == "") labels[$1]=$2
			else if ($0 != "") 
			printf ( "[%d] %s (%s) --> %s\n", count++, $1, labels[$1], $2 ) }'
		echo -ne "\nYour choice [none]: "
		read choose
	fi
	if [ $choose ]; then		
		eval "$1=$(echo -e $result | awk -F: "NR-1 == $choose {print \$1}")"
		[ $4 ] && eval "$4=$(echo -e $result | awk -F: "NR-1 == $choose {print \$2}")"
	fi		
fi
}
fatdoguser
Posts: 175
Joined: Sat Aug 05, 2023 10:54 am
Has thanked: 22 times
Been thanked: 79 times

Re: Multiple Save-Sessions in the same folder at boot

Post by fatdoguser »

To further add - yes it works as expected @Clarity ... presents select none or one of the found choices if there are multiple save choices (fd64save...).

Clarity
Posts: 3257
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1342 times
Been thanked: 438 times

Re: Multiple Save-Sessions in the same folder at boot

Post by Clarity »

@fatdoguser
That's a plus benefit to users who have multiple sessions which, each, may have a different service/function/tests. All sessions can reside in the same place, FD will discover and present a list if there are more than 1 session, and user can choose from the list of FD sessions he named in prior use of FD.

I too are verifying after I noticing the earlier FD code validation!

Thanks to all the great work FD developers and supporters contribute.

P.S. The documentation could reflect this when time exist to update it.

Clarity
Posts: 3257
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1342 times
Been thanked: 438 times

Re: Multiple Save-Sessions in the same folder at boot

Post by Clarity »

Further testing, findings and discussion of this thread's topic is moved to HERE.

Post Reply

Return to “FatDog64”