1837979 Members
2943 Online
110124 Solutions
New Discussion

Re: fsck

 
Otto Folprecht
Advisor

fsck

Hi, I need to take the system down into sigle mode. When I do that I need to run fsck on the /var and /usr. Since the only way to do that is to crash the system (the story is long why) what is the correct syntax for the fsck command to recover /var and /usr. THX Otto
5 REPLIES 5
Paul Eadington_1
Valued Contributor

Re: fsck

fsck -F {filesystem_type} -o {options} /dev/vg??/lvol??

Assuming your /var was /dev/vg00/lvol7, is a vxfs filesystem and you wanted to do a full check.

fsck -F vxfs -o full -y /dev/vg00/lvol7

The -y assumes a yes response to any prompts that would be flagged.

try man fsck to see the full list of options.

Hope this helps.
I had hair .. then I got into Unix
A. Clay Stephenson
Acclaimed Contributor

Re: fsck

Well, the first thing to do is a 'bdf' command to identify the devices associated with those filesystems or do a cat /etc/fstab. The cat /etc/fstab should also tell you the type of filesystem: vxfs (most likely) or hfs.

Here is an example:
fsck -F vxfs -y /dev/vg00/rlvol7

man mount_vxfs for details.

I assume you have lost the root passwd.
If it ain't broke, I can fix that.
Hoang Chi Cong_1
Honored Contributor

Re: fsck

Hi Otto
You can follow these steps:

1. mount -v
Start this command to determine which file systems are mounted where.
For example:
/dev/vg00/lvol8 on /var type vxfs delaylog on Sun Dec 19 03:39:02 2003
/dev/vg00/lvol7 on /usr type vxfs delaylog on Sun Dec 19 03:39:02 2003

2. umount /dev/vg00/filesystem
umount /dev/vg00/lvol8
umount /dev/vg00/lvol7
fsck should be run on quiescent file systems; unmount the file system before proceeding.
3. fsck -F -y vxfs /dev/vg00/lvol8
or : fsck -F -y hfs /dev/vg00/lvol7
This depend on what kind of your filesystem...

4. Remount the filesystem
mount /dev/vg00/lvol8
mount /dev/vg00/lvol7
Once fsck completes, remount the file system(s).
5. Restore any corrupted files.
In order to fix file system corruption, fsck may have to remove one or more files. Watch for "REMOVE" messages in the fsck output, and be sure to restore the affected files from tape.fsck may also RECONNECT orphaned files. If you see any RECONNECT messages, check the file systemâ s lost+found directory. The next slide discusses the lost+found directory in greater detail.


Hope this helps
regard,
HoangChiC
Looking for a special chance.......
Nguyen Anh Tien
Honored Contributor

Re: fsck

Full syntax of fsck is
/usr/sbin/fsck [-F FSType] [-m] [-V] [special ...]
/usr/sbin/fsck [-F FSType] [-o FSspecific-options] [-V] [special ...]
In order to determine FStype you check
#cat /etc/fstab
[ipcaspa:/] cat /etc/fstab
/dev/vg00/lvol3 / vxfs delaylog 0 1
/dev/vg00/lvol1 /stand hfs defaults 0 1
/dev/vg00/lv_swap1 ... swap pri=0 0 0
/dev/vg00/lvol4 /tmp vxfs delaylog 0 2
/dev/vg00/lvol5 /home vxfs delaylog 0 2
/dev/vg00/lvol6 /opt vxfs delaylog 0 2
/dev/vg00/lvol7 /usr vxfs delaylog 0 2
/dev/vg00/lvol8 /var vxfs delaylog 0 2
#/dev/vg00/lvtux /home/tux6.5 vxfs rw,suid,nolargefiles,delaylog,datainlog 0 2
/dev/vg00/lvora /home/oracle vxfs rw,suid,nolargefiles,delaylog,datainlog 0 2
/dev/vg00/lvkeb /keb vxfs rw,suid,nolargefiles,delaylog,datainlog 0 2
/dev/vg00/lv_swap2 ... swap pri=0 0 2
-m : sanity check only
In order to get special you pay attention on first field of /etc/fstab
2. You want fsck check /var. just type (/var must not be mounted)
#fsck -F vxfs -m /dev/vg00/lvol8
HP is simple
Michael D. Zorn
Regular Advisor

Re: fsck

If you have hfs, the "fsck -F hfs /dev/vg00/rlvol12" (or whatever) will either finish quickly and report something like "file system clean", or it will go into a sequence of error messages, after each one, "CLEAR?" or "FIX" (or something like that). Reply "y" to each. Don't forget the "r" in "rlvolNN"

The worst case is when it says "bad superblock - try another one". You can try "-b 16" (that's our usual default alternate superblock), but even if that works, it's not really reliable (my experience).

Sometimes there will be hundreds of the "CLEAR?" (or "FIX?") messsages. If you find more than a dozen or so, run fsck with "-y" (reply Y to all of them). This is sort of a last resort. I used it a while ago ; the fsck ran overnight (probably 6 to 8 hours), and when it was done, a regular fsck reported OK, but the data was gone.

In that case, it would have been quicker to do a newfs followed by a restore.

I hope you can recover to where you can do a regular "shutdown"