LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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

Reply
 
Search this Thread
Old 07-28-2003, 09:09 PM   #1
grantm
LQ Newbie
 
Registered: Jul 2003
Location: Rockaway, NJ, USA
Distribution: Redhat 9
Posts: 7

Rep: Reputation: 0
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.
 
Old 07-28-2003, 09:19 PM   #2
Azmeen
Senior Member
 
Registered: May 2003
Location: Malaysia
Distribution: Slackware, LFS, CentOS
Posts: 1,307

Rep: Reputation: 46
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.
 
Old 07-28-2003, 10:37 PM   #3
grantm
LQ Newbie
 
Registered: Jul 2003
Location: Rockaway, NJ, USA
Distribution: Redhat 9
Posts: 7

Original Poster
Rep: Reputation: 0
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
 
Old 11-19-2007, 11:32 AM   #4
rleesBSD
LQ Newbie
 
Registered: Jul 2005
Location: Cary, NC U.S.A
Distribution: RedHat/FreeBSD/NetBSD/Solaris
Posts: 29

Rep: Reputation: 15
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 11:47 AM.
 
Old 08-16-2012, 03:03 AM   #5
mymailbox83
LQ Newbie
 
Registered: Aug 2012
Location: bangalore
Posts: 1

Rep: Reputation: Disabled
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
 
Old 08-16-2012, 06:49 AM   #6
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,261

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
There is no such thing as 'RHEL 9'; you probably mean RH9 aka Shrike https://en.wikipedia.org/wiki/Red_Hat_Linux, which is years out of date.(!)
Please get eg Centos 6.3 which is a free version of RHEL(!) 6.3; the latest from Redhat https://en.wikipedia.org/wiki/Red_Hat_Enterprise_Linux
 
Old 08-16-2012, 07:00 AM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,203

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
When is jeremy going to lock these old threads ....
 
Old 08-16-2012, 07:05 AM   #8
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,261

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
I meant to add he should start a new thread as well ...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How to unmount actual swap and mount a new(bigger) swap space? isaac Linux - Newbie 1 06-06-2004 01:23 AM
Canīt reduce the space on my Windows Partition fedivh Linux - General 2 05-16-2004 11:47 PM
Swap space? jtsai256 Linux - Newbie 3 05-05-2004 01:42 PM
Swap space ekoome Red Hat 3 11-07-2003 10:49 AM
swap space not being used DarkBeethoven Linux - General 9 06-09-2002 12:09 PM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration