2

My friend whats to create a 4GB swap file on his ext4 file system. because he is using a chromebook acer c7 the way he installed he did not have a chance to specify swap partition

and now he want to create a swap file on his file system.

This is the guide he is following

http://ubuntuforums.org/showthread.php?t=1618220&p=10098565#post10098565

First you have to create a 2GiB file, for example in /mnt:

sudo dd if=/dev/zero of=/mnt/swap bs=1M count=2048

Then format the file to swap:

sudo mkswap /mnt/swap

Add the swap file to the system:

sudo swapon /mnt/swap

Check it out, i.e.:

free -m

Edit the fstab file:

gksu gedit /etc/fstab

and add this line at the end of the file:

/mnt/swap  none  swap  sw

Save the file and exit. That's all.

This is what he is getting

enter image description here

user@chrubuntu:~$ sudo swapon /mnt/swap
swapon: /mnt/swap: swapon failed: Invalid argument

and his fstab looks like this

fstab

any way to fix this ??

One more thing he is using ubuntu 14.04 and it is not a fresh install

Thank you for your time

Levan
  • 10,880
  • 1
    Does he get the error you've mentioned both times he tries to run swapon, or just after he's added it to the fstab file? – jkt123 May 04 '14 at 21:25
  • 1
    @Levan the fstab file doesn't have the /mnt/swap none swap sw at the end of the file. Save the file after editing. – Elder Geek May 04 '14 at 21:27
  • Thank you for the reply he follows the above guide that i mantioned

    before this step every thing works Add the swap file to the system:

    sudo swapon /mnt/swap

    http://imgur.com/rFP0gbc

    – Levan May 04 '14 at 21:30
  • 2
    Is this system running a custom kernel? What does uname -a show? – psusi May 04 '14 at 22:47
  • @psusi Thank you for the reply again this is what it say ser@chrubuntu:~$ uname -a Linux chrubuntu 3.4.0 #1 SMP Fri Apr 11 19:07:10 PDT 2014 x86_64 x86_64 x86_64 GNU/Linux user@chrubuntu:~$ – Levan May 04 '14 at 22:52
  • @psusi I have a question, what do you think if he manually upgrades to the latest kernel?? will his chrome book still boot or it is too dangerous – Levan May 04 '14 at 23:05
  • 1
    I don't know enough about it, but it certainly appears to have a custom, older, kernel, but if you check its config file in /boot, you may find that it was built without CONFIG_SWAP, so doesn't support swap. – psusi May 05 '14 at 02:07
  • @psusi thank you you have been tremendous help, crazy thing is that he can not even upgrade to a newer kernel – Levan May 05 '14 at 11:16

2 Answers2

1

It's possible the problem is because it's in the /mnt directory or it could be a security issue world readable swap isn't great. Try this tutorial and see if you have better results.

http://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/

Elder Geek
  • 36,023
  • 25
  • 98
  • 183
0

swapon failed: Invalid argument

Based on this discussion and this post, most likely your file system doesn't support swap files.

You need to create it somewhere outside of /mnt, as part of the native filesystem (e.g. in /var).

Try following these steps instead.

kenorb
  • 10,347