How doe I create a swap file in SUSE 10 after the installation?
SUSE / openSUSEThis Forum is for the discussion of Suse Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.