Page 2 of 7
Re: Save.dat / changes confusion
Posted: 07 Aug 2016, 16:26
by Jack
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.
Re: Save.dat / changes confusion
Posted: 07 Aug 2016, 18:15
by Ed_P
Jack wrote:If I hit any key it won't save but if I hit Enter or space it will save.
Yup.
Re: Save.dat / changes confusion
Posted: 07 Aug 2016, 21:00
by Jack
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.
Re: Save.dat / changes confusion
Posted: 07 Aug 2016, 22:38
by Ed_P
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.
You have learned well Grasshopper.
https://en.wikipedia.org/wiki/Kung_Fu_(TV_series)
Re: Save.dat / changes confusion
Posted: 07 Aug 2016, 23:01
by brokenman
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.
Re: Save.dat / changes confusion
Posted: 07 Aug 2016, 23:10
by Jack
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.
Re: Save.dat / changes confusion
Posted: 07 Aug 2016, 23:37
by Jack
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#
Re: Save.dat / changes confusion
Posted: 07 Aug 2016, 23:39
by Ed_P
brokenman wrote:I should look at implementing this in the shutdown scripts.
Thank you. I am honored you would consider an idea of mine.
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.
Re: Save.dat / changes confusion
Posted: 07 Aug 2016, 23:44
by Ed_P
Jack wrote:Here is my output on both scripts. It works great.
Excellent!!
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
Re: Save.dat / changes confusion
Posted: 08 Aug 2016, 00:07
by Jack
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.
Re: Save.dat / changes confusion
Posted: 08 Aug 2016, 00:27
by Ed_P
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.
Re: Save.dat / changes confusion
Posted: 08 Aug 2016, 02:35
by brokenman
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.
Re: Save.dat / changes confusion
Posted: 08 Aug 2016, 04:39
by Ed_P
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.
Re: Save.dat / changes confusion
Posted: 09 Aug 2016, 19:35
by Bogomips
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
http://forum.porteus.org/viewtopic.php? ... 800#p47800. In the example the amount of free and used space is always ascertainable offline.
Re: Save.dat / changes confusion
Posted: 09 Aug 2016, 20:25
by Ed_P
Bogomips wrote:Another approach could be to change the way the save.dat file is created, as illustrated thru dabblings with container file
http://forum.porteus.org/viewtopic.php? ... 800#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.