corrupted swap file

CALV

Distinguished
May 17, 2001
1,731
0
19,780
Hi all,

Logged out of kde yesterday (was in as root) tried to log in as myself and it just kept flicking back to the logon screen, tried to go back as root and it did the same, rebooted, then it stopped before the gui logon screen saying it was about to reboot- it didnt reboot, just landed at the console, no probs, my counterstrike server still fires up from console which was the main thing yesterday!, but i really need my gui back, I put startx, but got a lot of errors which I dont understand. I then tried to edit on of my server config files- basically a text file, but when I tried to save it (using VI) I put esc wq and it said it couldnt write due to a problem with my swap partition, is there a way to rebuild this?


Next time you wave - use all your fingers
 
you can rebuild your swap partition by booting single user mode, then typing <b>swapoff</b> to turn the swap off.

Then you type <b>mkswap -c <your swap partition></b> eg mkswap -c /dev/hda2

The <b>-c</b> checks for bad blocks.

Then type <b>swapon -a</b> and it should reactivate the swap.

Are you sure this is the problem though? I think vi makes it's own little swap file when you edit a file. Before doing the above stuff, cd to the directory in question and ls -a to see if there's a ~yourfile file (a backup of the edited file). If there is, remove it, and try editing again.
 
Thanks a lot for the info, Im a fairly newbie at linux and thought there must be a way to rebuild it.
The files I was editing (or trying to) were config files for my counterstrike server, one was motd.txt one was server.cfg, I tried a few more too, when VI'ing any of these I got the error that it couldnt write to the swap file, so i exited. I was in the current directory at the time, and ls showed the files, but also what I presume are backup files, for example I have a motd.xtx and now also a motd.txt~ , the others also have a ~ at the end. My counterstrike server still works, BUT, I cant get to a graphical logon screen, it just sends me back to level 3- not a great problem but I would like the option of gui as I find some things easier that way.


Next time you wave - use all your fingers
 
yes, those are the back up files. sorry i typed it round the wrong way... if you're not allowed to write to the file, check your permissions too. do you need to be root to edit those files (or the backup files)?

have a look at the XFree86.0.log file in /var/log/ and that might tell you why your X keeps crashing out.

<P ID="edit"><FONT SIZE=-1><EM>Edited by rjb263 on 09/21/01 06:58 AM.</EM></FONT></P>
 
Thanks again, the files are accesable by root (obviously) and also by "calv" which is the only other user on there. I'll have a look at the log file when I get home and see if I cant fix it, if not I'll have to reinstall I suppose- still, its all part of the learning process.
You dont know of a utility to clone an ext2 drive do you? Norton ghost 2001 is supposed to but it doesnt see the drive, it would be ideal for me to be able to do that.
Thanks again for the help


Next time you wave - use all your fingers
 
i've backed up partitions using tar and bzip2 before, but it's more like winzip than ghost... i dunno what the best solution is for you.

what i was thinking earlier was that you were logged in as root, and you changed something like those config files, and the backup file owner:group was set up as root:root, which calv probably won't be able to delete or modify. hence the "can't write" error.

kinda hard to figure this stuff out over the net...

Good luck anyways.
 
ahh right, I get what you mean now about not being able to write the file if you dont have the right permissions, as I said Im fairly new to linux, I would have (wrongly) assumed it would have simply said that I dont have permission- this is what happens when I try to cd into a directory I dont have permission to adccess.


Next time you wave - use all your fingers
 
You can use "dd" to peel a raw image of the disk, then send the output on-the-fly to bzip2 or gzip (preferably bzip2). That's basically what ghost does to peel a raw partition (where it doesn't understand the fs).

Tarring and then gzipping/bzip2'ing into a single tarball file also works well--you just have to be sure to tell tar to omit certain directories (like /tmp, /usr/tmp, /var/tmp, /proc, and others as you see fit) and to omit the file you're writing the archive to. You also have to remember to set up your boot loader all over again once you restore a tarballed backup.

Kelledin

"/join #hackerz. See the Web. DoS interesting people."
 
well, I never managed to fix the swap file so I reinstalled lol, but thanks for the tip, maybe I will need to do that one day, as for ghosting the drive, if I make a giant tarball, and then have a system crash, how will I get it back as I will need linux installed in the first place to untar it?

Next time you wave - use all your fingers
 
I came across this little app called "Partition Image" at <A HREF="http://www.partimage.org" target="_new">www.partimage.org</A> which is getting pretty close to being Ghost for linux.

Might be a useful tool.
 
Just some humor...
Famous last words:
#dd if=/tmp/stuff of/dev/hda1 bs=512


"If you teach a child to read, then he or her will be able to pass a literacy test" - George W.