阅读:9809回复:20
谁告诉我linux下1G内存怎么花,我都愁死了
愁啊,天天看着那么多内存没用,想哭
|
|
1楼#
发布于:2005-12-23 16:20
用户被禁言,该主题自动屏蔽! |
|
2楼#
发布于:2005-12-23 16:20
应该都已经成了cache了吧,我的1G在用suse的时候空闲内存就没有超过100M
|
|
|
3楼#
发布于:2005-12-23 16:20
我的fvwm占内存少
|
|
4楼#
发布于:2005-12-23 16:20
|
|
|
5楼#
发布于:2005-12-23 16:20
把/tmp挂到内存里也会改善系统的运行速度
|
|
|
6楼#
发布于:2005-12-23 16:20
|
|
7楼#
发布于:2005-12-23 16:20
Mr.Bean:拔一条送我吧,哈哈 太感谢,要的就是这个 都怪自己英文太差,一直找不到这好东东 |
|
8楼#
发布于:2005-12-23 16:20
|
|
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 ######################### |
|
10楼#
发布于:2005-12-23 16:20
|
|
|
11楼#
发布于:2005-12-23 16:20
用户被禁言,该主题自动屏蔽! |
|
12楼#
发布于:2005-12-23 16:20
唉~~~,内存太小了,我的/usr/lib这些东西又太大了,装不进内存中阿,
不过好像只是启动快,运行就没什么差别,那也就无所谓了 |
|
13楼#
发布于:2005-12-23 16:20
|
|
14楼#
发布于:2005-12-23 16:20
|
|
上一页
下一页