Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
I have had good success reducing the swap file thusly:
0. BACKUP your data:
- I like to boot from a live cd, and then dd the entire drive over to another one.
1. Make sure you have sufficient physical memory to hold the swap file contents, and then
turn the swap off with something like:
- swapoff -Lswap (substitute your values)
- swapon -s (status check to be sure that it worked)
- (if status check reveals a swap line-item, then you specified incorrect swap label.
2. Run fdisk and:
- List partitions with "p" command
- Delete the partition that is home for your swap file with "d" command
- Create a smaller Linux-Swap partition with "n" command
- Make sure it is a Linux-Swap partition (type 82) (Change with "t" command)
- Create a new Linux partition for new file system in rescued space ("n" and "t" commands)
- Write partition table with "w" command
3. The new table won't be used until the next reboot.
4. After reboot, make sure your swap is made and turned on.
- mkswap /dev/hda4 -Lswap (substitute your values)
- swapon -Lswap
- swapon -s (check to make sure swap is turned on)
5. Create a mount point for your new file system partition (mkdir ...)
6. Make the new file system in the new partition:
- mkfs /dev/hda2 (or whatever partition it happens to be)
7. Mount the new fs and enjoy:
- mount /dev/hda2 /newmountpoint...
Note the extreme importance of syncing and turning
the swap off before you change any partitions.
- FAILURE_TO_DO_THIS = LOST_DATA!
This works for me, but your mileage may vary. Use at your own risk!
My self vasanth. I have installed RHEL 9 in my laptop through Vmware. for swap space i have given 3GB i want to reduce it to 500mb. Because my through Vmware for my linux partion it took only 256 as physical memory. so i need to give only 500mb for swap space.
kindly help me for the same.