LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Made a mess with my swap partitions (https://www.linuxquestions.org/questions/linux-newbie-8/made-a-mess-with-my-swap-partitions-388068/)

VaniaMih 11-30-2005 06:17 PM

Made a mess with my swap partitions
 
Hi all,

i initially wanted to increase the size of my swap partition by doing:

dd if=/dev/zero of=/swapfile1 bs=1024 count=xxxxx

by mistake i've allocated too much of swap space (and got the message that there was no free space left on the device).

then without executing {mkswap /swapfile1 and swapon /swapfile1}

i've deleted that same swap partition (/swapfile1) by

swapoff /swapfile1
rm /swapfile1

as a result i've been left with my main partition /dev/hda5 FULL

Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hda5 73142560 73076172 0 100% /

i.e my swap mess has partitioned the rest of my hda5 device.

Is there a way of freeing that space without damaging the files that are already on hda5 ?

I've rebooted the computer but the memory that has been allocated has not been freed at the reboot - all my files previously on /dev/hda5 are still fine ...

any idea thanks.

michaelk 11-30-2005 07:48 PM

What distribution / version of linux are you running?
Try booting from a rescue or live CD and run fsck on hda5.

BTW you were trying to create a swap file not a partition. You only filled the partition up, you didn't change the partitioning of hda5. Were you logged in as root when you messed everything up? Was swapfile1 actually deleted?

VaniaMih 11-30-2005 11:12 PM

Quote:

Originally posted by michaelk
What distribution / version of linux are you running?
Try booting from a rescue or live CD and run fsck on hda5.

BTW you were trying to create a swap file not a partition. You only filled the partition up, you didn't change the partitioning of hda5. Were you logged in as root when you messed everything up? Was swapfile1 actually deleted?


Hi,
I'm running a RH8 distro Linux 2.4.18-14 i686 i686 i386 GNU/Linux.
Yes you are right i was trying to create a swap file not a partition.
I was logged as root unfortunately.
The only swap partition that remains is the old one, the new one (i.e the file) that i've created has been deleted by a rm command (i did however executed swapoff /swapfile1 before that) the cat on /proc/swaps gives me

[root] cat /proc/swaps
Filename Type Size Used Priority
/dev/hda6 partition 1044184 0 -1

[root] mount
/dev/hda5 on / type ext3 (rw)
/dev/hda3 on /boot type ext3 (rw)

i will try to check /dev/hda5 from the boot floppy using fsck any additional tips are very welcome

VaniaMih 12-01-2005 10:17 AM

I have one question can i boot with GRUB in a single user mode and then run fsck on my /dev/hda5 ?
thanks.
i.e

michaelk 12-01-2005 10:23 AM

If you have the RH8 install cd you should be able to boot into the rescue mode and run fsck.

VaniaMih 12-01-2005 10:57 AM

Hi thanks,

i've managed to run fsck from GRUB in a single user mode this is what i did at the prompt after booting with GRUB using " single"

umount /dev/hda5
fsck -t ext3 /dev/hda5

and got ...

fsck 1.27 (8-Mar-2002)
e2fsck 1.27 (8-Mar-2002)
/: clean, 229301/9289728 files, 18562727/18577156 blocks

my /dev/hda5 is still 100% full ... any idea would be most welcome !

VaniaMih 12-01-2005 11:08 AM

Actually i've just found swap files that i've created !
[roo]]# ll -h /swapfile*
-rw-r--r-- 1 root root 2.0G Nov 10 12:26 /swapfile
-rw-r--r-- 1 root root 33G Nov 30 19:04 /swapfile1
-rw-r--r-- 1 root root 2.0G Nov 16 21:11 /swapfile2

how should i delete them should i first do:

[root]swapoff /swapfile
then use rm after swapoff ?
i.e
[root] rm /swapfile ?

thanks again.

MORE ...

if i do

[root]cat /proc/swaps
Filename Type Size Used Priority
/dev/hda6 partition 1044184 0 -1

they do not figure as swap files should i just delete them using rm ?




michaelk 12-01-2005 11:16 AM

Since they are not being used as swap just delete them using rm.

VaniaMih 12-01-2005 11:21 AM

OK it worked thanks michaelk !

[root]df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hda5 73142560 34247172 35179960 50% /

michaelk 12-01-2005 12:04 PM

To create a 20mb swap file example:

dd if=/dev/zero of=/usr/local/newswap bs=1000000 count=20
chmod 600 /usr/local/newswap (set permissions)
mkswap /usr/loca/newswap (create filesystem)
swapon /usr/local/newswap (to activate it)

/usr/local/swapfile swap swap defaults 0 0 ( add to /etc/fstab to activate it at boot)

Change the location as desired.

VaniaMih 12-01-2005 12:42 PM

thanks - how about creating a swap file with 6GB (i know that this is really huge) for example in my Linux book it is written that swap files can only go up to 2GB ? Thus i will have to create three swap files each with 2GB size ? Do you know if three separate swap files are recognized as one when running a hypothetical program that uses that much memory ?
cheers
Vania

sundialsvcs 12-01-2005 12:47 PM

I recommend that swapping should be done to partitions, or even dedicated drives, and that those should be scattered across the various I/O channels and devices. If you have advanced bus-architectures such as SCSI or FireWire, which are capable of physically-simultaneous I/O operations, those are great to use for swap. You certainly want to pay attention to all opportunities for parallelism: for example, on a single IDE-chain the master and the slave cannot (afaik) be simultaneously active, but perhaps you have two such chains on your motherboard (or a bus-installed driver card, of course).

The rule of thumb is that your swap space should be twice the size of your RAM.

michaelk 12-01-2005 01:23 PM

The 2x rule of thumb is IMO outdated. It depends on what applications you run and how you use the computer. Someone that only uses a email, web browsing and basic office stuff with >512mb of memory might never use swap. Multiple swaps are recognized as one. With a 2.4 kernel you can have 32 partitions ( or files) * 2GB ea. Swap files are slower then swap partitions but can be used in a flash if additional space is required.


All times are GMT -5. The time now is 02:59 AM.