Linux - Newbie This 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! |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
|
07-28-2003, 10:09 PM
|
#1
|
LQ Newbie
Registered: Jul 2003
Location: Rockaway, NJ, USA
Distribution: Redhat 9
Posts: 7
Rep:
|
how to reduce swap space and reclaim the space
Hi All,
Newbie here .... just installed Redhat 9 (everything). I pretty much used the default partition profile and am regretting it now. I have a 7GB hard drive and here is how it's set up ...
Code:
# fdisk -l
Disk /dev/hdb: 7003 MB, 7003586560 bytes
255 heads, 63 sectors/track, 851 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 * 1 13 104391 83 Linux
/dev/hdb2 14 110 779152+ 82 Linux swap
/dev/hdb3 111 851 5952082+ 83 Linux
# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hdb3 5858544 5050696 510244 91% /
/dev/hdb1 101089 9275 86595 10% /boot
none 386196 0 386196 0% /dev/shm
Since I'm only using this box as a desktop I really don't need the 768MB of swap space (I have 768MB of main memory).
Is there any way I can reduce the swap space to 128MB and reclaim the space onto /dev/hdb3 without destroying the contents of it ??
I tried parted and was able to resize the swap but I'm guessing I'm SOL when it comes to moving the start of hdb3 (I didn't try it ... too scared).
Thanks !!
Grant.
|
|
|
07-28-2003, 10:19 PM
|
#2
|
Senior Member
Registered: May 2003
Location: Malaysia
Distribution: Slackware, LFS, CentOS
Posts: 1,307
Rep:
|
Go with parted... it's pretty safe
Any way, if you did cock up, there's not much to recover since your system is still in it's virgin stages.
So if you're too scared to use parted, then might as well install again.
|
|
|
07-28-2003, 11:37 PM
|
#3
|
LQ Newbie
Registered: Jul 2003
Location: Rockaway, NJ, USA
Distribution: Redhat 9
Posts: 7
Original Poster
Rep:
|
OK, I went for it.
Using parted from rescue disk....
Resized swap to 128MB .... good.
went to resize /dev/hdb3 to reclaim the space and got ....
No Implementation: This ext2 filesystem has a rather strange layout! Parted can't resize this (yet).
???????
Printout from parted ...
Code:
Disk geometry for /dev/hdb: 0.000-6679.140 megabytes
Disk label type: msdos
Minor Start End Type Filesystem Flags
1 0.031 101.975 primary ext3 boot
2 101.975 227.482 primary linux-swap
3 862.866 6675.446 primary ext3
Parted says it's an ext3 filesystem and then changes it's mind and thinks it's actually an ext2 filesystem ???
I dunno. Looks like I'll probably have to start from scratch
|
|
|
11-19-2007, 12:32 PM
|
#4
|
LQ Newbie
Registered: Jul 2005
Location: Cary, NC U.S.A
Distribution: RedHat/FreeBSD/NetBSD/Solaris
Posts: 29
Rep:
|
Turn your swap off and use fdisk
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:
- sync
- 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!
Last edited by rleesBSD; 11-19-2007 at 12:47 PM.
|
|
|
08-16-2012, 04:03 AM
|
#5
|
LQ Newbie
Registered: Aug 2012
Location: bangalore
Posts: 2
Rep:
|
Reduce Swap Space
Hi all,
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.
Thanks,
vasanth
|
|
|
08-16-2012, 08:00 AM
|
#7
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,314
|
When is jeremy going to lock these old threads ....
|
|
|
08-16-2012, 08:05 AM
|
#8
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,418
|
I meant to add he should start a new thread as well ...
|
|
|
All times are GMT -5. The time now is 04:50 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|