topic title: PC-BSD
Posts: 279
afab4
Joined: 17 Oct 2009
#16
anticapitalista wrote:Yes, cpulimit was mentioned before, but I forgot about it __{{emoticon}}__

This seems to be working.

#cpulimit --exe mksquashfs --limit 40

and then run mksquashfs

The main reason to reduce CPU is due to heat on laptops. I think this option is better than using a bag of ice cubes __{{emoticon}}__
Can this be added to the antixsnapshot script?
YES much better than setting my laptop on ice or setting it in the freezer __{{emoticon}}__
anticapitalista
Posts: 5,955
Site Admin
Joined: 11 Sep 2007
#17
It doesn't seem to work within the script as cpulimit needs to be run in parallel or just before mksquashfs is called. But I'll try it again)

Maybe one of the real gurus could suggest a way for this to happen.

BTW cpulimit --exe mksquashfs --limit 40 makes it very, very slow.

User should play with the numbers.

Some users may not want cpulimit running, so I guess it sgould be an option in the etc/antixsnapshot file and also the setting of the --limit value.
Posts: 1,062
Dave
Joined: 20 Jan 2010
#18
maybe a yad wrapper script?
something like:

Code: Select all

amount=`yad --scale\
 --min-value="40"\
 --max-value="100"\
 --value="70"\
 --text="Select the amount in of cpu\n you would like to use"\
 --button="gtk-ok:0"`; 
cpulimit --exe mksquashfs --limit $amount ;
[\code]

and then run the wrapper script from antix snapshot with nohup?
Posts: 279
afab4
Joined: 17 Oct 2009
#19
anticapitalista wrote:Yes, cpulimit was mentioned before, but I forgot about it __{{emoticon}}__

This seems to be working.

#cpulimit --exe mksquashfs --limit 40

and then run mksquashfs

The main reason to reduce CPU is due to heat on laptops. I think this option is better than using a bag of ice cubes __{{emoticon}}__

Okay, I installed cpulimit and then ran

Code: Select all

cpulimit --exe mksquashfs --limit 40 antixsnapshot
and it ran ok, no heat problems albeit slow.

So I changed the setting to 70 first, then 50 and the process took off hell bent both times and I couldn't shut it down. I finally had to power down my laptop.
Am I doing something wrong the way I am calling antixsnapshot?
anticapitalista
Posts: 5,955
Site Admin
Joined: 11 Sep 2007
#20
Try this.

#cpulimit --exe antixsnapshot --limit 40

Then open antixsnapshot in a terminal and htop to see if all is ok.

Added: Unfortunately, on its own, the above is ok for the beginning ie when rsync copies the files, but when mksquashfs takes over to make the compressed file system, CPU goes up so you need to open another root terminal as type

#cpulimit --exe mksquashfs --limit 40

There must be a better way. Time for me to rtfm.
Posts: 279
afab4
Joined: 17 Oct 2009
#21
anticapitalista wrote:
There must be a better way. Time for me to rtfm.
anti.
I blacklisted rsync, mksquashfs and genisoimage in the cpulimit_ daemon.sh and changed to 80 percent as you did. Works well. No overheating at this level on my laptop. antixsnapshot does take longer to complete but it is a good trade off.
I am using 43-52 % CPU and temperature 150-175 F so that is very good.
One thing i noticed was when I just added mksquashfs to the blacklist I seemed to use a few more MB at idle.
With all 3 processes added my idle MB actually dropped about 3 MB. So I am just going to let the daemon run all the time.
Posts: 9
fsmithred
Joined: 02 Oct 2011
#22
Here's a script I've used along with refractasnapshot to limit cpu usage for rsync. It uses the pid, so it has to be started after rsync starts. Maybe it'll give someone ideas.

Code: Select all

#!/usr/bin/env bash

for i in $(pgrep rsync); do
    sudo cpulimit -e rsync -l 50 &
done

echo"cpulimit"
ps ax |grep cpulimit
echo"rsync"
ps ax | grep rsync
echo"@@@@@"

sleep 360

if $(ps ax | grep -q mksquashfs); then
    sudo pkill cpulimit
fi

echo"#####"
ps ax | grep cpulimit
echo"#####"

exit 0
nadir
Posts 0
nadir
#23
meandean wrote:Heck I think the basic bash commands were the easy part. The others did the complicated part... __{{emoticon}}__

Dare i refresh your memory a bit? I recall a very old thread at a forum called cloudywizzard (?) where you explained how to use live-helper to BroTiag (and over several pages, with loads of questions and miracles). Back in those times it was a pain to get squash running (fiddling with kernel modules and what not). Then you posted that at forums.debian, and then came how-to's bout how to create something like a snapshot:"lh config --bootstrap copy" (and then, finally, something with bash commands).

So no: it was not the easy part, as far i can tell. I can't count the times where i linked to one of those how-to's. Not saying that the other things are not difficult (au contraire).
end off-topic.
Posts: 15
meandean
Joined: 14 Jul 2012
#24
nadir wrote:
Dare i refresh your memory a bit?
refresh away __{{emoticon}}__

I guess I should clarify. Coming up with the process/commands was the fun part. Some trial and error, some experimentation, and some testing. That for me is the easy part. The programing part....not so much.
nadir
Posts 0
nadir
#25
ah, i see.
Yes, with that i agree. fsmithred has fiddled more than just a bit with it (most of it is beyond me... but i got the general idea. I hope __{{emoticon}}__ ). Yeah, scripting/programming is strange.
To me it _looks like in a script 10% is the core, and 90% percent is the safety-net (if someone runs it without having enough space, if someone runs it without being root, if, if, if .... If one assumes users know what they do lots could be skipped. But what do i know).
Posts: 9
fsmithred
Joined: 02 Oct 2011
#26
cpulimit will run from within the script. You can start it before starting the command you want to limit, and it'll wait for it. I'll be adding the following code to the next version of refractasnapshot. I've tested this, and it works.

$limit_cpu and $limit are defined in the config file.

Code: Select all

# Copy the filesystem
copy_filesystem () {
if [[ $limit_cpu ="yes" ]] ; then
    cpulimit -e rsync -l"$limit" &
fi
rsync -av / myfs/ --delete-excluded --exclude="$work_dir" \
 --exclude="$snapshot_dir" --exclude-from="$snapshot_excludes" \
 | tee >($DIALOG --title="Copying filesystem..." --progress --pulsate --auto-close --width 300)
}

(snip)

# Squash the filesystem copy
if [[ $limit_cpu ="yes" ]] ; then
    cpulimit -e mksquashfs -l"$limit" &
fi
mksquashfs myfs/ iso/live/filesystem.squashfs ${mksq_opt} \
 | tee >($DIALOG --title="Squashing filesystem..." --progress --pulsate --auto-close --width 300)

pkill cpulimit