LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE
User Name
Password
SUSE / openSUSE This Forum is for the discussion of Suse Linux.

Notices


Reply
  Search this Thread
Old 05-11-2006, 04:05 PM   #1
promo3000
LQ Newbie
 
Registered: May 2006
Posts: 11

Rep: Reputation: 0
How doe I create a swap file in SUSE 10 after the installation?


When installing SUSE, the default partition selected by SUSE was not the one I wanted. I managed to tell YAST to go to another partition but it gave me a message that I did not create a swapt file. Since I did not know how to do it, I proceeded with the installation. How do I create one now ater the installation is completed?
 
Old 05-11-2006, 04:48 PM   #2
slackMeUp
Member
 
Registered: Nov 2003
Distribution: Slack-where?
Posts: 654

Rep: Reputation: 30
Use the mkswap to create swap space on either a device or file.

For more information, man mkswap.

Once created, you can enter the swap space in your fstab, and enable it with the swapon command.
 
Old 05-19-2006, 12:07 AM   #3
lornix
LQ Newbie
 
Registered: May 2006
Location: Oklahoma
Distribution: SuSE 10.x
Posts: 1

Rep: Reputation: 0
Creating / Adding Swap Partition to system.

This will all be CLI work, as I don't believe there is a proper GUI tool for adding/creating swap partitions.

First find a partition you wish to use as a swap partition. Use this scenario:

/dev/hda1 - partition of whatever we didn't want touched.

/dev/hdb1 - a suitably sized partition, I think the rule of thumb is 2x RAM size, but as long at it's at least as big as your RAM size, that way you can do the 'Suspend to Disk' trick.
/dev/hdb2 - Current linux installation

Of course your drives and partitions will vary from this, but I'll use these three partitions to illustrate the process of creating and adding a swap partition to a system after install.

