Save.dat / changes confusion

Technical issues/questions of an intermediate or advanced nature.
Jack
Contributor
Contributor
Posts: 1257
Joined: 09 Aug 2013, 14:25
Distribution: Porteus 3.2.rc5 Mate 64 bit
Location: Marysville, OHIO USA

Re: Save.dat / changes confusion

Post#16 by Jack » 07 Aug 2016, 16:26

Bogomips wrote:Think you need:

Code: Select all

changes=/porteus/porteussave.dat changes-ro
This way you are starting with last changes and then no longer saving changes, if that is what you wish to do.
If I hit any key it won't save but if I hit Enter or space it will save.
I just like Slackware because I think it teach you about Linux to build packages where Ubuntu is like Windows you just install programs you want.

User avatar
Ed_P
Contributor
Contributor
Posts: 3419
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 3.2.2 64-bit ISO
Location: Western NY, USA

Re: Save.dat / changes confusion

Post#17 by Ed_P » 07 Aug 2016, 18:15

Jack wrote:If I hit any key it won't save but if I hit Enter or space it will save.
Yup. :good:
Ed

Jack
Contributor
Contributor
Posts: 1257
Joined: 09 Aug 2013, 14:25
Distribution: Porteus 3.2.rc5 Mate 64 bit
Location: Marysville, OHIO USA

Re: Save.dat / changes confusion

Post#18 by Jack » 07 Aug 2016, 21:00

How can I tell how much been used? That 4GB has 2.4 free. One thing I did was I made a copy of porteussave.dat file and put it here "/mnt/sdb1/backup" backup is a directory on the same USB just to be safe.
I just like Slackware because I think it teach you about Linux to build packages where Ubuntu is like Windows you just install programs you want.

User avatar
Ed_P
Contributor
Contributor
Posts: 3419
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 3.2.2 64-bit ISO
Location: Western NY, USA

Re: Save.dat / changes confusion

Post#19 by Ed_P » 07 Aug 2016, 22:38

Jack wrote:How can I tell how much been used?
An excellent question Jack. And it is good to be concerned because a) it can fill up and b) you can loose your files should it fill up.

If you are using the save.dat file these commands should help:

savedatspaceused.sh

Code: Select all

#!/bin/sh
#  http://forum.porteus.org/viewtopic.php?f=81&t=1941&start=15#p13272
#  http://forum.porteus.org/viewtopic.php?f=117&t=3205&p=25099#p25097

# Color definitions
txtbld=$(tput bold)               # Bold
txtred=${txtbld}$(tput setaf 1)   # Red
rst=$(tput sgr0)                  # Reset

function redpswd() {
echo -e "$1" $txtred  
}

if [ `whoami` != "root" ]; then
    redpswd "Enter root's password"
    su -c "sh $0 $1"
    exit
fi
echo $rst

du -sh  /mnt/live/memory/images/changes      # Show the amount used
echo
df -h  /mnt/live/memory/images/changes        # Show filesystem summary 
echo
du -sh ${SPACEDATDIR}/etc
du -sh ${SPACEDATDIR}/home
du -sh ${SPACEDATDIR}/opt
du -sh ${SPACEDATDIR}/root  
du -sh ${SPACEDATDIR}/usr
du -sh ${SPACEDATDIR}/var
And while the above script is handy it is only handy when you remember to use it. To check the space used automatically when shutting down I use this script:

savedatspaceck.sh

Code: Select all

#!/bin/sh
# Add to /etc/rc.d/rc.local_shutdown.  And make sure rc.local_shutdown is executable.
# Bogomips help: http://forum.porteus.org/viewtopic.php?f=140&t=6069&p=47591#p47589
#                http://forum.porteus.org/viewtopic.php?f=140&t=6069&p=47614#p47598
# Color definitions
txtbld=$(tput bold)               # Bold
txtred=${txtbld}$(tput setaf 1)   # Red
rst=$(tput sgr0)                  # Reset

function redwarning() {
echo -e $txtred "$1" $rst
}

if [ -a /mnt/live/memory/images/changes ]; then
   SDspace=$(df -BM --output=size,used,avail,pcent /mnt/live/memory/images/changes | tail -n1)
   read size used avail percent <<< $SDspace
   if [ ${percent%\%} -gt  85 ]; then
      echo 
      redwarning "Warning! save.dat file $percent full.  Used: $used  Free: $avail"
      echo 
   else
      echo "save.dat file $percent full.  Used: $used  Free: $avail"
   fi
