desatan
千年狐狸
千年狐狸
  • UID5373
  • 注册日期2005-04-22
  • 最后登录2008-10-16
  • 发帖数1033
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
阅读:9370回复:20

谁告诉我linux下1G内存怎么花,我都愁死了

楼主#
更多 发布于:2005-12-23 16:20
愁啊,天天看着那么多内存没用,想哭
三翻领
禁止发言
禁止发言
  • UID6501
  • 注册日期2005-06-02
  • 最后登录2017-11-30
  • 发帖数2796
  • 经验-5234枚
  • 威望0点
  • 贡献值-10494点
  • 好评度-5257点
1楼#
发布于:2005-12-23 16:20
用户被禁言,该主题自动屏蔽!
Ryandol
非常火狐
非常火狐
  • UID1379
  • 注册日期2004-12-25
  • 最后登录2019-08-17
  • 发帖数970
  • 经验11枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
2楼#
发布于:2005-12-23 16:20
应该都已经成了cache了吧,我的1G在用suse的时候空闲内存就没有超过100M
刚搞了一个 for Firefox & Opera only 的 Blog:
http://www.onepx.com/
desatan
千年狐狸
千年狐狸
  • UID5373
  • 注册日期2005-04-22
  • 最后登录2008-10-16
  • 发帖数1033
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
3楼#
发布于:2005-12-23 16:20
我的fvwm占内存少
Mr.Bean
火狐狸
火狐狸
  • UID9219
  • 注册日期2005-10-12
  • 最后登录2008-04-13
  • 发帖数116
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
4楼#
发布于:2005-12-23 16:20
三人行,必有我师
Mr.Bean
火狐狸
火狐狸
  • UID9219
  • 注册日期2005-10-12
  • 最后登录2008-04-13
  • 发帖数116
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
5楼#
发布于:2005-12-23 16:20
把/tmp挂到内存里也会改善系统的运行速度
三人行,必有我师
desatan
千年狐狸
千年狐狸
  • UID5373
  • 注册日期2005-04-22
  • 最后登录2008-10-16
  • 发帖数1033
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
6楼#
发布于:2005-12-23 16:20
Mr.Bean:把/tmp挂到内存里也会改善系统的运行速度回到原帖

嗯,早挂啦
desatan
千年狐狸
千年狐狸
  • UID5373
  • 注册日期2005-04-22
  • 最后登录2008-10-16
  • 发帖数1033
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
7楼#
发布于:2005-12-23 16:20
Mr.Bean:拔一条送我吧,哈哈
http://forums.gentoo.org/viewtopic-t-29 ... ocess.html
回到原帖

太感谢,要的就是这个      
都怪自己英文太差,一直找不到这好东东
无聊望见了犹豫
千年狐狸
千年狐狸
  • UID3586
  • 注册日期2005-03-04
  • 最后登录2017-02-12
  • 发帖数1679
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
8楼#
发布于:2005-12-23 16:20
desatan
太感谢,要的就是这个      
都怪自己英文太差,一直找不到这好东东
回到原帖


这个网站跟gwa有愁    

Due to security concerns you can not view this site whilst using Google Web Accelerator. This applies even if you've switch off acceleration for the forums as we have no way of telling.
desatan
千年狐狸
千年狐狸
  • UID5373
  • 注册日期2005-04-22
  • 最后登录2008-10-16
  • 发帖数1033
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
9楼#
发布于:2005-12-23 16:20
copy过来,让看不到它的兄弟姐妹能看到它。
欢迎转载,请遵循GPL协议,转载从:
http://forums.gentoo.org/viewtopic-t-29 ... ocess.html

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 & /sbin

Step 1
Install as normal

Step 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!):
代码:

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 $CURRDIR


Step 3
Now we have to make an initrd to perform the population of our RAM drive before we load init:
代码:

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:
代码:

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.
代码:
mkdir /newroot

Now we have to copy the libraries that each of these binaries needs. You can determine this a la:
代码:

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.2

Here's what I needed in total:
代码:

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

Please 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:
代码:

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 /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


Once that's done, we need to make the device nodes that this will use:
代码:

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  10

You 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
代码:
umount /mnt/initrd


Step 4
Modify /etc/init.d/localmount
代码:
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
代码:

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 /initrd



Step 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:
代码:

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

Putting portage in the RAM drive sure is a nice speedup, tho.
代码:
time /usr/bin/emerge -s mozilla
real    0m3.680s
user    0m2.978s
sys     0m0.131s


Step 7
Finalizing
代码:
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
代码:

##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

#########################
Mr.Bean
火狐狸
火狐狸
  • UID9219
  • 注册日期2005-10-12
  • 最后登录2008-04-13
  • 发帖数116
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
10楼#
发布于:2005-12-23 16:20
三人行,必有我师
三翻领
禁止发言
禁止发言
  • UID6501
  • 注册日期2005-06-02
  • 最后登录2017-11-30
  • 发帖数2796
  • 经验-5234枚
  • 威望0点
  • 贡献值-10494点
  • 好评度-5257点
11楼#
发布于:2005-12-23 16:20
用户被禁言,该主题自动屏蔽!
zlbruce
非常火狐
非常火狐
  • UID5714
  • 注册日期2005-05-05
  • 最后登录2013-05-16
  • 发帖数903
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
12楼#
发布于:2005-12-23 16:20
唉~~~,内存太小了,我的/usr/lib这些东西又太大了,装不进内存中阿,
不过好像只是启动快,运行就没什么差别,那也就无所谓了
desatan
千年狐狸
千年狐狸
  • UID5373
  • 注册日期2005-04-22
  • 最后登录2008-10-16
  • 发帖数1033
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
13楼#
发布于:2005-12-23 16:20
zlbruce:唉~~~,内存太小了,我的/usr/lib这些东西又太大了,装不进内存中阿,
不过好像只是启动快,运行就没什么差别,那也就无所谓了
回到原帖

内存超频
无聊望见了犹豫
千年狐狸
千年狐狸
  • UID3586
  • 注册日期2005-03-04
  • 最后登录2017-02-12
  • 发帖数1679
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
14楼#
发布于:2005-12-23 16:20
desatan:愁啊,天天看着那么多内存没用,想哭回到原帖


想哭就到我…里哭      
上一页
游客

返回顶部