I tried to create some swap files in /dev directory for my desktop. the dd and mkswap were ok. but when I try to swapon it, i get this: # swapon /dev/myswap swapon: /dev/myswap: Invalid argument but when I mv the file to some other directory like /mnt or /, the swapon works. could sb. tell me why? -- Tang Jianwei
2010/7/6 Tang Jianwei <myhnet at gmail.com>:> I tried to create some swap files in /dev directory for my desktop. > the dd and mkswap were ok. but when I try to swapon it, i get this: > > # swapon /dev/myswap > swapon: /dev/myswap: Invalid argument > > but when I mv the file to some other directory like /mnt or /, the > swapon works./dev/* is virtual directory containing all devices, not files. create your swap on disk devices (/dev/sdXX, not in "empty space) -- Eero, RHCE
On 07/06/2010 12:41 PM, Tang Jianwei wrote:> I tried to create some swap files in /dev directory for my desktop. > the dd and mkswap were ok.Does the file exist after reboot? I think the /dev directory is made in a RAM disk (tmpfs), not a useful place to put a swapfile. Mogens -- Mogens Kjaer, mk at lemo.dk http://www.lemo.dk
At Tue, 06 Jul 2010 18:41:06 +0800 CentOS mailing list <centos at centos.org> wrote:> > I tried to create some swap files in /dev directory for my desktop. > the dd and mkswap were ok. but when I try to swapon it, i get this: > > # swapon /dev/myswap > swapon: /dev/myswap: Invalid argument > > but when I mv the file to some other directory like /mnt or /, the > swapon works. > > could sb. tell me why?/dev is mounted from a *ramdisk* -- swapping to a RAM disk makes really no sense. With a modern (eg 2.6 kernel w/udev), /dev is created fresh at boot time and only contains device node files, generally created on-the-fly by udevd.>-- Robert Heller -- Get the Deepwoods Software FireFox Toolbar! Deepwoods Software -- Linux Installation and Administration http://www.deepsoft.com/ -- Web Hosting, with CGI and Database heller at deepsoft.com -- Contract Programming: C/C++, Tcl/Tk
On Tue, Jul 06, 2010 at 06:41:06PM +0800, Tang Jianwei wrote:> I tried to create some swap files in /dev directory for my desktop. > the dd and mkswap were ok. but when I try to swapon it, i get this: > > # swapon /dev/myswap > swapon: /dev/myswap: Invalid argument > > but when I mv the file to some other directory like /mnt or /, the > swapon works. > > could sb. tell me why?/dev is not a real directory for data files. You should actually make a separate partition for swap Otherwise, you can put it in some real file spaca such as in /usr or where you left a lot of space. That is often done to increase available swap space when the originally created swap partition is not large enough - add some from file space. ////jerry> > -- > Tang Jianwei > > _______________________________________________ > CentOS mailing list > CentOS at centos.org > http://lists.centos.org/mailman/listinfo/centos