You are not logged in.

#1 2008-06-29 12:31:51

Barrucadu
Member
From: Hull, England
Registered: 2008-03-30
Posts: 1,157
Website

Jiggery pokery

What jiggery pokery have you done to your Arch system to make it faster? I've just devised and implemented a cunning plan to make pacman/abs faster by using a ramdisk.

/etc/fstab:

#
# /etc/fstab: static file system information
#

none        /dev/pts     devpts  defaults              0 0
none        /dev/shm     tmpfs   defaults              0 0

#/dev/cdrom /mnt/cdrom   iso9660 ro,user,noauto,unhide 0 0
#/dev/dvd   /mnt/dvd     udf     ro,user,noauto,unhide 0 0
#/dev/fd0   /mnt/fd0     vfat    user,noauto           0 0

/dev/sda1   /mnt/media   jfs     defaults              0 0
/dev/sdb1   /boot        ext2    defaults              0 1
/dev/sdb2   swap         swap    defaults              0 0
/dev/sdb3   /            ext3    defaults              0 1
/dev/sdb4   /home        ext3    defaults              0 1

ramfs       /mnt/ramdisk ramfs   defaults              0 0

/etc/rc.local:

#!/bin/dash
#
# /etc/rc.local: Local multi-user startup script.
#

echo 0 > /proc/sys/vm/swappiness
echo 1 > /proc/sys/kernel/sysrq

# Ramdisk Magic!
touch /etc/ramdisk.sh
echo "#!/bin/dash" >> /etc/ramdisk.sh
echo "mkdir /mnt/ramdisk/var/" >> /etc/ramdisk.sh
echo "mkdir /mnt/ramdisk/var/cache/" >> /etc/ramdisk.sh
echo "mkdir /mnt/ramdisk/var/lib/" >> /etc/ramdisk.sh
echo "mv /var/abs /mnt/ramdisk/var" >> /etc/ramdisk.sh
echo "mv /var/cache/pacman /mnt/ramdisk/var/cache" >> /etc/ramdisk.sh
echo "mv /var/lib/pacman /mnt/ramdisk/var/lib" >> /etc/ramdisk.sh
echo "ln -s /mnt/ramdisk/var/abs /var/abs" >> /etc/ramdisk.sh
echo "ln -s /mnt/ramdisk/var/cache/pacman /var/cache/pacman" >> /etc/ramdisk.sh
echo "ln -s /mnt/ramdisk/var/lib/pacman /var/lib/pacman" >> /etc/ramdisk.sh
echo "rm /etc/ramdisk.sh" >> /etc/ramdisk.sh
chmod +x /etc/ramdisk.sh
/etc/ramdisk.sh &

/etc/rc.local.shutdown:

#!/bin/dash
#
# /etc/rc.local.shutdown: Local shutdown script.
#

# Ramdisk Magic!

echo "Saving contents of ramdisk to harddrive"
rm /var/abs
rm /var/cache/pacman
rm /var/lib/pacman
mv /mnt/ramdisk/var/abs /var
mv /mnt/ramdisk/var/cache/pacman /var/cache
mv /mnt/ramdisk/var/lib/pacman /var/lib

The only downsides are that shutdown takes a bit longer, which doesn't bother me as long as it doesn't take ages, and abs/pacman aren't available straight after booting as there is a slight delay, however as I don't sync abs or update pacman immediately that's not a problem. has anyone else done something interesting with ramdisks? I have 2GB of RAM and am rarely using over 512MB or so, so I have plenty of room to experiment in.

Last edited by Barrucadu (2008-06-29 13:15:11)

Offline

#2 2008-06-29 13:31:27

Gullible Jones
Member
Registered: 2004-12-29
Posts: 4,863

Re: Jiggery pokery

My fstab:

none                   /dev/pts      devpts    defaults            0      0
none                   /dev/shm      tmpfs     defaults            0      0
tmpfs                  /tmp          tmpfs     defaults            0      0

/dev/sda1 / ext3 defaults,noatime 0 1
/dev/sda3 /var ext3 defaults,noatime 0 1
/dev/sda4 /home ext3 defaults,noatime 0 1
/dev/sda2 swap swap defaults 0 0

The third line makes the system use RAM for storing temp files. What with a gigabyte of swap space, this is not a problem.

Offline

#3 2008-06-29 13:34:15

Barrucadu
Member
From: Hull, England
Registered: 2008-03-30
Posts: 1,157
Website

Re: Jiggery pokery

I just checked my disk usage on /tmp, and it's not that much. I think I'll stick than on my ramdisk too smile
However, free doesn't seem to report the RAM taken up by these files I'm sticking in it. It possibly is, but it's such a small fraction I'm not noticing. Oh well, I can always manually check the size of /mnt/ramdisk if unsure.

Last edited by Barrucadu (2008-06-29 13:35:19)

Offline

#4 2008-06-29 14:30:21

