You are not logged in.

#1 2015-03-30 18:55:13

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,930
Website

Old laptop want to run swapfile [Solved]

Currently running arch on a usb device as my old laptop hard drive is failing. Boots and runs ok but does lag from time to time. So thought I would try a swapfile as it only has a gig of ram.. Created swapfile without a problem, ran mkswap but swap on failed. On boot systemd is complaining, am guessing that I need to activate a service so systemd sees swap?

Never really used swap before so am in the dark about using it.

Have thought about adding some more options too fstab to boost f2fs performance, possibly discard.

Last edited by Mr Green (2015-04-01 06:57:42)


Mr Green

Offline

#2 2015-03-30 20:38:53

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: Old laptop want to run swapfile [Solved]

Did you add the fstab entry for your swapfile?
https://wiki.archlinux.org/index.php/Swap#Swap_file

systemd should activate swap automatically.

Also, "discard" will reduce performance as the device will attempt to TRIM continuously; try the fstrim.timer instead:
https://wiki.archlinux.org/index.php/So … md_service

Check your USB device will actually support TRIM first:
https://wiki.archlinux.org/index.php/So … IM_Support


Jin, Jîyan, Azadî

Offline

#3 2015-03-31 05:48:03

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,930
Website

Re: Old laptop want to run swapfile [Solved]

Did add too fstab, only on boot I get an error from systemd (will post later). As I said swapon command failed for some reason. Will look at trim and if usb is supported.


Mr Green

Offline

#4 2015-03-31 06:42:03

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,930
Website

Re: Old laptop want to run swapfile [Solved]

[mrgreen@ArchUsb ~]$ dmesg | grep swap
[    9.285635] systemd[1]: Activating swap /swapfile...
[   10.796658] swapon: swapfile has holes
[   10.797528] systemd[1]: swapfile.swap swap process exited, code=exited status=255
[   10.798377] systemd[1]: Failed to activate swap /swapfile.
[   10.798926] systemd[1]: Job swap.target/start failed with result 'dependency'.
[   10.798949] systemd[1]: Unit swapfile.swap entered failed state.

Fstab

# Swap
/swapfile                                       none     swap           defaults,pri=10 0 0

Error

swapon /swapfile
swapon: /swapfile: swapon failed: Invalid argument

Mr Green

Offline

#5 2015-03-31 07:21:49

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: Old laptop want to run swapfile [Solved]

Did you follow all the steps in the ArchWiki page I linked (eg, `chmod 600 /swapfile`)?

Try removing the "pri=10" bit from the options in your fstab line.

What is the output of:

systemctl --all --no-pager|grep swap

Jin, Jîyan, Azadî

Offline

#6 2015-03-31 07:29:06

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,930
Website

Re: Old laptop want to run swapfile [Solved]

did the chmod, but will double check, thanks


Mr Green

Offline

#7 2015-03-31 17:51:30

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,930
Website

Re: Old laptop want to run swapfile [Solved]

[mrgreen@ArchUsb ~]$ systemctl --all --no-pager|grep swap
● swapfile.swap                                                                                                      loaded    failed   failed    /swapfile
  swap.target                                                                                                        loaded    inactive dead      Swap
[mrgreen@ArchUsb ~]$ 

Have removed 'pri=10'


Mr Green

Offline

#8 2015-03-31 18:25:03

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: Old laptop want to run swapfile [Solved]

How about:

systemctl status swapfile.swap
systemctl status swap.target

As they are failed units, this will output a suggestion to check another command output (can't remember what as I haven't had any failed units for a while): post the output of that command as well plz.

Also, how did you create the swapfile?


Jin, Jîyan, Azadî

Offline

#9 2015-03-31 19:07:47

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,930
Website

Re: Old laptop want to run swapfile [Solved]

I followed wiki page:

fallocate -l 512M /swapfile

Made mine 2G...


Mr Green

Offline

#10 2015-03-31 19:14:00

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: Old laptop want to run swapfile [Solved]


Jin, Jîyan, Azadî

Offline

#11 2015-03-31 19:24:47

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,930
Website

Re: Old laptop want to run swapfile [Solved]

f2fs ---

mrgreen@ArchUsb ~]$ systemctl status swapfile.swap
● swapfile.swap - /swapfile
   Loaded: loaded (/etc/fstab)
   Active: failed (Result: exit-code) since Tue 2015-03-31 20:18:13 BST; 6min ago
     What: /swapfile
     Docs: man:fstab(5)
           man:systemd-fstab-generator(8)
  Process: 135 ExecActivate=/sbin/swapon /swapfile (code=exited, status=255)

Mr Green

Offline

#12 2015-03-31 19:25:47

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,930
Website

Re: Old laptop want to run swapfile [Solved]

[mrgreen@ArchUsb ~]$ systemctl status swap.target
● swap.target - Swap
   Loaded: loaded (/usr/lib/systemd/system/swap.target; static; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:systemd.special(7)

Mr Green

Offline

#13 2015-03-31 19:30:15

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: Old laptop want to run swapfile [Solved]

Sorry, you did mention f2fs and of course systemd will fail trying to activate the swapfile if `swapon` failed... hmm

Perhaps f2fs doesn't support swapfiles.


Jin, Jîyan, Azadî

Offline

#14 2015-03-31 20:49:34

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,930
Website

Re: Old laptop want to run swapfile [Solved]

I can check by using internal hard drive (ext4)....


Mr Green

Offline

#15 2015-03-31 20:55:01

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,930
Website

Re: Old laptop want to run swapfile [Solved]

It might be that f2fs does not support swapfiles, swap partition might work will have to test and see...time to break out gparted :-)


Mr Green

Offline

#16 2015-04-01 07:01:23

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,930
Website

Re: Old laptop want to run swapfile [Solved]

Well f2fs does support swapfiles and does not allow partition resizing. I stuck a small swap partition on laptops internal drive and set up as per Arch Wiki

[mrgreen@ArchUsb ~]$ swapon -s
Filename				Type		Size	Used	Priority
/dev/sda2                              	partition	2047996	0	-1
[mrgreen@ArchUsb ~]$ free -h
              total        used        free      shared  buff/cache   available
Mem:           1.5G         55M        1.3G        524K        113M        1.3G
Swap:          2.0G          0B        2.0G

Running from usb does lag from time to time, opening firefox took forever...[I can replace with something lighter in the near future]

Thanks for all your help


Mr Green

Offline

Board footer

Powered by FluxBB