[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: 在内存中可以建立 swap 分区吗?



有一个办法可以,就是在swapdisk上建立一个文件,用这个文件做swap文件,具体操作如下:
blueice:/# mkfs.ext3 /dev/ram9
mke2fs 1.39-WIP (10-Dec-2005)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
2048 inodes, 8192 blocks
409 blocks (4.99%) reserved for the super user
First data block=1
1 block group
8192 blocks per group, 8192 fragments per group
2048 inodes per group

Writing inode tables: done
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
blueice:/# mount /dev/ram9 /mnt
blueice:/# cd /mnt
blueice:/mnt# ls
lost+found
blueice:/mnt# dd if=/dev/zero of=ramswap bs=1M count=4
4+0 records in
4+0 records out
4194304 bytes (4.2 MB) copied, 0.056658 seconds, 74.0 MB/s
blueice:/mnt# ls
lost+found  ramswap
blueice:/mnt# mkswap ramswap
Setting up swapspace version 1, size = 4190 kB
no label, UUID=9535fd5a-36d1-45b5-a679-ac0dcd2b5c9c
blueice:/mnt# swapon /mnt/ramswap
blueice:/mnt# swapon -s
Filename                                Type            Size    Used  Priority
/dev/hda5                               partition       2008084 0     -1
/mnt/ramswap                            file            4088    0     -2



在 Thursday 29 December 2005 22:16,Ian Chen 写道:
> swap为的是解决物理内存不足的问题,有足够的物理内存就不需要swap了。反过来,物理内存不足的时候,哪里有物理内存做swap呢?
>
> 2005/12/29, Faris Xiao <atzlinux@163.com>:
> > 我听人说在内存中可以建立 swap 分区,这在某些特殊的应用中可以提供服务器的
> > 效率。
> >
> > 我今天尝试了一下在内存中用 ramdisk 建立 一个swap 分区,没有成功,
> > 不知道大家意见如何?
> >
> > 在内存中可以建立 swap 分区吗?
> >
> > --
> > 肖盛文 (Faris Xiao)
> > Email:atzlinux@163.com
> >
> >
> >
> >
> > --
> > To UNSUBSCRIBE, email to debian-chinese-gb-REQUEST@lists.debian.org
> > with a subject of "unsubscribe". Trouble? Contact
> > listmaster@lists.debian.org

-- 
====================
快乐着你的快乐!
幸福着你的幸福!!
====================

Reply to: