help creating and deleting swapfiles

Hi,

I need to increase my swap size on my Open suse. Being a beginner I decided to create a swapfile instead of a new swap partition.
From what I read the way to do it is :

1- get to superuser, eg. root, doing alt+F2, entering opensuze nautilus, giving the password. So from there I am root with a red name in a terminal, a terminal stating “as superuser”.

2- type “dd if=/dev/zero of=/swapfile bs=1024 count=524288” to create a 256M file for example

3- type “mkswap /swapfile” to make it a swapfile for real

4- type “swapon /swapfile” to activate it immediatly into swap

5- twicking things in fstab to activate it automaticaly at each boot. I did not approach this yet.

so I got step 1 and 2 fine. At step 3 it says it may not work as mkswap is located in sbin and I need superuser privileges (rg. root)
The same thing happens for the swapon command.

I tried to reboot, nothing changed.

That is the point where i made a BIG mistake. I wanted to start over, so i deleted the swapfile i created. The file desapeared but it didnt release its disk space. It s not in the trash, or at least I cannot see it. the find command doesn’t find it either.

How can I fix this lost disk space problem?
and finally what is the problem i have with step 3?

Okay,
i fixed my disk space problem.
When I deleted the file it actually went to /root/.local/share/trash/files

I still don’t understand why i cannot do step 3 :confused:

On 02/18/2011 11:36 AM, Orpexo wrote:
>
> I still don’t understand why i cannot do step 3 :confused:

have you read the important information attained if you type the
following into a terminal:


man mkswap

do NOT overlook the info “a typo may destroy your disk.”

and, then answer this: why did you elect to NOT allow the partitioner
to set up a small swap partition on your disk? that is the normal way
of handling the swap area, and it requires no involvement on your part
nor is it likely that you will destroy your disk if you don’t mess
with it!


DenverD
CAVEAT: http://is.gd/bpoMD
[NNTP posted w/openSUSE 11.3, KDE4.5.5, Thunderbird3.0.11, nVidia
173.14.28 3D, Athlon 64 3000+]
“It is far easier to read, understand and follow the instructions than
to undo the problems caused by not.” DD 23 Jan 11

Thx for your help.
I didnt even knew there was a partitioner in ‘yast’, I am new to linux.
I checked it, the size of my current swap is allready at maximum. And I cannot create a new partition on my disks.

I read, the man mkswap info, but did’nt find what my problem is.

On 02/18/2011 12:36 PM, Orpexo wrote:
>
> I read, the man mkswap info, but did’nt find what my problem is.

it could be that the system will not let you make a swap because you
already have a swap! by default, the openSUSE install disk will set up
a swap partition…if you did not turn that off (on purpose, or
accidentally) then you have a swap partition and efforts to have
another is unnecessary, and dangerous

please show us the output of entering the following into a terminal


cat /etc/fstab

and copy/paste the output back to this thread using the instructions
here: http://goo.gl/i3wnr

as for being new to Linus: welcome, but you might read more in the
opensuse.org area and less that google and others can drag
up…because, it sounds like to me that checklist of do this, 1
through 5 was probably written about 12 years ago…we do not do that
any more…

you might begin reading here:

  1. doc.opensuse.org

http://forums.opensuse.org/english/get-technical-help-here/how-faq-forums/
3. http://en.opensuse.org/Portal:Support_database

and, instead of searching the entire internet for info on openSUSE use
google’s “site specifier” like


site:opensuse.org


DenverD
CAVEAT: http://is.gd/bpoMD
[NNTP posted w/openSUSE 11.3, KDE4.5.5, Thunderbird3.0.11, nVidia
173.14.28 3D, Athlon 64 3000+]
“It is far easier to read, understand and follow the instructions than
to undo the problems caused by not.” DD 23 Jan 11

I found a way to make it work.

I repeated step 1 and 2 as described before.
First I tried “sudo mkswap /fileswap”, this did not work.
Finally I tried to type “sudo su”, then “mkswap /fileswap” and it worked!
It is a bit stupid that you have to lauch “sudo su” as a superuser but I have now my swap file working well and am happy :slight_smile:

I know my instalation may seem weird DenverD, but I am doing something very specific and I need approx 36Go RAM for that. My computer has only 32Go Ram. The swap partition created at the install was only of 2Go, so I was 2 Go short at least. I created a swapfile of 5Go and my computation works all right now.

This is certainly not stupid. Windows actually accommodates this behaviour as default lately. Imagine that a user runs a command
mkswap /
If the sudo was not required they would be able to easily destroy all their data however the privileges escalation defends the user from himself and doesn’t allow to do anything stupid until the user becomes the superuser. If You find this behaviour stupid You can log into your system as root all the time but IMHO this is actually stupid (highly NOT recommended) and the default for all desktop Windows operating systems prior to Vista.

Best regards,
Greg