LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Creating a swap partition (https://www.linuxquestions.org/questions/linux-newbie-8/creating-a-swap-partition-67622/)

dsuniln 06-23-2003 11:57 PM

Creating a swap partition
 
i have installed red hat linux 9.0 without creating a swap partition. While installing it i did not get an option to create a swap partition.I have arround 1gb free space for the swap partition. Now i want to create a swap partition. How do i do it?

adz 06-24-2003 01:01 AM

1 GB is a lot for swap. If you want, before you go too far, you can reduce this (you'll have to repartition the linux and the swap and hence you'll lose everything in the linux partition). Otherwise, run "fdisk /dev/hda" as root. Then have a look around: press "p" to print the table, "m" the print the available commands. When you're bored of this press "p" again to see where the free space is. Then press "n" to create a new partition. Select primary partition from the next prompt and tell it to use all the remaining space (unless you want to use some of that space for something else). When it asks you what kind of partition to make it, say swap (you'll have to choose the number corresponding to swap). Press "p" again and write down the name of the partition you just created (something like /dev/hda2).

Once all this is done, edit your /etc/fstab file. and add in the following line just after the first entry:

/dev/hda2 none swap sw

The spaces are arbitrary (one press of the spacebar will do). Reboot. Presto! you now have a swap partition.

dsuniln 06-25-2003 11:54 PM

i ran fdisk but it is not showing me free space when i print the partition information. I have a 40 gb hard disk which i have partitioned as c:,d: for windows and /*,/*boot for linux Now i have 1 gb free space which i want to use as a swap partition. Even when i installed linux and used disk druid to create the partitions, it did not allow me to create a swap partition saying that there was insufficient space....

xiaodown 06-26-2003 01:29 AM

If you could, become root and type:
fdisk -l
and
df -k

and post the outputs here.

dsuniln 06-27-2003 01:06 AM

when i run fdisk -l i get the following output

Device boot start end blocks id system
/dev/hda1 * 1 1913 15366141 7 HPFS/NTFS
/dev/hda2 1914 3591 13478535 f Win 95 Ext'd (LBA)
/dev/hda3 3592 3604 104422+ 83 Linux
/dev/hda4 3605 4726 9012465 83 Linux
/dev/hda5 1914 3591 13478503+ 7 HPFS/NTFS

when i run df -k i get the following output

file system 1k-blocks used available use% Mounted on
/dev/hda4 8870804 5003840 3416344 60% /
/dev/hda3 10107 9324 816562 10% /boot
none 111472 0 111472 0% /dev/shm

michaelk 06-27-2003 04:56 AM

How many total sectors does fdisk says the disk has?

You might have free space on the end of your drive but your problem is that you can not create a partition for swap because:

1. You already have 4 parimary partitions and can not create another one.

2. hda5 is using up all of the space in your extended partition hda2 and therefore can not create another logical partition.

You will need to resize hda2 but to do this hda3 and hda4 need to be moved to the end of the drive. parted may or may not work depending on what kind of filesystem systems they are. See parted documentation for limitations.

Partition Magic will probably work.

Do you need a swap partition? How much RAM do you have? Like the previous post says 1gb is a lot of swap for an ordinary user unless you have RAM intensive apps or running a high volume server of some type. Most people can get by with 512mb.

You can create a swap file on your root partition. It will not be as fast as a partition.

adz 06-27-2003 11:17 PM

Yes that's correct. Only 4 primary partitions are allowed per disk. What you should do is create 3 primary partitions:
Linux
Linux Swap
NTFS/HPFS (Windows)

Then LOGICALLY partition Linux into / and /boot and then LOGICALLY partition Windows into C: and D:. This should solve your problem. You can use the programs suggested by michaelk or you'll have to reinstall everything.

adz 06-27-2003 11:21 PM

One more thing... I have 256Mb of RAM. My swap is the same size. I almost never hear my computer swapping and whenever I checked my swap partition, it was unused. Mind you, I use Debian which runs a little lighter than Red Hat but it shows you that you don't need ANYWHERE NEAR the amount of swap sapce under linux as you do under windows.

xiaodown 06-28-2003 12:33 AM

It's a good practice to maintain your swap file, though. I mean, it has to be there. But, like, if you don't think you need it, you don't have to make it as big as the ram. Some people make it twice as big as the ram.

If, in future situations, you want to maKe your swap smaller, you can probably do that.

~Wx

cpierce69 06-30-2003 12:18 PM

same problem
 
Quote:

Originally posted by dsuniln
i ran fdisk but it is not showing me free space when i print the partition information. I have a 40 gb hard disk which i have partitioned as c:,d: for windows and /*,/*boot for linux Now i have 1 gb free space which i want to use as a swap partition. Even when i installed linux and used disk druid to create the partitions, it did not allow me to create a swap partition saying that there was insufficient space....
Just to let you know, I ran into the same problem. I have actually found a few others that did the same thing. It sounds like we might have hit a limit of some sort when trying to create a "5th" partition. I have winme, and older system, that I wanted to install RH9 on. I created root and boot, then tried to create swap, but disk druid would not go it. The auto completly failed, but disk druid allowed me to create / & /boot
My system works just fine, but after bootup, I only have about 70MB free (out of 256MB) from free command. It shows 0 0 0 for swap, and I am here to look for suggestions. I just came from www.justlinux.com and kinda got flammed for asking a question before looking it up. There is so much out there it just gets overwhelming, and I did not want to have to install everything from scratch again. Its funny, with just a few posts from you guys, it sounds like the answer is there. I had to go to politics of newbie this and newbie that and I still was confused. Thanks for taking the time to answer questions without all the BS.
:study: <- begins to suck after a few days of getting no where!
:newbie:


All times are GMT -5. The time now is 06:14 PM.