Problem with swap space.
Tofloor
poster avatar
moomin74
deepin
2015-12-05 11:17
Author
I have noticed with Deepin, even though I set a swap space it is not being mounted by the system. If I go into gparted, it shows the swap, but I have to select swapon to get it to detect it. I have to do this every time I boot up. Is there anyway to get Deepin to do this automatically?

Thanks,

Reply Favorite View the author
All Replies
eric52
deepin
2015-12-05 12:27
#1
It is good to have swap space available. It is better to never use it. If you have little RAM, say under 2GB, the OS may need to swap. Your computer will crawl when this is happening. I've never encountered this with deepin, and I've never looked into it. With many systems, you have to lower the "swapiness" from a default 60% to about 10% to get decent performance. It seems you have confirmed this is not the case with deepin. There may be an automatic recognition and use of swap space, if needed. I actually don't know, but I'll check on it. Counter-intuitively, you don't want to use swap space or encourage it. It exists as an overflow last resort from an earlier era when there often wasn't enough RAM. I think it is still useful for certain emergency situations, so it's good to define some greater than your RAM, but if deepin isn't inclined to use it, I wouldn't ask it to.
Reply View the author
moomin74
deepin
2015-12-05 14:19
#2
The swap space is there. It is visible with gparted, but you have to use "swapon" each time after you boot for it to show under system monitor. I only discovered this after installing and using vmware player. It kept going on about "swap" and saying I had no space. When I looked under system monitor, sure enough there was no swap. After opening gparted and selecting swapon for the swap space it then showed in system monitor and the error message in vmware player disappeared. It's just annoying that I can't set it to detect the swap space all the time and use it as and when required. (Probably never as the laptop has 8GB ram).
Reply View the author
eric52
deepin
2015-12-05 18:58
#3
8GB RAM won't need swap space. Sounds like a high-end machine. Does it use a SSD?
Reply View the author
laoguang
deepin
2015-12-06 01:25
#4
why would you want to mount swap, you don't need them most of time, i did not even create them.
Reply View the author
moomin74
deepin
2015-12-06 03:15
#5
It's a Lenovo thinkpad x230. Has a fast i5 processor and 8gb ram with intel hd4000 graphics. It came with windows 7, but Deepin runs so much faster than windows 7 did. The only reason I mentioned swap is when I formated I had created a swap space, It
Reply View the author
moomin74
deepin
2015-12-06 03:19
#6
was recommended to me to do this even with 8GB ram, but of course it would probably never be used. That doesn't bother me, it's just the fact that Deepin doesn't detect the swap space,  let alone use it unless I use swapon in gparted after it has loaded. Vmware Player detected this as being an issue when I was running windows xp in a vm.
Reply View the author
eric52
deepin
2015-12-06 06:58
#7
Thanks for the model. Specs say HDD not SSD, so it's not a SSD recognition issue. Just to confirm, gparted shows it as a brown swap partition. not formatted for ext*?
Reply View the author
laoguang
deepin
2015-12-06 07:34
#8
https://bbs.deepin.org/post/30453
was recommended to me to do this even with 8GB ram, but of course it would probably never be used. T ...

did you format the swap with deepin during installation?
Reply View the author
moomin74
deepin
2015-12-06 07:38
#9
Yes it is an HD not SSD. It does show under Gparted as swap space not ext. It shows as unmounted unless I right click and select swap on. The swap was not formatted with deepin. I didn't have a swap until yesterday. When I used vmware, it said I needed a swap, so I booted with gparted and added a swap.
Reply View the author
eric52
deepin
2015-12-06 08:45
#10
My guess is that deepin saw no need for swap space on install, and some flag somewhere in a startup script is set or unset accordingly. Thus, you're back to square one every time you boot. Making session changes like swapon doesn't affect this startup script, which might be read-only, hidden, etc. I can't think of any other easy fix possibilities other than to say: "If it ain't broken ..."
Reply View the author
moomin74
deepin
2015-12-06 09:15
#11
I tried doing this:

sudo blkid

and it brought up this:

/dev/sda1: UUID="c7383e59-e3c6-4655-a7dd-eb6934371a7e" TYPE="ext4"
/dev/sda2: UUID="5c8df5c4-52d9-48da-98c9-a2a9e3f114e3" TYPE="swap"

If I run fstab:

sudo gedit /etc/fstab

I get this:

/dev/sda1
UUID=c7383e59-e3c6-4655-a7dd-eb6934371a7e        /                 ext4              rw,relatime,data=ordered        0 1

It doesn't show /dev/sda2 at all.

I am wondering could I add the UUID for sda 2 to fstab? If so how woud I do it? Add a line like this:

/dev/sda2
UUID=5c8df5c4-52d9-48da-98c9-a2a9e3f114e3        /                 swap              rw,relatime,data=ordered        0 2

I am just guessing here, but do you think that would work?


Reply View the author
moomin74
deepin
2015-12-06 11:06
#12
Ok I tried adding this after some google research:

# /dev/sda2
UUID=5c8df5c4-52d9-48da-98c9-a2a9e3f114e3        /                 swap              sw                                0 0

to the lines in fstab. On reboot though the swap space is still not being loaded so I must be doing something wrong?
Reply View the author
moomin74
deepin
2015-12-06 11:43
#13
Ok I finally fixed this with trial and error. I was on the right track. I needed to first do sudo blkid to get the UUID number for the swap partition (or from gparted). Then run fstab: sudo gedit /etc/fstab.

fstab only showed:

#/dev/sda1
UUID=c7383e59-e3c6-4655-a7dd-eb6934371a7e        /                 ext4              rw,relatime,data=ordered        0 1

So I then added:

/dev/sda2
UUID=5c8df5c4-52d9-48da-98c9-a2a9e3f114e3  none  swap sw 0 0

On reboot the swap space is finally detected! :-)

Reply View the author
eric52
deepin
2015-12-06 12:39
#14
I don't think you're doing something wrong, just unnecessary. Defining a swap or how to mount it doesn't force the OS to use it. A swap partition is just allocated unused space on the hard drive - sort of a frame to facilitate ad hoc writing and limit it. In some ways, it's more like RAM than a physical entity. Recognizing and using it is a special case. In my limited experience, deepin is far less inclined to swap than many others. This is a good feature. In your case there's absolutely no reason to swap, so you're trying to force it into a performance error. Leave the swap partition. If you try other OS's on live DVD or pen drive, they may need it. Knoppix, for instance, is about 4GB compressed, and it will try to occupy as much RAM/swap as it can.
Reply View the author
moomin74
deepin
2015-12-06 12:54
#15
Yes, even with the swap in place Deepin is never using it. But I am wondering if vmware player does, hence the warning message? Anyway when I installed Deepin I let it do all the formatting and it didn't create a swap partition, but there is an expert option which suggests setting a swap of 4GB on modern computers:

http://linuxbsdos.com/2014/07/11 ... de-for-deepin-2014/

I could've done this when installing, but I didn't and it just got me wondering whether, had I installed the swap partition from deepin's own installer would it have mounted it automatically rather than my having to struggle with swapon and fstab? I agree with you though there seems to be absolutely no need for swap in my case (other than whether vmware would suffer performance problems without it).

Thanks for all your advise and patience with me in this matter however, it is greatly appreciated.
Reply View the author
moomin74
deepin
2015-12-07 16:32
#16
Have just tested my theory on another laptop. I installed using expert mode, added the swap space and installed deepin. Sure enough after installation system monitor showed the swap space, although not being used. So if you did want swap, adding it after install would cause it not to be mounted and you would need to use the method above, but as already discussed, swap isn't required if you have plenty of ram.
Reply View the author
eric52
deepin
2015-12-08 02:11
#17
Thanks, moomin74, for testing and posting your findings to serve as a reference for others.
Reply View the author