You are not logged in.
I saw this on the gentoo forums.
http://forums.gentoo.org/viewtopic-t-296892.html
Can we do anything like this in arch? I've got 4gigs of ram, so plenty to spare.
I'm also pretty nooby, so please be specific if you can about what commands to run and whatnot.
Here's the original text copied:
I figured this out based on this post:
So you want to mount / in RAM for a super-speedy system?
Here's what you need to make your gentoo FLY/usr must be on it's own partition
/home must be on it's own partition if it's large or you use it for storage
/root must be on it's own partition if you're putting anything big in it
/var on it's own partition (so we don't fill up the RAM drive with logs/portage cache)
an empty directory called /newroot
You must have a partition to store the tarballs on (I use the same partition that ends up being /root) and it can't be /usr.
Maybe use the partition that was / during the install
computer must have a spare 176MB of RAM or so.
(Depends how much you want to load into RAM)
You need to have ramdisk, initial ramdisk, loopback device support in the kernel, not as modules.
These choices can be found under block devices, which is under device drivers.The amount of performance boost in order of magnitude, by which is loaded into RAM seems to be
/usr/lib
/lib
/usr/bin
/bin
/usr/sbin & /sbinStep 1
Install as normalStep 2
generate the tarballs that will populate our RAM drives
put this in /sbin so you can run it should you update your system (make sure STORE is mounted first if applicable!):
Code:echo /sbin/update-balls >> /etc/conf.d/local.stop
chmod +x /sbin/update-balls
cat /sbin/update-balls
##############
#!/bin/sh
CURRDIR=`/bin/pwd`
STORE="root"
cd /
#Exclude anything that's on it's own partition here
tar cfp ${STORE}/fs.tar * --exclude=usr/* --exclude=root/* --exclude=home/* \
--exclude=proc/* --exclude=sys/* --exclude=tmp/* --exclude=var/* \
--exclude=opt/*
cd /usr/
# rm -fr /usr/bin /usr/sbin /usr/lib
# cp -a /usr/.bin /usr/bin
# cp -a /usr/.sbin /usr/sbin
# cp -a /usr/.lib /usr/lib
cd bin && tar cfp /${STORE}/usr_bin.tar *
cd ../sbin && tar cfp /${STORE}/usr_sbin.tar *
cd ../lib && tar cfp /${STORE}/usr_lib.tar *
# rm -fr /usr/bin /usr/sbin /usr/lib
# mkdir /usr/bin /usr/sbin /usr/lib
cd $CURRDIRStep 3
Now we have to make an initrd to perform the population of our RAM drive before we load init:
Code:mount /boot #If necessary
touch /boot/initrd
dd if=/dev/zero of=/boot/initrd bs=1024k count=8
losetup /dev/loop0 /boot/initrd
mke2fs /dev/loop0
Now we have loop0 mounted as the initrd. Time to populate it:
Code:mkdir /mnt/initrd
mount /dev/loop0 /mnt/initrd
cd /mnt/initrd
mkdir etc dev lib bin proc new store
touch linuxrc etc/mtab etc/fstab
chmod +x linuxrc
for I in sh cat mount umount mkdir chroot tar; do cp /bin/$I bin/; done
cp /sbin/pivot_root bin/We need a /newroot directory to hold the initrd after the system's booted.
Code:
mkdir /newrootNow we have to copy the libraries that each of these binaries needs. You can determine this a la:
Code:ldd /bin/sh
linux-gate.so.1 => (0xffffe000)
libdl.so.2 => /lib/libdl.so.2 (0xb7fe2000)
libc.so.6 => /lib/tls/libc.so.6 (0xb7eca000)
/lib/ld-linux.so.2 (0xb7feb000)
means we need /lib/libdl.so.2 /lib/tls/libc.so.6, lib/ld-linux.so.2Here's what I needed in total:
Code:ls -R lib
lib:
ld-linux.so.2 libblkid.so.1 libdl.so.2 libuuid.so.1 tlslib/tls:
libc.so.6 libpthread.so.0 librt.so.1Please check each of your binaries in case you need something I don't. Then we need to write the linuxrc script that does the dirty work:
Code:cat /mnt/initrd/linuxrc
################
#!/bin/sh
export PATH=/bin
STOREDEV=/dev/hda10
STORE=/store
ROOTSIZE=128m# Get kernel CMDLINE
mount -t proc none /proc
CMDLINE=`cat /proc/cmdline`
umount /procmount $STOREDEV $STORE
# Mount root and create read-write directories
mount -t tmpfs -o size=$ROOTSIZE none /new/ > /dev/null 2>&1
cd /new/ && tar xpf $STORE/fs.tar > /dev/null 2>&1
umount $STOREDEV
# Pivot root and start real init
cd /new
pivot_root . newroot
exec chroot . /bin/sh <<- EOF >dev/console 2>&1
exec /sbin/init ${CMDLINE}
EOFOnce that's done, we need to make the device nodes that this will use:
Code:mknod /mnt/initrd/dev/console c 5 1
mknod /mnt/initrd/dev/null c 1 3
mknod /mnt/initrd/dev/hda b 3 0
mknod /mnt/initrd/dev/hda4 b 3 4
mknod /mnt/initrd/dev/hda10 b 3 10You only need the nodes for the mounts that the linuxrc script uses (see /usr/src/linux/Documentation/devices.txt)
And that's it for the initrd
Code:
umount /mnt/initrdStep 4
Modify /etc/init.d/localmount
Code:
start() {
USRBINSIZE=32m
USRSBINSIZE=2m
USRLIBSIZE=256m# Mount local filesystems in /etc/fstab.
ebegin "Mounting local filesystems"
mount -at nocoda,nonfs,noproc,noncpfs,nosmbfs,noshm >/dev/null
eend $? "Some local filesystem failed to mount"ebegin "Mounting RAM filesystems"
mount -t tmpfs -o size=$USRBINSIZE none /usr/bin > /dev/null 2>&1
mount -t tmpfs -o size=$USRSBINSIZE none /usr/sbin > /dev/null 2>&1
mount -t tmpfs -o size=$USRLIBSIZE none /usr/lib > /dev/null 2>&1
cd /usr/bin && tar xpf /root/usr_bin.tar > /dev/null 2>&1
cd /usr/sbin && tar xpf /root/usr_sbin.tar > /dev/null 2>&1
cd /usr/lib && tar xpf /root/usr_lib.tar > /dev/null 2>&1
eend $? "Some RAM filesystems did not mount"Step 5
Modify the bootloader
Code:cat /boot/grub/grub.conf
################
timeout 3
default 0# For booting GNU/Linux from an existing install (rescue)
title Gentoo
root (hd0,0)
kernel /bzImage root=/dev/ram0 rw init=linuxrc video=vesafb:ywrap,pmipal,1024x768-16@70
initrd /initrdStep 6
If you find that /usr/lib is too big to make a reasonable RAM drive, perhaps move some things to /usr/local/lib/ and link them, eg:
Code:cd /usr/lib
for I in perl5 python2.3 portage modules gcc gcc-lib; do
mv $I ../local/lib/
ln -s ../local/lib/$I $I
donePutting portage in the RAM drive sure is a nice speedup, tho.
Code:
time /usr/bin/emerge -s mozilla
real 0m3.680s
user 0m2.978s
sys 0m0.131sStep 7
Finalizing
Code:
mv /usr/sbin /usr/.sbin
mv /usr/bin /usr/.bin
mv /usr/lib /usr/.lib
reboot###########Aside##########
If you just want to load certain applications from a RAM disk, you can do something like the following
Code:##do this in advance
tar cpf /root/preload.tar /usr/bin/firefox /lib/and /lib/all /usr/lib/of /usr/lib/the /lib/raries/ it's/dependent /lib/on
##replace all the original bins and libraries with links to /preload/whatever
##Then put this in /etc/conf.d/local.start
mount -t tmpfs -o size=128m none /preload > /dev/null 2>&1
cd /preload && tar xfp /root/preload.tar#########################
Offline
A flash cachedir is easier and probably just as fast.
Ram disks are limited to one-half of physical ram.
Tmpfs can use swap but ramfs does not.
One solution that uses ram for execution is FaunOS, a USB flash install system which can use install to ram with 600 packages. The cachedir can be another flash drive which loads packages via pacman at good speed into ram via aufs.
No redesign of the system which may negate the pacman system as a side issue.
The sauce in one system is not sauce in another.
My ailment? Lackatesla!
Tesla fails smog test..no gas!
Favorite song...Tesla On My Mind....
Online
Being honest, although it is possible, the use of RAMdisks is no longer needed on modern hardware as the speed of physical disks has improved significantly over recent years. Its use is most beneficial in embedded systems or older hardware where your drive speed is quite low. Don't forget that the OS caches all operations to disk anyway, run xosview (if you have it installed - which you should, it's cool
) and have a look at what is going on. The vast majority of your memory usage will be cached. This is all the apps/files you have opened previously, so when you run something chances are you aren't running it from disk, but rather from RAM anyway.
Offline
I did this on my laptop back in my old gentoo days.
I found it to be a complete waste of time, though there is one pretty awesome advantage to doing this. You get a ton of security for free. Though if you're looking for security, just run things in a VM, not all up in your RAM.
Offline