Making a swap space
As my swap partition is dead, I tried to resurcitae it by making the following file. I use the 'vi' to creat the file. As a matter of fact, I copied the file from a website. The name of this file is 'Swap space'.
-------------------------------------------------------------------------------------------------- -#!/bin/sh # # swapinit.sh - activate the swap partition # # written by Rahul U. Joshi # Verify and initialize swap space # echo -n 'Verifying swap space... ' loopcount=0 # flag to indicate whether the partition has been activated or not activated=0 # check for signatures 6 times before giving up while [ $loopcount -lt 6 ] do if [ "`/bin/dd 2>/dev/null if=/dev/winswap bs=1 count=10 skip=4086`" = 'SWAP-SPACE' ]; then echo "Linux signature found, iteration $loopcount" echo "Activating swap partitions" swapon /dev/winswap activated=1 break elif [ "`/bin/dd 2>/dev/null if=/dev/winswap bs=1 count=11 skip=43`" = 'SWAP SPACE ' ]; then echo "DOS signature found, iteration $loopcount" echo "Making swap partition" mkswap /dev/winswap YYYYY echo "Activating swap partitions" swapon /dev/winswap activated=1 break else let loopcount=loopcount+1 fi done if [ $activated -ne 1 ] ; then echo "Swap signature not found after $loopcount tries" echo "No swapping partitions activated" exit 1 fi --------------------------------------------------------------------------------------------------------------- 1. Use the 'vi' editor to make the file. 2. Wrote ' chmod 755 Swap space 3. ./Swap space I got the following message ------------------------------------------------------- [nissanka@c83-250-90-204 nissanka]$ ./Swap Verifying swap space... Swap signature not found after 6 tries No swapping partitions activated [nissanka@c83-250-90-204 nissanka]$ What is the problem? I looked deep into my 'dev' folder; there is no folder or file called 'winswap' . This may be the problem. What is this? |
Hi -
Be *very* careful: you can easily trash your system. But here's all the script is really doing: 1. "Su" to "root" su - root 2. Identify your existing swap partition: swapon -s Filename Type Size Used Priority /dev/hda3 partition 2097136 0 42 <= EXAMPLE OUTPUT: THIS SYSTEM HAS A SWAP PARTITION ON "/dev/hda3" 3. (Re)initialize the swap area swapoff /dev/hda3 mkswap /dev/hda3 swapon /dev/hda3 |
The 'swapon -s ' command didn't gave me an output. Please read the following:
[nissanka@c83-250-90-204 nissanka]$ su root Password: [root@c83-250-90-204 nissanka]# swapon -s [root@c83-250-90-204 nissanka]# swapon -s [root@c83-250-90-204 nissanka]# [root@c83-250-90-204 sbin]# swapon -s [root@c83-250-90-204 sbin]# ----------------------------------------------------------------------- However, I found the following file in 'sbin' folder. mkswap* --------------------------------------------------------------------------- ------------------------------------------------------------ When I wrote the ' cat mkswap * ' and pressed enter. I couldn't read anything. Just some binary stuff. --------------------------------------------------------------------------- What is the meaning of * 'at the end of the word 'mkswap' ? Some files has @. What does this @ sign means? My swapfile is --> hda10@ |
OK, if you're sure /dev/hda10 is supposed to be your swap partition (if you're really REALLY sure!), then:
mkswap /dev/hda10 swapon /dev/hda10 |
Now I have a swap space or rather swap file on my system. Please read the following:
[nissanka@c83-250-90-204 nissanka]$ cd /proc [nissanka@c83-250-90-204 proc]$ cat meminfo MemTotal: 125304 kB MemFree: 1680 kB Buffers: 1000 kB Cached: 41940 kB SwapCached: 0 kB Active: 109404 kB Inactive: 2268 kB HighTotal: 0 kB HighFree: 0 kB LowTotal: 125304 kB LowFree: 1680 kB SwapTotal: 0 kB SwapFree: 0 kB Dirty: 36 kB Writeback: 0 kB Mapped: 104760 kB Slab: 8048 kB Committed_AS: 139220 kB PageTables: 1156 kB VmallocTotal: 909236 kB VmallocUsed: 2564 kB VmallocChunk: 906256 kB [nissanka@c83-250-90-204 proc]$ Please tell me if the swap file is still inactive. |
I urge one of our experts to look at the output which I posted and provide me an answer. I am not good at these things.
|
The '@' normally means that your are looking at a symlink rather than an actual file/device. `ls -l` will show you where the symlink is referring to.
It would appear that your swap partition is still inactive. See the 'TotalSwap' field, that says 0Kb Perhaps you would like to post the output of `fdisk -l /dev/hda`. That way someone will be able to tell you if hda10 is indeed a swap partition. Then post the contents of /etc/fstab disclaimer: I am not much of an expert ;) |
Thanks Phill for the reply.
[nissanka@c83-250-90-204 nissanka]$ su root Password: [root@c83-250-90-204 nissanka]# fdisk -l /dev/hda Disk /dev/hda: 61.4 GB, 61492838400 bytesThe 'hda 10 ' is the boot partition and all my work lies on ' hda 9 ' partition. 255 heads, 63 sectors/track, 7476 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hda1 1 229 1839411 16 Hidden FAT16 /dev/hda2 * 262 390 1036192+ b W95 FAT32 /dev/hda3 391 7476 56918295 f W95 Ext'd (LBA) /dev/hda5 391 1832 11582833+ 7 HPFS/NTFS /dev/hda6 1833 3649 14595021 b W95 FAT32 /dev/hda7 3650 4802 9261441 b W95 FAT32 /dev/hda8 4803 6447 13213431 b W95 FAT32 /dev/hda9 6448 7219 6201058+ 83 Linux /dev/hda10 7220 7291 578308+ 83 Linux /dev/hda11 7292 7476 1485981 83 Linux [root@c83-250-90-204 nissanka]# It was 'hda11' is my swap partition. I made a mistake by saying it was 'hda10' . The 'hda 10 ' is the boot partition and all my work lies on ' hda 9 ' partition. |
Please post the contents of /etc/fstab
hda11 is 1.5Gb and hda10 is ~550Mb, and seeing your using Mandrake I would expect that your system is not installed on hda10. Which ever partition you intended to be your swap (I can tell you this from /etc/fstab) you need to change the partition type from 83 (Linux) to 82 (Linux Swap). You can do this with any partitioning tool. Once that has been done you can then do `mkswap ...` and `swapon ...`. For reference: Code:
# fdisk -l /dev/hda |
I have 128 MB of RAM.
My swap partition is unproportiantely large. So the system failed to recognize the swap partition. Am I correct? |
All my programs are on ' hda 9 ' partition.
[root@c83-250-90-204 etc]# cat fstab /dev/hda9 / ext2 defaults 1 1 /dev/hda10 /boot ext2 defaults 1 2 none /dev/pts devpts mode=0620 0 0 /dev/hdc /mnt/cdrom auto umask=0,user,iocharset=iso8859-1,codepage=850,noauto,ro,exec 0 0 /dev/hdd /mnt/cdrom2 auto umask=0,user,iocharset=iso8859-1,codepage=850,noauto,ro,exec 0 0 none /mnt/floppy supermount dev=/dev/fd0,fs=ext2:vfat,--,umask=0,iocharset=iso8859-1,sync,codepage=850 0 0 /dev/hda5 /mnt/win_d ntfs umask=0,nls=iso8859-1,ro 0 0 /dev/hda2 /mnt/win_h vfat umask=0,iocharset=iso8859-1,codepage=850 0 0 none /proc proc defaults 0 0 /dev/hda11 /tmp ext2 defaults 1 2 [root@c83-250-90-204 etc]# |
I believe this code was from a howto on sharing the same swap space with windows and linux. Is this your intention?
If not then I suggest changing the swap partition ID from 83 to 82 via fdisk and then formating the partition as previously stated. Does your /etc/fstab file have an entry for the swap partition? |
Futhermore,
Your /tmp is directory is mounted to /dev/hda11. Did you originally setup a swap partition? |
No, Windows and Linux are completely different on my system. Both are on the same harddrive.
They don't interfere with each other. I have posted the contents of the ' fstab' folder. Originally it was ' root ' , ' boot ' and ' tmp ' parttions. There were no swap partition. The problem is I don't know very much about those minute issues. |
OK, hda11 is currently being used for /tmp
so first of all unmount it Code:
umount /tmp Code:
/dev/hda11 /tmp ext2 defaults 1 2 Code:
fdisk /dev/hda Once that is done Code:
mkswap /dev/hda11 Code:
/dev/hda11 swap swap defaults 0 0 Do all of this in runlevel 3, or 1 to minimise the chance of something using /tmp whilst you unmount it |
All times are GMT -5. The time now is 10:09 PM. |