LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   create swap partition (https://www.linuxquestions.org/questions/linux-newbie-8/create-swap-partition-827188/)

siva balan 08-19-2010 06:33 AM

create swap partition
 
total used free shared buffers cached
Mem: 3895 3203 691 0 4 2163
-/+ buffers/cache: 1035 2859
Swap: 0 0 0


this is the output of "free -m" command in my fedora 13 linux system..

as per the output, there is no swap partition in my system..
i am lack of analysing the output above. please describe me about buffers,cached fields and "-/+buffers/cache" row.

and do i need to create swap partition or not?if yes, how?

nandri(for thanks in my mother tongue(tamil))

sem007 08-19-2010 07:03 AM

Quote:

please describe me about buffers,cached fields and "-/+buffers/cache" row.
The buffers/cache line shows you how much memory is used by programs , and is free for programs to use.

Quote:

and do i need to create swap partition or not?if yes, how?
for better performance you need to create swap.

adding swap partition or swap file

HTH

johnsfine 08-19-2010 07:07 AM

Quote:

please describe me about buffers,cached fields and "-/+buffers/cache" row.
Buffers and cache represent information that is stored on disk that was needed in ram at some point and isn't needed in ram right now. As long as there is no other need for that ram, the redundant (with disk contents) data is kept in ram in case it might be needed again.

The -/+buffers/cache row shows what used and free memory would be if buffers and cache were counted as free rather than used. Usually that is the more meaningful way of counting used and free memory, because the memory used by buffers and cache will be treated as free if any application needs memory.

Quote:

do i need to create swap partition or not?
If this level of memory use is typical for your system then you don't need to create a swap partition.

I think it is better to have a swap partition anyway.

Your system might have some stale anonymous memory use and could be a tiny bit faster if that memory were swapped and a little more memory were available for caching. But you already have a lot of caching so such improvement if any would be tiny.

A swap partition is also a useful safety valve if you run some tasks that are much bigger than your typical use, or if some task has a memory leak. In case of a memory leak, swap space may make the system degrade smoothly rather than fail abruptly. That may give you time to diagnose and correct the problem without crashing the whole system.

We may be able to give you a better idea about creating swap space if we knew more about your current disk usage. Post your partitioning and free space, output from the following commands done as root
Code:

/sbin/fdisk -l
df

You should use CODE tags when posting the output of commands (including the output of free that you posted at the top of this thread). That makes it easier for us to read such output.

siva balan 08-19-2010 10:35 PM

Code:

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c4424

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1          39      307200  83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              39      27453  220200960  83  Linux
/dev/sda3          27453      47034  157286400  83  Linux
/dev/sda4          47035      60801  110583427+  5  Extended
/dev/sda5          47035      53562    52428800  83  Linux
/dev/sda6          53823      60801    56056831+  83  Linux
/dev/sda7          53563      53822    2088418+  83  Linux

Partition table entries are not in disk order


this is the output of the command "fidisk -l".actually.i had wrongly created swap partition in the installation by giving "/swap with ext3 partition".i have deleted that 2gb partition.and that 2gb is in my system as unallocated space..how to make it as swap partition.i had used "gparted"..but get error..

johnsfine 08-20-2010 06:32 AM

Quote:

Originally Posted by siva balan (Post 4071917)
i had wrongly created swap partition in the installation by giving "/swap with ext3 partition".i have deleted that 2gb partition.and that 2gb is in my system as unallocated space.

Do you mean you did that after the fdisk -l that you posted?

I assume the 2GB you mean is sda7. In the fdisk -l output you posted, sda7 has not been deleted and there is no unallocated space on that drive.

One of the the reasons I asked for output from df is to find out which partitions are mounted where in your directory tree. Output from mount would also tell that (since now I understand you don't need to resize any partition, so we don't need to know about free space inside partitions).

So you want to make sure sda7 isn't mounted nor in etc/fstab to be remounted. Then you want to know how to delete it, recreate and format it as a swap partition and enable use of that swap partition.

jay73 08-20-2010 07:36 AM

If you rarely ever need swap, you may as well leave your partitions as they are and create a swap file instead. They used to be slower than swap partitions but that has not been the case for several years now (if the kernel developers are to believed - and I don't see why not).

johnsfine 08-20-2010 07:50 AM

Quote:

Originally Posted by jay73 (Post 4072339)
you may as well leave your partitions as they are and create a swap file instead.

That might make more sense if resizing the partitions that are in use would be required to create a swap partition. But apparently sda7 was meant to be the swap partition and was just set up wrong.

On my own systems, I don't use suspend to disk, so it is usually convenient that multiple different liveCDs and installed copies of Linux all use the same swap partition. That would be a lot messier with a swap file.

When switching versions or distributions of Linux, I usually want to shrink the existing installed Linux and create a new partition for the new one, then install, test and copy things to the new one all before trashing the old one. Keeping the swap space outside of the file system means it is one less thing taking time, extra space and complexity during such a transition. Contrast that to Windows where you often need to turn off paging and delete the pagefile before changing the partition size, then turn paging back on afterwards.


All times are GMT -5. The time now is 03:32 AM.