'fdisk' allows you to create/edit/delete partitions on drives (actually, in files too, but that's next class)

So, type the following to access the drive we want to make the partition on:

fdisk /dev/hdb

You'll get a cryptic prompt, good commands to know are 'p' for print (show) the partition table, 'm' for show menu of commands, 'q' for quit WITHOUT saving and 'w' for write and quit.

if the partition already exists, then you may skip this step, otherwise, you need to create a partition.

Type 'n' (for create New), choose a partition type, primary or extended (usually primary for swap), then the start cylinder (I usually just press enter here). The end cylinder prompt allows to enter things like '+512M' to create a 512meg partition, quite handy since you don't have to figure out how many cylinders.

Once the partition is created, make sure it is a type 82 - Linux SWAP partition. This is a simple flag that tells operating systems and BIOS's what kind of partition this is. '83' is a typical linux partition, 'b' is a typical Win9x type, and '7' is the usual NTFS ickiness used by the Win2k/XP crowd.

To check/change the partition type, type 't', enter, then the partition number (if more than one), and then the code for the desired type. the 'L' command displays a huge list of known types.

after double checking that you were editing the proper drive (/dev/hda, /dev/hdb, /dev/sdc, etc), and using the 'p' command to verify your work is correct, type 'w' to write your changes and return to the root prompt.

now, in this example we created /dev/hdb1 as a swap partition, so it is 'tagged' as a swap (type 82), but isn't 'formatted' as a swap.

Type 'mkswap /dev/hdb1' and the partition will have the proper magic numbers placed in it to signal it is a valid swap partition. BE CAREFUL, MISTYPING THIS COMMAND CAN BE VERY VERY BAD IF YOU HAVE EXISTING DATA AND SPECIFY THE WRONG DRIVE/PARTITION!!!!!

now the swap partition is created. We have to add it to the /etc/fstab file so it will be seen during boot and added to the system.

edit /etc/fstab with your favorite vanilla text editor (nano,pico,ed,joe,vi,vim,emacs,kate... your choice)

Add this line:

/dev/hdb1 swap swap defaults 0 0

location in the file doesn't matter, although style points are awarded for keeping the fstab file sorted by drive and partition number.

after you've saved that, type 'swapon -a' and the swap partition should be added to the system virtual ram cache. Verify it was added by using the 'free' command. The value under 'total' and 'swap' should be the same as the size of the partition you created.

Actually takes longer to write out than to perform. Hope this long-winded answer helps.

Take Care,

Lornix
 
Old 08-14-2006, 11:19 PM   #4
promo3000
LQ Newbie
 
Registered: May 2006
Posts: 11

Original Poster
Rep: Reputation: 0
Thank you

Quote:
Originally Posted by slackMeUp
Use the mkswap to create swap space on either a device or file.

For more information, man mkswap.

Once created, you can enter the swap space in your fstab, and enable it with the swapon command.
Thank you, very helpful.
 
Old 08-14-2006, 11:20 PM   #5
promo3000
LQ Newbie
 
Registered: May 2006
Posts: 11

Original Poster
Rep: Reputation: 0
Thank you

Quote:
Originally Posted by lornix
This will all be CLI work, as I don't believe there is a proper GUI tool for adding/creating swap partitions.

First find a partition you wish to use as a swap partition. Use this scenario:

/dev/hda1 - partition of whatever we didn't want touched.

/dev/hdb1 - a suitably sized partition, I think the rule of thumb is 2x RAM size, but as long at it's at least as big as your RAM size, that way you can do the 'Suspend to Disk' trick.
/dev/hdb2 - Current linux installation

Of course your drives and partitions will vary from this, but I'll use these three partitions to illustrate the process of creating and adding a swap partition to a system after install.

'fdisk' allows you to create/edit/delete partitions on drives (actually, in files too, but that's next class)

So, type the following to access the drive we want to make the partition on:

fdisk /dev/hdb

You'll get a cryptic prompt, good commands to know are 'p' for print (show) the partition table, 'm' for show menu of commands, 'q' for quit WITHOUT saving and 'w' for write and quit.

if the partition already exists, then you may skip this step, otherwise, you need to create a partition.

Type 'n' (for create New), choose a partition type, primary or extended (usually primary for swap), then the start cylinder (I usually just press enter here). The end cylinder prompt allows to enter things like '+512M' to create a 512meg partition, quite handy since you don't have to figure out how many cylinders.

Once the partition is created, make sure it is a type 82 - Linux SWAP partition. This is a simple flag that tells operating systems and BIOS's what kind of partition this is. '83' is a typical linux partition, 'b' is a typical Win9x type, and '7' is the usual NTFS ickiness used by the Win2k/XP crowd.

To check/change the partition type, type 't', enter, then the partition number (if more than one), and then the code for the desired type. the 'L' command displays a huge list of known types.

after double checking that you were editing the proper drive (/dev/hda, /dev/hdb, /dev/sdc, etc), and using the 'p' command to verify your work is correct, type 'w' to write your changes and return to the root prompt.

now, in this example we created /dev/hdb1 as a swap partition, so it is 'tagged' as a swap (type 82), but isn't 'formatted' as a swap.

Type 'mkswap /dev/hdb1' and the partition will have the proper magic numbers placed in it to signal it is a valid swap partition. BE CAREFUL, MISTYPING THIS COMMAND CAN BE VERY VERY BAD IF YOU HAVE EXISTING DATA AND SPECIFY THE WRONG DRIVE/PARTITION!!!!!

now the swap partition is created. We have to add it to the /etc/fstab file so it will be seen during boot and added to the system.

edit /etc/fstab with your favorite vanilla text editor (nano,pico,ed,joe,vi,vim,emacs,kate... your choice)

Add this line:

/dev/hdb1 swap swap defaults 0 0

location in the file doesn't matter, although style points are awarded for keeping the fstab file sorted by drive and partition number.

after you've saved that, type 'swapon -a' and the swap partition should be added to the system virtual ram cache. Verify it was added by using the 'free' command. The value under 'total' and 'swap' should be the same as the size of the partition you created.

Actually takes longer to write out than to perform. Hope this long-winded answer helps.

Take Care,

Lornix

Thanks for the detailed answer, very helpful.
 
  


Reply

Tags
suse, swap, swapon



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to Create Installation Source in SuSE 9.0 pmehta1613 Linux - Distributions 9 06-10-2007 10:24 PM
Yast System Backup doesn't create auto-installation file MatricalDreamer SUSE / openSUSE 1 05-03-2006 09:36 AM
How do I create a windows hosted file sharing that can share files with suse 10.0?? winstone5000 Linux - Networking 3 12-18-2005 03:39 PM
fwrite() doe not move pointer, why? realos Programming 4 12-08-2005 12:48 PM
How do I partition so Red Hat and SuSE share the same swap file. sjia Linux - Newbie 3 01-31-2004 08:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE

All times are GMT -5. The time now is 05:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration