Need help in scripting to do repair in format tool of Solaris


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help in scripting to do repair in format tool of Solaris
# 1  
Old 02-23-2017
Need help in scripting to do repair in format tool of Solaris

Hi,

I posted my problem in Solaris forum, but I think, I am expecting a script, which should solve my purpose. I am not a scripting person, so need help here.

I am on Solaris 10, in failsafe mode. Manually I run format command and it takes me to options, I pick "repair" and enter, it waits for my input at "Enter absolute block number of defect:", here I need to give block number, which is 39594646. It asks for confirmation, I say Y and enter. It will take some time to repair and came back on "repair" prompt. I need to repeat same for block 39594646 to 585912500 so manual repairing is not possible. I need to say n also, if block is not defective.

Can somebody help me with this kind of script ?
Code:
# format c0t0d0
selecting c0t0d0
[disk formatted]


FORMAT MENU:
        disk       - select a disk
        type       - select (define) a disk type
        partition  - select (define) a partition table
        current    - describe the current disk
        format     - format and analyze the disk
        repair     - repair a defective sector
        label      - write label to the disk
        analyze    - surface analysis
        defect     - defect list management
        backup     - search for backup labels
        verify     - read and display labels
        save       - save new disk/partition definitions
        inquiry    - show vendor, product and revision
        volname    - set 8-character volume name
        !<cmd>     - execute <cmd>, then return
        quit
format>
format> repair
Enter absolute block number of defect: 39594665
Ready to repair defect, continue? y
Repairing hard error on block 39594665 (3167/11/290)...ok.

format> repair
Enter absolute block number of defect: 39594666
This block doesn't appear to be bad.  Repair it anyway? n
format>

# 2  
Old 02-23-2017
If I understand you correctly, you want to automate the input to the format tool.

You could try to use expect, which is made for this purpose. There should be a man-page for this, and you also find many examples for expect on the Net.

Note that expect is basically Tcl, which was extended with a special library, so you are then effectively doing Tcl-programming, not shell programming. Keep this in mind, when you get in trouble with the syntax of the commands: In this case, search the Net not only for "expect", but also for "Tcl".

I also recommend taking 15 minutes or so to get familiar with the Tcl language. It is simple, but not always obvious if you come from other languages.

# 3  
Old 02-23-2017
From experiemce: if more than 10 sectors are bad then you better go for a new disk.
# 4  
Old 02-23-2017
I am not knowledgeable on scripting, but will try to check, if I can figure out TCL.

I understand that disk is bad, though there are no errors in iostat. But we don't have backup for this server, so want to retain as much as data before replacing disk. I already got new disk from Oracle. Here is actual issue, which I mentioned in this post - Can I run repair on lot of blocks with single command ?
# 5  
Old 02-23-2017
Probably do two things initially:-
  • Get a backup of the data and the structure.
  • Run the analyze option and let it run to at least list out the errors. Make sure you choose the right sub-option so it is not destructive.

Make sure you replace the disk before you have a failure.


Robin
# 6  
Old 02-23-2017
On your other (now closed) thread you say:

Quote:
Somehow when one disk gone bad (c0t1d0), other disk (c0t0d0) also got lot of bad block.
This would make me see red. This shouldn't happen. I'd be checking whether the disks are over-heating, are the fans running, etc.

AFAIK a disk read test will not correct anything, only verify readability. That's what read means.

The system will boot into safe mode but not into multi-user.
I'm assuming the filesystem is ufs (??) and there is an (often little documented) option on fsck which will check literally everything on a filesystem:

Code:
# fsck -n -o full <filesystem device node>

Note the -n will ensure no modifications are attempted but the -o full will check everything and list files with errors. Make sure you capture the output as it may be long and take many hours to run. You should then know which files are affected and which to restore.

I appreciate that my comments above do not give you a coherent strategy for a fix but you might find them helpful. Hopefully you will get other input from other members.

