October 16, 2004

咸鱼翻身之运行时改变Linux的交换文件

Categories:  Linux

我的Libretto(见以前的《咸鱼翻身》系列)只有32M的内存,安装Debian的时候配置了64M的交换分区。使用的过程中发现有时会在apt-get upgrade/install的时候内存不够用,而且用光交换分区空间的情况,导致无法正确安装、升级软件包。我用下面的方法解决这个问题:

1、使用dd命令建立一个文件,作为交换文件;
2、使用mkswap命令初始化上一步中建立的文件;
3、使用swapon命令激活交换文件,这样交换空间就是原有交换分区的容量加上新建的交换文件的容量;
4、进行耗费内存的操作;
5、根据需要可以使用swapoff关闭交换文件,并删除文件节省磁盘空间。

下面是操作的例子:

# dd if=/dev/zero of=/tmp/swapfile bs=1024 count=65536
# mkswap /tmp/swapfile
# swapon /tmp/swapfile
# ...
# swapoff /tmp/swapfile
# rm /tmp/swapfile
Posted by dumm at October 16, 2004 01:28 AM
Comments
Post a comment









Remember personal info?




  
Please enter the code as seen in the image above to post your comment.