pogeymanz
Member
Registered: 2008-03-11
Posts: 1,008

Re: Jiggery pokery

You guys get a giant thumbs up from me! Once I get a little more RAM I'll try this out.

Offline

#5 2008-06-29 15:21:11

patogen
Member
Registered: 2008-05-11
Posts: 86

Re: Jiggery pokery

Barrucadu wrote:

What jiggery pokery have you done to your Arch system to make it faster? I've just devised and implemented a cunning plan to make pacman/abs faster by using a ramdisk ... [lots of text]

Seems nice, however you can  change:

echo 0 > /proc/sys/vm/swappiness
echo 1 > /proc/sys/kernel/sysrq

To:
kernel.sysrq = 1
vm.swappiness=0

In /etc/sysctl.conf so it's permanent. At least I think they are equivalent to what you are doing.


We met up with the aliens and guess what? They have no word for fluffy!

Offline

#6 2008-06-29 15:58:39

JeremyTheWicked
Member
From: Poland
Registered: 2008-05-23
Posts: 193

Re: Jiggery pokery

What does kernel.sysrq = 1 do?


arch(3) adj amused because you think you understand something better than other people ;P

Offline

#7 2008-06-29 16:09:46

Redroar
Member
Registered: 2008-03-17
Posts: 200

Re: Jiggery pokery

Oooh. Sweet stuff, I gotta do this with my most used programs, pacman, tmp...I got 2 gigs to play in, and hardly ever exceed 300 megabytes when I'm doing quite a bit of stuff. Muchas gracias for the info, Barracadu. You should add it to the wiki.


Stop looking at my signature. It betrays your nature.

Offline

#8 2008-06-29 16:21:41

Barrucadu
Member
From: Hull, England
Registered: 2008-03-30
Posts: 1,157
Website

Re: Jiggery pokery

Redroar wrote:

Muchas gracias for the info, Barracadu. You should add it to the wiki.

I didn't know I was that helpful big_smile
Added: http://wiki.archlinux.org/index.php/Ramdisk

Offline

#9 2008-06-29 16:50:06

patogen
Member
Registered: 2008-05-11
Posts: 86

Re: Jiggery pokery

JeremyTheWicked wrote:

What does kernel.sysrq = 1 do?

Enables the magic sysrq button (usuallly on your print screen button). Check wiki for info:

http://en.wikipedia.org/wiki/Magic_SysRq_key

If your computer locks up you can do a safe reboot.


We met up with the aliens and guess what? They have no word for fluffy!

Offline

#10 2008-06-29 18:10:33

czar
Member
Registered: 2008-03-08
Posts: 115

Re: Jiggery pokery

If your computer doesn't shutdown properly due to power outage or the like, will you lose your pacman cache? Or am i missing somthing?
I'm very interested in finding some use for the 75% of my ram that never gets touched. What else is useful to copy to a ramdisk?

Last edited by czar (2008-06-29 18:12:23)

Offline

#11 2008-06-29 18:13:02

Barrucadu
Member
From: Hull, England
Registered: 2008-03-30
Posts: 1,157
Website

Re: Jiggery pokery

Yes, which is why backing up is important. I added three lines to backup /var/abs, /var/lib/pacman, and /var/cache/pacman before moving them to RAM.

Offline

#12 2008-06-29 19:05:04

Procyon
Member
Registered: 2008-05-07
Posts: 1,807

Re: Jiggery pokery

Why do you move it and not copy it? Isn't the disk usage the same since it's different partitions?

And at shutdown you could check for duplicates, maybe if it's one archive or loopback device.

e.g.
tar cf /var/abs.tar /var/abs
rm -R /var/abs
in rc.local:
cp /var/abs.tar /mnt/ramdisk/
tar xf /mnt/ramdisk/abs.tar
ln -s /mnt/ramdisk/abs /var/abs
in rc.shutdown:
tar cf /mnt/ramdisk/newabs.tar /mnt/ramdisk/abs
md5sum /mnt/ramdisk/newabs.tar
md5sum /mnt/ramdisk/abs.tar
(insert auto compare script... probably, just du might be enough, not md5sum)
if different; then cp /mnt/ramdisk/newabs.tar /var/abs.tar; fi

Last edited by Procyon (2008-06-29 19:05:58)

Offline

#13 2008-06-29 20:50:01

Redroar
Member
Registered: 2008-03-17
Posts: 200

Re: Jiggery pokery

Just out of curiosity, why do you have the whole thing in rc.local, then echo it into ramdisk.sh? Wouldn't it just be easier to maintain it seperately, rather than creating/deleting it at every boot?


Stop looking at my signature. It betrays your nature.

Offline

#14 2008-06-29 21:35:00

Barrucadu
Member
From: Hull, England
Registered: 2008-03-30
Posts: 1,157
Website

Re: Jiggery pokery

I like my system being neat - rc.local is for things happening after boot, so I want to only have to look in there to edit things relating to that.

Offline