fi
I made a copy of porteussave.dat file
Excellent. :good: You have learned well Grasshopper. :)

https://en.wikipedia.org/wiki/Kung_Fu_(TV_series)
Ed

User avatar
brokenman
Site Admin
Site Admin
Posts: 5656
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v3.2rcX all desktops
Location: Brazil
Contact:

Re: Save.dat / changes confusion

Post#20 by brokenman » 07 Aug 2016, 23:01

I should look at implementing this in the shutdown scripts. If there is not enough room then the changes are not saved in order to prevent the container file from becoming corrupt.
How do i become super user?
Wear your underpants on the outside and put on a cape.

Jack
Contributor
Contributor
Posts: 1257
Joined: 09 Aug 2013, 14:25
Distribution: Porteus 3.2.rc5 Mate 64 bit
Location: Marysville, OHIO USA

Re: Save.dat / changes confusion

Post#21 by Jack » 07 Aug 2016, 23:10

Ed_P wrote:If you are using the save.dat file these commands should help:
Should I rename mind to save.dat or is it ok to leave mind porteussave.dat? And do I use the 2nd script so it will auto do it for me?
EDIT:
This what happen.

Code: Select all

root@porteus:/mnt/sdb1/backup# sh savedatspacesused.sh
sh: savedatspacesused.sh: No such file or directory
root@porteus:/mnt/sdb1/backup# sh savedatspacesck.sh
sh: savedatspacesck.sh: No such file or directory
root@porteus:/mnt/sdb1/backup# 
You might need some kind of built in Help but just a idea.
I just like Slackware because I think it teach you about Linux to build packages where Ubuntu is like Windows you just install programs you want.

Jack
Contributor
Contributor
Posts: 1257
Joined: 09 Aug 2013, 14:25
Distribution: Porteus 3.2.rc5 Mate 64 bit
Location: Marysville, OHIO USA

Re: Save.dat / changes confusion

Post#22 by Jack » 07 Aug 2016, 23:37

Here is my output on both scripts. It works great.

Code: Select all

root@porteus:/mnt/sdb1/porteus# sh savedatspaceused.sh porteussave.dat

133M	/mnt/live/memory/images/changes

Filesystem      Size  Used Avail Use% Mounted on
/dev/loop14     509M  164M  346M  33% /mnt/live/memory/images/changes

5.9M	/etc
du: cannot access '/home/guest/.gvfs': Permission denied
96M	/home
666M	/opt
53K	/root
1.1G	/usr
24M	/var
root@porteus:/mnt/sdb1/porteus# sh savedatspaceck.sh porteussave.dat
save.dat file 33% full.  Used: 164M  Free: 346M
root@porteus:/mnt/sdb1/porteus# 
I just like Slackware because I think it teach you about Linux to build packages where Ubuntu is like Windows you just install programs you want.

User avatar
Ed_P
Contributor
Contributor
Posts: 3419
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 3.2.2 64-bit ISO
Location: Western NY, USA

Re: Save.dat / changes confusion

Post#23 by Ed_P » 07 Aug 2016, 23:39

brokenman wrote:I should look at implementing this in the shutdown scripts.
Thank you. I am honored you would consider an idea of mine. :D Please note the technical heart of it came from Bogomips.
Jack wrote:Should I rename mind to save.dat or is it ok to leave mind porteussave.dat?
By all means leave it named as porteussave.dat. save.dat is just it's nickname. :)
And do I use the 2nd script so it will auto do it for me?
Well I would try the 1st script periodically to get a feel for the space usage. See how it's allocated and such.
EDIT:
This what happen.

Code: Select all

root@porteus:/mnt/sdb1/backup# sh savedatspacesused.sh
sh: savedatspacesused.sh: No such file or directory
root@porteus:/mnt/sdb1/backup# sh savedatspacesck.sh
sh: savedatspacesck.sh: No such file or directory
root@porteus:/mnt/sdb1/backup# 
You might need some kind of built in Help but just a idea.
Did you save the script as that name? And where did you save it? Mine is in my /home/guest/ folder.
Last edited by Ed_P on 07 Aug 2016, 23:55, edited 1 time in total.
Ed

User avatar
Ed_P
Contributor
Contributor
Posts: 3419
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 3.2.2 64-bit ISO
Location: Western NY, USA

Re: Save.dat / changes confusion

Post#24 by Ed_P » 07 Aug 2016, 23:44

