[SOLVED] How to create a swap partition after the installation of Linux (deepin)
Tofloor
poster avatar
Blogghete
deepin
2018-05-25 02:31
Author
Edited by Blogghete at 2018-5-28 17:37

[SOLVED] How to create a swap partition after the installation of Linux (deepin)

I have installed deepin.
Because of the freezes of the operating system, I opted for a swap partition.

Can I create it?
And if yes, how to do it?

Many thanks in advance.


== SOLUTION ==

The solution is to create a swap file instead of a swap partition. It is very easy:
# create a swap file of 2GB (swap size)
sudo fallocate -l 2G /var/swapfile

# reset file permissions
sudo chmod 600 /var/swapfile

# activate the swap file (1 of 2)
sudo /sbin/mkswap /var/swapfile

# activate the swap file (2 of 2)
sudo swapon /var/swapfile

# edit the /etc/fstab file to add an entry for the swap file to activate swap file permanently
sudo gedit /etc/fstab
replace the similar existing row with the following:
/var/swapfile none swap defaults 0 0

Save the file.

the details of swap file information can be found in https://wiki.archlinux.org/index.php/Swap




Reply Favorite View the author
All Replies
152******14
deepin
2018-05-25 05:41
#1
https://bbs.deepin.org/post/133470交换分区

https://bbs.deepin.org/post/39614

看看能不能解决你的问题 英语不好,这是借助谷歌翻译看的。
Reply View the author
Blogghete
deepin
2018-05-25 05:44
#2
https://bbs.deepin.org/post/156953
https://bbs.deepin.org/post/133470#交换分区

https://bbs.deepin.or ...

Many thanks in advance.
Can you translate the Chinese documents?
Reply View the author
152******14
deepin
2018-05-25 05:54
#3
https://bbs.deepin.org/post/156953
Many thanks in advance.
Can you translate the Chinese documents?

你 把 文件 复制到记事本上  然后用谷歌浏览器打开  。会提示你要不要翻译,点击确定  可以当做网页一样整本翻译。举例子,我一般是把 外文复制到 记事本 选择打开方式谷歌浏览器  会提示我 是否翻译,点击确定  ,整篇都给我翻译成中文了。
Reply View the author
许自强
deepin
Ecological co-builder
2018-05-25 07:21
#4
https://bbs.deepin.org/post/156953
Many thanks in advance.
Can you translate the Chinese documents?

You can use the google translate, or search by google how to do. The only thing I can tell you is that it can be  done absolutely
Reply View the author
nero28
deepin
2018-05-25 07:37
#5
Blogghete 发表于 2018-5-24 21:44
Many thanks in advance.
Can you translate the Chinese documents?

searching the answer on google is much better
Reply View the author
Blogghete
deepin
2018-05-25 07:44
#6
Great, many thanks,
I hope that the next deepin release will include a default swap partition.
Reply View the author
MeowSprite
deepin
2018-05-25 09:15
#7
本帖最后由 MeowSprite 于 2018-5-25 16:55 编辑

Try to use swap file instead of swap partition. Just run following commands with root privilege:
# create a swap file of 2GB (swap size)
  1. fallocate -l 2G /var/swapfile
Copy the Code
# reset file permissions
  1. chmod 600 /var/swapfile
Copy the Code
# format swap file
  1. mkswap /swapfile
Copy the Code

# activate the swap file
  1. swapon /var/swapfile
Copy the Code
# edit the /etc/fstab file to add an entry for the swap file to activate swap file permanently
  1. /var/swapfile none swap defaults 0 0
Copy the Code
the details of swap file information can be found in https://wiki.archlinux.org/index.php/Swap
Reply View the author
caoyuan217
deepin
2018-05-25 17:19
#8
https://bbs.deepin.org/post/156953
Great, many thanks,
I hope that the next deepin release will include a default swap partition.

when you install the system via    CD or usb DISK ,  the  install program offer 2 ways of disk partition:      one is automatic partiton ,in which  there is no swap partition, in another option  manully partition (expert mode of partition),you  can made your own partition paln ,such as   root(/)   home(/home )   and the swap ,    the system wiil   mount them automatically.    So  ,    further  deepin release will not  include a default swap partition  bacause  it has the plan of sawp partiton right now.  Hope can help u . If you  bulid one system without swap partition , you can always turn to the google or  stn  else for help ,there are plenty  of  web
pages that can help you .   Though I can not remenber the details,  the common ways including  resizing your current disk to build an empty partiton ,formatting it as   swap  ,as mounting it by editing  fstab  .Make sure your data is safe before all your moves.
Reply View the author
Comments
Blogghete
2018-05-25 23:46
Ok, thanks for these info.
Blogghete
deepin
2018-05-25 23:44
#9
https://bbs.deepin.org/post/156953
本帖最后由 MeowSprite 于 2018-5-25 01:17 编辑

Try to use swap file instead of swap partition. Jus ...

Great!
Many thanks for these commands.

I will try to execute them.
Thanks for your support.
Reply View the author
Blogghete
deepin
2018-05-25 23:55
#10
Edited by Blogghete at 2018-5-28 12:16
https://bbs.deepin.org/post/156953
本帖最后由 MeowSprite 于 2018-5-25 01:17 编辑

Try to use swap file instead of swap partition. Jus ...

Hi,
when I try to run this command an error occurs
sudo swapon /var/swapfile

Results:
swapon: /var/swapfile: read swap header failed

How can I fix this?

UPDATE:
I have fixed this with this command:
sudo /sbin/mkswap /var/swapfile
sudo swapon /var/swapfile



Reply View the author