Attenzione: dato che in 2 giorni é stato modificato 22 volte, aspettatevi frequenti aggiornamenti, e se vi accorgete che é stato aggiornato senza che lo sia anche questo, segnalatemelo per favore. Per lo stesso motivo non assicuro niente sul lato della stabilità e della correttezza della procedura.
-------------------------------------
Questo HOWTO é immaginato a partire da questo (ndt: boh... chi mi illumina sul legame tra i due??)
Vuoi montare / nella RAM per un sistema super-veloce?
Qui c'é quello di cui hai bisogno per far volare la tua gentoo
Requisiti:
- Le seguenti directory in partizioni separate:
/usr
/home (se molto pesante o usata per depositare dati)
/root (come per /home)
/var (cosi da evitare di mettere nella RAM i log o la cache di portage)
- una directory chiamata /newroot
- una partizione disponibile per depositarci dentro i tarballs (non può essere root) Magari usa la partizione che é stat / durante l'installazione
- 176MB di RAM disponibili (dipende da quanto si vuole caricare nella RAM)
Il miglioramento di prestazioni é questo (in ordine di importanza):
Code: Select all
/usr/lib
/lib
/usr/bin
/bin
/usr/sbin & /sbinInstalla normalmente
Step 2
Genera i tarballs che vuoi caricare nella RAM.
Salvalo come /sbin/update-balls (controlla che STORE sia montato, e che sia una dir adatta allo scopo):
Code: Select all
#!/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 $CURRDIR Code: Select all
echo /sbin/update-balls >> /etc/conf.d/local.stopAdesso dobbiamo creare un initrd per migliorare l'occupazione del nostro drive RAM prima di caricare init:
Code: Select all
mount /boot #se necessario
touch /boot/initrd
dd if=/dev/zero of=/boot/initrd bs=1024k count=8
losetup /dev/loop0 /boot/initrd
mke2fs /dev/loop0 Code: Select all
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/ Code: Select all
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) Questo é tutto quello di cui abbiamo bisogno:
Code: Select all
ls -R lib
lib:
ld-linux.so.2 libblkid.so.1 libdl.so.2 libuuid.so.1 tls
lib/tls:
libc.so.6 libpthread.so.0 librt.so.1 Code: Select all
#!/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 /proc
mount $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}
EOF Code: Select all
mknod /mnt/initrd/dev/console c 5 1
mknod /mnt/initrd/dev/null c 1 3
mknod /mnt/initrd/dev/hda b 3 0
mknot /mnt/initrd/dev/hda4 b 3 4
mknod /mnt/initrd/dev/hda10 b 3 10 E questo é per l'initrd:
Code: Select all
umount /mnt/initrdModifica /etc/init.d/localmount
Code: Select all
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" Modifica la conf del bootloader (in questo caso grub)
Code: Select all
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 /initrd Se trovi che /usr/lib é troppo grande da mettere nella RAM, magari puoi muovere alcune cose in /usr/local/lib e linkarle, per esempio:
Code: Select all
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
done Code: Select all
time /usr/bin/emerge -s mozilla
real 0m3.680s
user 0m2.978s
sys 0m0.131sFinializziamo
Code: Select all
mv /usr/sbin /usr/.sbin
mv /usr/bin /usr/.bin
mv /usr/lib /usr/.lib
rebootSe vuoi caricare solo alcune applicazioni nella RAM, fai qualcosa del genere:
Code: Select all
##fai questo prima
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
##rimpiazza tutte i binari originali e le librerie con link a /preload/foo
##Quindi metti questo 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