#15 2008-06-30 01:35:54

Redroar
Member
Registered: 2008-03-17
Posts: 200

Re: Jiggery pokery

Ok, just making sure that it was not something that was going over my head somehow. I prefer to have clean config files, with each complex task residing in it's own space, but to each his own. I gotta try this out.


Stop looking at my signature. It betrays your nature.

Offline

#16 2008-07-01 15:38:13

czar
Member
Registered: 2008-03-08
Posts: 115

Re: Jiggery pokery

i edited my fstab but i don't seem to get a ramfs on reboot. Where am i going wrong?

# /etc/fstab: static file system information
#
# <file system>        <dir>         <type>    <options>          <dump> <pass>
none                   /dev/pts      devpts    defaults            0      0
none                   /dev/shm      tmpfs     defaults            0      0


/dev/cdrom /mnt/cdrom   iso9660   ro,user,noauto,unhide   0      0
/dev/cdrom1 /mnt/cdrom1   iso9660   ro,user,noauto,unhide   0      0
/dev/dvd /mnt/dvd   udf   ro,user,noauto,unhide   0      0
/dev/dvd1 /mnt/dvd1   udf   ro,user,noauto,unhide   0      0
/dev/sda2 /boot vfat defaults 0 1
/dev/sda3 / ext3 defaults 0 1
/dev/sda4 swap swap defaults 0 0
/dev/sda1 /mnt/windows ntfs-3g defaults,locale=en_PH.utf8 0 0
ramfs       /mnt/ramdisk ramfs   defaults              0 0

Offline

#17 2008-07-01 16:04:18

Barrucadu
Member
From: Hull, England
Registered: 2008-03-30
Posts: 1,157
Website

Re: Jiggery pokery

Did you make the folder /mnt/ramdisk? If you did, and if you can write to it, it worked.

Offline

#18 2008-07-01 18:34:14

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: Jiggery pokery

Perhaps instead of using rm and mv for the backups, just use rsync. It should be faster for this.

Offline

#19 2008-07-04 15:54:32

faelar
Member
From: Amiens (FR)
Registered: 2007-12-18
Posts: 232
Website

Re: Jiggery pokery

Hi, I tried to set ramfs type for /tmp
If I save my fstab with something like :

none /tmp ramfs defaults 0 0

my files-manager (pcmanfm) doesn't load.
There is no error output when launched from urxvt, but the window isn't display, and there's no process running.
I also have HAL started on boot to auto-mount disks.
Do you think pcmanfm fail because is trying to browse /tmp ?

I can reproduce it, tell me if you need extra information.

Offline

#20 2008-07-04 16:14:21

Barrucadu
Member
From: Hull, England
Registered: 2008-03-30
Posts: 1,157
Website

Re: Jiggery pokery

You need to chmod /tmp to 777, otherwise graphical programs probably won't work.

Offline

#21 2008-07-04 16:27:55

faelar
Member
From: Amiens (FR)
Registered: 2007-12-18
Posts: 232
Website

Re: Jiggery pokery

Right, I missed this in the wiki, now it works smile

Offline

#22 2008-07-04 16:40:55

Asgaroth
Member
From: Hesse, Germany
Registered: 2008-03-26
Posts: 58

Re: Jiggery pokery

Barrucadu wrote:

I like my system being neat - rc.local is for things happening after boot, so I want to only have to look in there to edit things relating to that.

It would be a lot more readable to use 'heredoc's though:

cat <<EOF > /etc/whereever.sh
<code for the script>
EOF

Nice work though, thanks for that.

Last edited by Asgaroth (2008-07-04 16:41:42)

Offline

#23 2008-07-04 18:00:20

u_no_hu
Member
Registered: 2008-06-15
Posts: 453

Re: Jiggery pokery

May be a stupid question....
Whats the advantage of using ramfs with pacman? for me the only thing that takes some time is downloading file (75kbps connection :-( and they sell it as broadband here) ....after that its pretty quick ....


Don't be a HELP VAMPIRE. Please search before you ask.

Subscribe to The Arch Daily News.

Offline

#24 2008-07-06 15:20:33

czar
Member
Registered: 2008-03-08
Posts: 115

Re: Jiggery pokery

Searching for packages is much faster off of ramfs. Just about instant.

Offline

#25 2008-07-06 15:55:57

Asgaroth
Member
From: Hesse, Germany
Registered: 2008-03-26
Posts: 58

Re: Jiggery pokery

czar wrote:

Searching for packages is much faster off of ramfs. Just about instant.

Depending on your harddisk that's pretty fast anyway, so no real speed benefit for me.
With reiserfs and luks hdd-encryption(and pacman-cage, the "device-file" is formatted with ext2):

$> time pacman -Ss pacman
...
pacman -Ss pacman  0,21s user 0,16s system 97% cpu 0,375 total

Last edited by Asgaroth (2008-07-06 22:22:07)

Offline

Board footer

Powered by FluxBB