开发者

mkswap fails to create a file

I was attempting to create a swap file:

  mkswap -f /var/swap

I get "/var/swap No such file or directory"

Am I supposed to create the file first? The documentation I found does not 开发者_开发问答say that, so I am concerned.


Yes, you'll need to create the file first. dd is the standard choice:

dd if=/dev/zero of=/var/swap bs=1024 count=131072
mkswap /var/swap
swapon

this'd create a 128meg swap file.


Normally you run mkswap on a partition, not a file. Since one wouldn't expect it to edit the partition table for you, it's written to expect the target to already exist.


Snip from man mkswap:

To set up a swap file, it is necessary to create that file before initializing it with mkswap, e.g. using a command like

          # dd if=/dev/zero of=swapfile bs=1024 count=65536

The "-f" option to mkswap is a bit dangerous too, it's "force". Try it without first...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