Jack wrote:Here is my output on both scripts. It works great.
Excellent!! :Yahoo!:

You don't need to added "porteussave.dat" to the commands to run them. Both scripts read the contents of the files in use.

For the automatic check version this is my /etc/rc.d/rc.local_shutdown file:

Code: Select all

#!/bin/sh
#
# rc.local_shutdown
#
# This script is executed at shutdown (rc0) and reboot (rc6).
# You need to make it executable before using.
#
# Example:
# /etc/rc.d/rc.samba stop
#
/home/guest/savedatspaceck.sh
Ed

Jack
Contributor
Contributor
Posts: 1257
Joined: 09 Aug 2013, 14:25
Distribution: Porteus 3.2.rc5 Mate 64 bit
Location: Marysville, OHIO USA

Re: Save.dat / changes confusion

Post#25 by Jack » 08 Aug 2016, 00:07

This is your. And you just added to the end of the line?
/home/guest/savedatspaceck.sh
I could put mind in the same place.
I just like Slackware because I think it teach you about Linux to build packages where Ubuntu is like Windows you just install programs you want.

User avatar
Ed_P
Contributor
Contributor
Posts: 3419
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 3.2.2 64-bit ISO
Location: Western NY, USA

Re: Save.dat / changes confusion

Post#26 by Ed_P » 08 Aug 2016, 00:27

Jack wrote:This is your. And you just added to the end of the line?
Yup.
I could put mind in the same place.
Yup.

But you have to be root to do it.
Ed

User avatar
brokenman
Site Admin
Site Admin
Posts: 5656
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v3.2rcX all desktops
Location: Brazil
Contact:

Re: Save.dat / changes confusion

Post#27 by brokenman » 08 Aug 2016, 02:35

save.dat file 33% full. Used: 164M Free: 346M
There is something wrong with the math here.

Thank you. I am honored you would consider an idea of mine.
The idea was introduced many years ago, but sat on the backburner. Thanks for bringing it back up, and thanks for the legwork Bogomips. If time permits I will try to incorporate it into the shutdown. Perhaps if the container is not big enough an offer could be made to create a module on a real file system instead.
How do i become super user?
Wear your underpants on the outside and put on a cape.

User avatar
Ed_P
Contributor
Contributor
Posts: 3419
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 3.2.2 64-bit ISO
Location: Western NY, USA

Re: Save.dat / changes confusion

Post#28 by Ed_P » 08 Aug 2016, 04:39

brokenman wrote:save.dat file 33% full. Used: 164M Free: 346M
There is something wrong with the math here.
Not by much.

164 / (164 + 346) = 164 / 510 = 0.321568

And the numbers are from Porteus's df command not calculated by a script.
Perhaps if the container is not big enough an offer could be made to create a module on a real file systemr instead.
Yes. Thank you. Or offer to stop the shutdown and let the user decide how to proceed.

I was considering adding a 15 second delay to the warning to allow the user time to consider a plan of action.
Ed

Bogomips
Full of knowledge
Full of knowledge
Posts: 2563
Joined: 25 Jun 2014, 15:21
Distribution: 3.2.2 Cinnamon & KDE5
Location: London

Re: Save.dat / changes confusion

Post#29 by Bogomips » 09 Aug 2016, 19:35

brokenman wrote:If time permits I will try to incorporate it into the shutdown.
Another approach could be to change the way the save.dat file is created, as illustrated thru dabblings with container file viewtopic.php?f=140&t=6069&p=47800#p47800. In the example the amount of free and used space is always ascertainable offline.
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

User avatar
Ed_P
Contributor
Contributor
Posts: 3419
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 3.2.2 64-bit ISO
Location: Western NY, USA

Re: Save.dat / changes confusion

Post#30 by Ed_P » 09 Aug 2016, 20:25

Bogomips wrote:Another approach could be to change the way the save.dat file is created, as illustrated thru dabblings with container file viewtopic.php?f=140&t=6069&p=47800#p47800. In the example the amount of free and used space is always ascertainable offline.
Pardon me but that approach is something the user has to run manually and it may not be done when most needed, when shutting down.

I've used this script for a few years now to manually check my save.dat space files both online and offline. And it works for versions 3.0, 3.1 and 3.2 rc3, 4 & 5. But it only works if you remember to use it.

Code: Select all

#!/bin/sh
#  http://forum.porteus.org/viewtopic.php?f=81&t=1941&start=15#p13272
#  http://forum.porteus.org/viewtopic.php?f=117&t=3205&p=25099#p25097

#  mloop requires changes= cheatcodes not be used (Always Fresh mode)
#  nor modsavedat/porteussave.dat.xzm!!

BOOTDEV=`grep -A1 "Booting" /var/log/porteus-livedbg|tail -n1|sed 's^//^/^g'`
if [ "$BOOTDEV" == "/mnt/isoloop" ]; then
   BOOTDEV=`grep -A1 "ISO=" /var/log/porteus-livedbg`
   BOOTDEV=${BOOTDEV:4:9}
fi
VERSION=$(cat /etc/porteus-version)
FOLDER=porteus${VERSION:9:3}
GUEST="$BOOTDEV/$FOLDER/Guest"
MODULES="$BOOTDEV/$FOLDER/Modules"

# Color definitions
txtbld=$(tput bold)               # Bold
txtred=${txtbld}$(tput setaf 1)   # Red
rst=$(tput sgr0)                  # Reset

function redpswd() {
echo -e "$1" $txtred  
}

if [ `whoami` != "root" ]; then
    redpswd "Enter root's password"
    su -c "sh $0 $1"
    exit
fi
echo $rst

if [ "$1" == "" ]; then
   if [ -a /mnt/live/memory/images/changes ]; then
      SPACEDATDIR=/mnt/live/memory/images/changes 
   else
      echo mloop $BOOTDEV/$FOLDER/changes/porteussave.dat
      mloop $BOOTDEV/$FOLDER/changes/porteussave.dat
      SPACEDATDIR=/mnt/loop
   fi
else
   echo mloop $1
   mloop $1
   SPACEDATDIR=/mnt/loop
fi

if [ ! -d ${SPACEDATDIR}/home ]; then 
   echo " Error!! "
   dmesg | tail > t
   UUIDck=$(grep -A1 "duplicate UUID" t) 
   if [ ! "$UUIDck" == "" ]; then
      echo
      echo " * This is NOT Always Fresh mode. * "
      echo
   else 
      echo
      echo "dmesg | tail "
      dmesg | tail  
   fi
   rm t
   uloop
   exit
fi

echo
echo du -sh
du -sh ${SPACEDATDIR}     # Show the amount used   
echo df -h
df -h  ${SPACEDATDIR}     # Show filesystem summary
echo
du -sh ${SPACEDATDIR}/etc
du -sh ${SPACEDATDIR}/home
du -sh ${SPACEDATDIR}/opt
du -sh ${SPACEDATDIR}/root
du -sh ${SPACEDATDIR}/usr
du -sh ${SPACEDATDIR}/var
echo
if [ -d "${SPACEDATDIR}/home/guest/.PlayOnLinux" ]; then
  du -sh ${SPACEDATDIR}/home/guest/.PlayOnLinux
fi
du -sh ${SPACEDATDIR}/home/guest/.wine
echo
echo Press Enter for more details, Ctrl+C to end.
read 
du -sh  ${SPACEDATDIR}/etc/usm
echo ls ${SPACEDATDIR}/etc/usm
ls      ${SPACEDATDIR}/etc/usm
#cat     ${SPACEDATDIR}/etc/usm/usm.conf
echo
du -sh  ${SPACEDATDIR}/var/log
du -sh  ${SPACEDATDIR}/var/usm
du -h   ${SPACEDATDIR}/var/usm/*
echo
du -sh  ${SPACEDATDIR}/home/guest/Downloads
du -sh  ${SPACEDATDIR}/home/guest/Desktop
du -h   ${SPACEDATDIR}/home/guest/Backups
echo
echo ls -s   ${SPACEDATDIR}/home/guest/Backups/FireFox
ls -s   ${SPACEDATDIR}/home/guest/Backups/FireFox
echo
du  -h ${SPACEDATDIR}/*|grep '[0-9][0-9]M'

if [ -a /mnt/live/memory/images/changes ]; then
   echo  
   echo "For more info use:" 
   echo " du -h /mnt/live/memory/images/changes/home/guest*"
   echo " du -h /mnt/live/memory/images/changes/home/*" and
   echo " du -h /mnt/live/memory/images/changes/*|grep  '[0-9][0-9]M'"
else
   uloop 
fi
And if you are at 80% used and download 5 movies and don't remember to run the script it won't help you save your save.dat file. Been there, done that.
Ed

Post Reply