LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-18-2019, 03:08 AM   #1
mackowiakp
Member
 
Registered: Jun 2014
Location: Poland/Gdynia
Distribution: Mageia 9, SH4, Debian
Posts: 367

Rep: Reputation: 8
FSTAB adding file as swap


I created on nanoPI (Ubuntu Xenial) swap file on attached USB SSD HDD partition (not seperate partition but already existing) using such commands:

Code:
$ dd if=/dev/zero of=/path/to/swapfile bs=1M count=1024 # For 1GB swap file
$ mkswap /path/to/swapfile
$ swapon /path/to/swapfile
And set in /etc/sysctl.conf

Code:
vm.swappiness = 10
My current /etc/fstab file looks like this:

Code:
LABEL=DYSK /home/pi/domoticz ext4 defaults,noatime,rw 1 2
/home/pi/domoticz/log /var/log none rw,bind 0 0
LABEL=4TB /home/pi/4TB ext4 defaults,noauto,noatime,rw 0 0
tmpfs /home/pi/ramdisk tmpfs nodev,nosuid,noexec,nodiratime,size=150K,uid=pi,gid=pi 0 0
tmpfs /var/LOG tmpfs nodev,nosuid,size=10M 0 0
media:/TMP /home/pi/MEDIA nfs rw,noauto,soft 0 0
Where LABEL=DYSK is related to /dev/sda1, that is 120 GB SSD HDD (connected via USB).

My question is. What is the proper syntax of entry in /etc/fstab for swap file (not partition) to be mounted automatically during boot time?
 
Old 03-18-2019, 03:40 AM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
https://askubuntu.com/questions/1260...p-after-reboot

By the way, according to this page it's best not to use an SSD for file swapping. I am not sure why; I guess it must have something to do with wear and tear.
 
Old 03-18-2019, 04:48 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,133

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
Maybe in days of yore - no longer a consideration with modern SSD.

However, the OP has been deliberately vague as to where the swap is located - let's guess it's under /home. Timing/race problems likely await.
Then again to my eye, the entire fstab schema is somewhat bizarre, but to each his own ... :shrug:
 
Old 03-18-2019, 09:03 AM   #4
tyler2016
Member
 
Registered: Sep 2018
Distribution: Debian, CentOS, FreeBSD
Posts: 243

Rep: Reputation: Disabled
Code:
/path/to/file none            swap    sw              0       0
You might want to add a _netdev to your options to make sure that the file is available. The _netdev option means to wait until the network is available before trying to use the swap file. If it is a systemd based system, you can play around with the unit files to ensure the filesystem the swap file is on is up before it attempts to activate your swap file.
 
1 members found this post helpful.
  


Reply

Tags
fstab, swapfile, ubuntu



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
swap file vs. swap partition verndog Ubuntu 16 07-09-2012 08:49 PM
[SOLVED] Adding entries in /etc/fstab for swap in Ec2 servers call_krushna Linux - Server 6 01-19-2012 10:18 AM
swap file instead of swap disk "dd" error rezwits Linux - Newbie 5 12-16-2007 12:34 AM
Need Help Increasing Swap by creating a swap file froggo Red Hat 3 06-13-2006 08:04 AM
Adding more SWAP after adding memory marc1978 Linux - General 6 03-19-2006 07:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration