How to Edit Files in Maintenance Mode
Environment
OS Level: AIX Version 4.1.4
Type/Model: 590
Problem
The user was booted up in maintenance and could not access the vi
editor to edit a file.
Solution
Complete the following script and steps to allow editing in
Maintenance mode.
- From the mksysb install menu, select Option 3, System
Maintenance and Recovery.
- Select Option 3 again, Advanced Maintenance Functions.
- Select Option 0 to start a limited function maintenance shell. The
shell prompt Enter 'exit' to return$ will display.
- Enter the following commands exactly as they appear:
echo '> $1.new' >> kshedit
echo 'IFS="' >> kshedit
echo '"' >> kshedit
echo 'cat $1 |&' >> kshedit
echo 'if [[ -n $2 ]] then' >> kshedit
echo 'x=1' >> kshedit
echo 'while (( x < $2 )); do' >> kshedit
echo 'read -pr oldline' >> kshedit
echo 'print -r -- $oldline >> $1.new' >> kshedit
echo 'let x=x+1' >> kshedit
echo 'done' >> kshedit
echo 'fi' >> kshedit
echo 'while read -pr oldline ; do' >> kshedit
echo 'print -r -- $oldline' >> kshedit
echo 'read -r newline' >> kshedit
echo 'case $newline in' >> kshedit
echo 'q ) print -r -- $oldline >> $1.new' >> kshedit
echo 'while read -pr oldline ; do' >> kshedit
echo 'print -r -- $oldline >>$1.new' >> kshedit
echo 'done; exit;;' >> kshedit
echo '* ) if [[ -n $newline ]] then' >> kshedit
echo 'print -r -- $newline >> $1.new' >> kshedit
echo 'else print -r -- $oldline >> $1.new' >> kshedit
echo 'fi;;' >> kshedit
echo 'esac' >> kshedit
echo 'done' >> kshedit
This script, called kshedit, may be used to edit any text file in
Maintenance mode, including bi_main. The usage for the script is as
follows.
- Since the script does not have executable permissions, first enter
ksh, followed by the name of the file to edit, followed by the
line number of the file to edit. If you wish to edit the entire file,
do not specify a line number.
- The appropriate line of the file is displayed on the screen. If you
choose to edit this line, type in the new line and press Enter. If you
want to leave the line as it is, press Enter. The next line of the file
will display.
- You can continue to edit the file by entering new lines of text to
replace the displayed lines, or press q to end the edit session.
When you press q, the shell prompt will return and the rest of
the file will be left as it was originally.
- The new edited file will receive the same name as the original file
with a .new extension. For instance, after you edit line 27 of
the file image.data with the command kshedit image.data 27,
the new file will be named image.data.new. If desired, the new
file may then be copied over the original.
A sample edit
Let's assume you want to edit the line in the bi_main file that
makes the rootvg.
- Enter the command:
grep -n mkvg /usr/lpp/bosinst/bi_main
Output similar to the following displays:
3127: # durning mkvg. Reduce maxpvs by 4.
3134: mkvg -f -y $VG -s $PPS -d $MAXPVS $DISKS; rc=$?
- Enter the command:
ksh kshedit /usr/lpp/bosinst/bi_main 3134
After a few seconds, the following line displays:
mkvg -f -y $VG -s $PPS -d $MAXPVS $DISKS; rc=$?
- Type in the appropriate changes and press Enter. The next line will
display.
- Type q and press Enter to stop editing. This saves the edited
file as /usr/lpp/bosinst/bi_main.new.
- If you have finished editing files, type exit to return to
the menus.
[ Doc Ref: 95634889421114 Publish Date: Apr. 28, 2000 4FAX Ref: none ]