LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   SUSE / openSUSE (https://www.linuxquestions.org/questions/suse-opensuse-60/)
-   -   Redistribute Swap file space to main partition (https://www.linuxquestions.org/questions/suse-opensuse-60/redistribute-swap-file-space-to-main-partition-496761/)

stuartornum 10-29-2006 08:40 PM

Redistribute Swap file space to main partition
 
Hi,

I have SuSe 9.3 running on a 733Mhz P3, 256MB, 10G.

At the moment I have 2GB of swap space (hda2), and 7.3GB on the hda1.

Is it possible to change the swap to say 512MB and put the other 1.5GB onto hda1 without deleting any info on hda1?

Thanks

PatrickNew 10-29-2006 09:07 PM

Yeah, I'd get my hands on the GParted LiveCD available at http://sourceforge.net/project/showf...kage_id=173828

It's graphical and easy will full options to grow and shrink partitions. The only hitch might come with what file system Suse uses. I have Suse 10.0 and I know it uses ReiserFS, which doesn't resize well.

syg00 10-30-2006 12:17 AM

I've always found it easiest to just mount a directory on the reclaimed space.
Pick a big one - say /home.
Don't bother trying to resize.

stuartornum 10-30-2006 04:15 AM

Thanks PatrickNew and syg00 for the replies,

As for the LiveCD I don't think I can do that because its a dedicated PC, so cant mount any CD's.

So how would I go about creating a new swpa space and new /home partition.

So far im here:

free -mt
Code:

total      used      free    shared    buffers    cached
Mem:          249        226        23          0          8        159
-/+ buffers/cache:        58        191
Swap:            0          0          0
Total:        249        226        23

swapon -s
Code:

Filename            Type            Size    Used    Priority
/dev/hda2            partition      2094112 0      42

swapoff /dev/hda2


And from there on, not really sure what im doing??

Thanks again

syg00 10-30-2006 04:21 AM

Use cfdisk (preferable - better interface) or fdisk to delete the swap partition, then create the new one of the appropriate size.
Write the table, then from a terminal
Code:

mkswap /dev/hda2
swapon /dev/hda2

Easy.
Presumes the partition comes back as the same.

As for the free space, up to you what you want to do.

jschiwal 10-30-2006 04:26 AM

YaST2 has a partitioner program that can resize your partitions. You can use the install disk to access it.

However SYG00's idea is a good one. Delete the swap partition; create a 500M swap partition; create a new 1GB partition. Using the new 1GB partition may be a good place for either /usr/local or /tmp.
/usr/local because that would protect software you install from tarballs. Even a new install won't write anything to /usr/local. /tmp because it doesn't need to be as large as /usr or /home and having /tmp on its own partition will allow you to mount it with the noexec and nodev options.

You could determine how much space is used for these partitions presently.
du -hs /usr/local
sudo -hs /tmp

That will let you know whether there is enough room in 1GB.

stuartornum 10-30-2006 04:40 AM

Thanks syg00, slowly getting there

I have typed in cfdisk and get:

Code:

cfdisk 2.12q

                              Disk Drive: /dev/hda
                        Size: 10005037056 bytes, 10.0 GB
              Heads: 240  Sectors per Track: 63  Cylinders: 1292

    Name        Flags      Part Type  FS Type          [Label]        Size (MB)
 ------------------------------------------------------------------------------
    hda1                    Primary  Linux ext3                        7857.57
    hda2        Boot        Primary  Linux swap / Solaris              510.94
    hda3                    Primary  Linux                            1633.45










    [Bootable]  [ Delete ]  [  Help  ]  [Maximize]  [ Print  ]
    [  Quit  ]  [  Type  ]  [ Units  ]  [ Write  ]

                Toggle bootable flag of the current partition

However I go to "write" and yes everything

Code:

fdisk -l

Disk /dev/hda: 10.0 GB, 10005037056 bytes
240 heads, 63 sectors/track, 1292 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/hda1              1        1015    7673368+  83  Linux
/dev/hda2  Boot    1016        1081      498960  82  Linux swap / Solaris
/dev/hda3            1082        1292    1595160  83  Linux

Then I...

Code:

mkswap /dev/hda2
Setting up swapspace version 1, size = 2144374 kB

and

Code:

swapon /dev/hda2
swapon: /dev/hda2: Device or resource busy

Any Ideas why the swap is still 2GB and why its busy? will a restart fix it?

Thanks again

jschiwal 10-30-2006 04:47 AM

Did you run "sudo /sbin/swapoff /dev/hda2" before running cfdisk?

syg00 10-30-2006 04:49 AM

Quite often the re-read of the partition table isn't successful.
Just reboot - you may get a swap error, just ignore it.
Swapoff and mkswap as above.

stuartornum 10-30-2006 04:51 AM

Yep,

I did, I ran through it again just in case and still get the error and the 2GB swap size.

Thanks

michaelk 10-30-2006 10:57 AM

Not sure what steps you are using but here is a run through. It would be best to use a liveCD but since you can't.
1. deactive swap
2. delete hda2
3. recreate hda2 as an extended partition.
4. create a 512 mb logical partition (hda5) and change its partition ID to swap (82).
5. create a logical partition (hda6) using the rest of the space, partition ID should be 83.
6. save and reboot.
7. format swap ie. mkswap /dev/hda5 and activate (swapon /dev/hda5).
8. change fstab entry for swap from hda2 to hda5.
9. format hda6 as desired.
10 mount hda6 to some mount point like /mnt/newhome (be sure to create the directory).
11 copy contents of /home to newhome. i.e. cp -rp /home/ /mnt/newhome
12 Add an entry to in fstab for /home (i.e /dev/hda6 /home ext3 defaults 1 2) Replace ext3 with correct filesystem type.
13 reboot to make sure everything works. When all is working as expected you can unmount /home. In doing so you can then delete the contents of the old home which is still on the old partition and free up that space. Remount /home and you should be good to go.

syg00 10-30-2006 03:49 PM

What's the "fdisk -l" show after the reboot ??


All times are GMT -5. The time now is 03:55 PM.