You are not logged in.

#1 2011-02-09 10:11:54

ah
Member
Registered: 2010-08-15
Posts: 22

frequently written directories to ram, save to hard drive at shutdown?

Is there a program or system that will create a tmpfs in ram that will write frequently used files/directories (like /tmp and /var) to ram and save the final state to hdd at shutdown, thus reducing the number of writes to the hdd? I am interested in using my semi-abundant amount of ram (4gigs) to boost my laptop's battery life by lowering hard drive usage, as ram uses less juice to operate than hdd writes, iirc.

Thanks,
ah

Last edited by ah (2011-02-09 10:14:10)

Offline

#2 2011-02-09 10:17:13

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,354

Re: frequently written directories to ram, save to hard drive at shutdown?

Haven't heard of such a thing. Would be difficult to automate, in any case. Why not just write your own?


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#3 2011-02-09 10:18:27

ah
Member
Registered: 2010-08-15
Posts: 22

Re: frequently written directories to ram, save to hard drive at shutdown?

ngoonee wrote:

Haven't heard of such a thing. Would be difficult to automate, in any case. Why not just write your own?

I was thinking of that, but wasn't sure if it was practical/feasible, i.e. I was wondering if it actually saved energy.

Offline

#4 2011-02-09 10:24:15

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,354

Re: frequently written directories to ram, save to hard drive at shutdown?

ah wrote:
ngoonee wrote:

Haven't heard of such a thing. Would be difficult to automate, in any case. Why not just write your own?

I was thinking of that, but wasn't sure if it was practical/feasible, i.e. I was wondering if it actually saved energy.

It could, but here's some numbers for you.

ngoonee@ngoonee-laptop ~ % du -sh /var
du: cannot read directory `/var/lock/lvm': Permission denied
du: cannot read directory `/var/cache/ldconfig': Permission denied
du: cannot read directory `/var/cache/system-tools-backends/backup': Permission denied
du: cannot read directory `/var/log/samba/cores': Permission denied
du: cannot read directory `/var/log/gdm': Permission denied
du: cannot read directory `/var/lib/openldap': Permission denied
du: cannot read directory `/var/lib/sudo': Permission denied
du: cannot read directory `/var/lib/udisks': Permission denied
du: cannot read directory `/var/lib/locate': Permission denied
du: cannot read directory `/var/lib/dovecot': Permission denied
du: cannot read directory `/var/lib/NetworkManager': Permission denied
du: cannot read directory `/var/lib/polkit-1': Permission denied
du: cannot read directory `/var/lib/gdm': Permission denied
du: cannot read directory `/var/lib/mlocate': Permission denied
du: cannot read directory `/var/run/gdm': Permission denied
du: cannot read directory `/var/run/dovecot/login': Permission denied
du: cannot read directory `/var/run/cups/certs': Permission denied
du: cannot read directory `/var/spool/fcron': Permission denied
du: cannot read directory `/var/spool/cups': Permission denied
6.6G    /var

So /var is bigger than your ram, goody smile. Which is precisely why its not feasible to automate this. /tmp is more feasible.

Whether it saves energy, only if your hard disc actually stops being used, if something else is using the hard disc then no. Note that if you reduce your ram (by using some as tmpfs) you're increasing the possibility for swapping to HD, which defeats the purpose.

Not all programs use /tmp exclusively though. Firefox for one constantly reads/writes into its profile directory (which some people have scripted to run from a tmpfs, google it). Gnome also writes/reads to .gconf, how often I'm not sure.

This is best done app-specific rather than system-wide.


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#5 2011-02-09 10:29:13

ah
Member
Registered: 2010-08-15
Posts: 22

Re: frequently written directories to ram, save to hard drive at shutdown?

I was under the impression that every write was separate, so less of them = less hdd usage, regardless of what else is being used. I realize that loading entire directories into RAM is a Bad Idea, and am wondering if there is a way to load only modified files into RAM, much like how some netbooks have hybrid storage, writing to a solid state drive most times and periodically writing to a hard disk periodically. Or at least that's where this idea was inspired from.

Last edited by ah (2011-02-09 10:29:51)

Offline

#6 2011-02-09 10:37:36

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: frequently written directories to ram, save to hard drive at shutdown?

But what exactly is your problem? I own a decade-old HDD and it's working fine, so unless you use a pendrive for your install you don't have to worry that much.
There are distros that load themselves into RAM and save the modified parts of the system back to the pendrive .e.g http://www.slitaz.org/ but they are much smaller.

Offline

#7 2011-02-09 10:39:42

ah
Member
Registered: 2010-08-15
Posts: 22

Re: frequently written directories to ram, save to hard drive at shutdown?

karol wrote:

But what exactly is your problem? I own a decade-old HDD and it's working fine, so unless you use a pendrive for your install you don't have to worry that much.
There are distros that load themselves into RAM and save the modified parts of the system back to the pendrive .e.g http://www.slitaz.org/ but they are much smaller.

As mentioned in the OP, I am trying to improve laptop battery life. I have used pen drive installs before and they are not what I'm looking for currently.

Last edited by ah (2011-02-09 10:40:13)

Offline

#8 2011-02-09 10:42:51

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: frequently written directories to ram, save to hard drive at shutdown?

ah wrote:

using my semi-abundant amount of ram (4gigs) to boost my laptop's battery life by lowering hard drive usage

Just set up laptop-mode-tools.

The main point is that the hard drives are *stopped* for hopefully an hour or two. Because spinning them takes power (and creates heat), even when they are not reading or writing.

Offline

#9 2011-02-09 10:45:59

ah
Member
Registered: 2010-08-15
Posts: 22

Re: frequently written directories to ram, save to hard drive at shutdown?

brebs wrote:
ah wrote:

using my semi-abundant amount of ram (4gigs) to boost my laptop's battery life by lowering hard drive usage

Just set up laptop-mode-tools.

The main point is that the hard drives are *stopped* for hopefully an hour or two. Because spinning them takes power (and creates heat), even when they are not reading or writing.

Thanks for the pointer. I'm looking into it now. However, I am still interested in implementing this. Also, how insane would I be for disabling syslogd? Again, this would be for less writes to the hdd, less resource usage, and thus more battery life. I've never had a need for logs before and I don't anticipate using them in the near future.

Offline

#10 2011-02-09 10:48:35

pit
Member
From: Wrocław, Poland
Registered: 2010-10-11
Posts: 19
Website

Re: frequently written directories to ram, save to hard drive at shutdown?

You can mount /tmp as tmpfs without any problems.

Also, take a look at this: https://wiki.archlinux.org/index.php/Ch … e_in_tmpfs
And this: https://bbs.archlinux.org/viewtopic.php?id=71097

Offline

#11 2011-02-09 10:50:13

eldragon
Member
From: Buenos Aires
Registered: 2008-11-18
Posts: 1,029

Re: frequently written directories to ram, save to hard drive at shutdown?

this is what i have for my firefox profile.

fstab

firefox /home/tomas/.mozilla/firefox/oqxlxay2.default tmpfs size=64M,noauto,user,exec,uid=1000,gid=100 0 0

/etc/rc.local

sudo -u tomas /home/tomas/.pack_ffox.sh

/etc/rc.local.shutdown

sudo -u tomas /home/tomas/.pack_ffox.sh

crontab

*/10 * * * * /home/tomas/.pack_ffox.sh

and the script itself: .pack_ffox.sh

#!/bin/bash

# Change this to match your correct profile
PROFILE="oqxlxay2.default"
HOME_DIR="/home/tomas"

# echo "${HOME}"
# echo "${HOME_DIR}"

HOME=${HOME_DIR}
cd "${HOME}/.mozilla/firefox"

if test -z "$(mount | grep -F "${HOME}/.mozilla/firefox/${PROFILE}" )"
then
    mount "${HOME}/.mozilla/firefox/${PROFILE}"
fi

if test -f "${PROFILE}/.unpacked"
then
    tar --exclude '.unpacked' -cpf packed.tmp.tar "$PROFILE"
    mv packed.tar packed.tar.old
    mv packed.tmp.tar packed.tar
else
    tar xpf packed.tar &&\
    touch "${PROFILE}/.unpacked"
fi

its self explanatory

i bet this could be daemonized but im fine with it like this.

and the credits goes to someone on the web. if i remembered where i got this, i would post the link directly.

Offline

#12 2011-02-09 10:56:06

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: frequently written directories to ram, save to hard drive at shutdown?

Just as brebs wrote, it's not about minimizing the number reads/writes, but spinning down / stopping your HDD - that's why I suggested doing away with it completely.
A basic Arch setup would load into 4GB RAM easily - even now my / is 3.3 GB. You can cut down to half of that.
I'm not sure if it would work, but have a look at http://code.google.com/p/compcache

Last edited by karol (2011-02-09 10:58:12)

Offline

#13 2011-02-09 11:04:37

ah
Member
Registered: 2010-08-15
Posts: 22

Re: frequently written directories to ram, save to hard drive at shutdown?

karol wrote:

Just as brebs wrote, it's not about minimizing the number reads/writes, but spinning down / stopping your HDD - that's why I suggested doing away with it completely.
A basic Arch setup would load into 4GB RAM easily - even now my / is 3.3 GB. You can cut down to half of that.
I'm not sure if it would work, but have a look at http://code.google.com/p/compcache

Are you suggesting running the root directory completely off of RAM? If so, any pointers to where I would start?

Offline

#14 2011-02-09 11:42:36

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: frequently written directories to ram, save to hard drive at shutdown?

ah wrote:
karol wrote:

Just as brebs wrote, it's not about minimizing the number reads/writes, but spinning down / stopping your HDD - that's why I suggested doing away with it completely.
A basic Arch setup would load into 4GB RAM easily - even now my / is 3.3 GB. You can cut down to half of that.
I'm not sure if it would work, but have a look at http://code.google.com/p/compcache

Are you suggesting running the root directory completely off of RAM? If so, any pointers to where I would start?

We're going in circles :-)
You said you don't want a pendrive install, so it may not suit you. If you're downloading lots of stuff, it won't be perfect either.
Check out some liveCD / liveUSB Arch-based distros: http://wiki.archlinux.org/index.php/Arc … tributions or whip your own.

Offline

#15 2011-02-10 18:53:23

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: frequently written directories to ram, save to hard drive at shutdown?

If you want to put only certain parts of your system in RAM, see https://wiki.archlinux.org/index.php/Ramdisk

Offline

Board footer

Powered by FluxBB