Run a new backup as soon as you can.

Last edited by hicksd8; 02-23-2017 at 09:48 AM..
This User Gave Thanks to hicksd8 For This Post:
# 7  
Old 02-23-2017
You can feed format from stdin.
For example
Code:
echo "
0
partition
print
" | format

Now, if your disk is the first one (0), make a script "repair_sector"
Code:
#!/bin/sh
for arg
do
  echo "
0
repair
$arg
y
" | format
done

And you can run this with your absolute sectors as arguments.
Untested! of course.
This User Gave Thanks to MadeInGermany For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Solaris

BART tool on Solaris 10 - enable SHA256

Hi all, I am attempting to create a BART manifest on a Solaris 10 box; however, I need it to be hashed with SHA256. Normally, at the beginning of a "bart create" command, the version and date appear along with the type of encryption listed. When I run the command though I receive the... (3 Replies)
Discussion started by: Derk Berk
3 Replies

2. Solaris

Question with Solaris Crash Analysis Tool with Solaris 9

Hello all. I am new hear and would like to ask a question regarding to the Solaris Crash Analysis Tool. We are analyzing the results of "thread summary" but not quite sure what the asterisk represents. Following are the items that asterisk were attached. 50* threads sleeping on a semaphore (49... (1 Reply)
Discussion started by: YuW
1 Replies

3. Solaris

Is there a similar tool with authconfig of Linux on Solaris?

Hi Dears, I believe you know authconfig on most of Linux Distributions. However, on Solaris OS, I don't know the similar tool. Could you please share me the tool, if any? Note: I am using SunOS 5.10. (0 Replies)
Discussion started by: crest.boy
0 Replies

4. Shell Programming and Scripting

Need a ksh scripting tool

Hi guys, I am new in Unix/linux field. I need a >>tool which is running on windows xp and provide the >>Korn shell scripting environment. As I used cygvin, but it is bash shell and most of the command of unix is not supported by cygwin.:confused: please suggest..... :) thanks in... (9 Replies)
Discussion started by: atul9806
9 Replies

5. Solaris

Can fssnap be used as a compression tool (Solaris 10)?

Friends, I am learning the working of fssnap command. Suppose there is a directory named /datadir which is of size 500mb. I had taken the snapshot by means of the following command: #fssnap -F ufs -o bs=/snapshotdir /datadir { it shows the o/p as /dev/fssnap/0 } My question is if... (2 Replies)
Discussion started by: saagar
2 Replies

6. Infrastructure Monitoring

Network monitoring tool for Solaris 10

Hi All, I was wondering if there is any Network Monitoring Tool for Solaris 10 to monitor a network having hybrid operating systems. I just googled it without success. Hope, experts will guide me to get it. Thanks, Deepak (7 Replies)
Discussion started by: naw_deepak
7 Replies

7. Solaris

Network monitoring tool for Solaris 10

Hi All, I was wondering if there is any Network Monitoring Tool for Solaris 10 to monitor a network having hybrid operating systems. I just googled it without success. Hope, experts will guide me to get it. Thanks, Deepak (0 Replies)
Discussion started by: naw_deepak
0 Replies

8. Shell Programming and Scripting

New tool for shell scripting

Hi All, It's quite long time....m comming to my favourite forum.. Can anyone suggest me good tool like eclipse for Java....do we have anything for Shell scripting..where n i can atlease prepare script...rather than typing all mistakes in Linux box :) Thanks Sha (1 Reply)
Discussion started by: Shahul
1 Replies

9. Solaris

Solaris Performance Monitoring Graphing Tool

Hi All Anyone out there using any graphing tool for Solaris performance data taken either through SAR utility or iosatat, vmstat, nicstat etc. There are a couple on googling like statsview and rrdtool but not sure if anyone is really happy and satisfied with using any of the graphing tool. ... (1 Reply)
Discussion started by: baner_n
1 Replies
Login or Register to Ask a Question