Operating System - HP-UX
1833304 Members
2858 Online
110051 Solutions
New Discussion

Re: vi commands in Single user mode

 
SOLVED
Go to solution
Stuart Lloyd_2
Advisor

vi commands in Single user mode

HP11 on a D Class 9000. Bad disk. Botted up into single user mode to edit fstab. vi doesn't play nice. I can't write to the fstab to comment out the disk. Any clues?
Charlie don't surf.
22 REPLIES 22
G. Vrijhoeven
Honored Contributor

Re: vi commands in Single user mode

Hi,

To use vi you must mount /var and /usr first.

Gideon

doug mielke
Respected Contributor

Re: vi commands in Single user mode

Or use ed.
it's still in user, but is more self contained, where vi has some dependencies which also need to be available.
Pete Randall
Outstanding Contributor

Re: vi commands in Single user mode

Stuart,

Just do a "mount -a", then proceed as normal.


Pete

Pete
Stuart Lloyd_2
Advisor

Re: vi commands in Single user mode

/var and /usr are mounted. The vi session starts up but it will not save changes doing a wq! for some reason.
Charlie don't surf.
Jeff Schussele
Honored Contributor

Re: vi commands in Single user mode

Hi,

How about a w! THEN a q?

Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
G. Vrijhoeven
Honored Contributor

Re: vi commands in Single user mode

HI,

Thats strange. Does the bad disk contain vg00. You can try to move the /etc/fstab to /etc/fstab.org and create a new one. That one will be on different blocks. If so i hope you have mirroring.

Gideon
Jeff Schussele
Honored Contributor

Re: vi commands in Single user mode

Oh & another thing just crossed my mind (it's a short trip ;~))....run stty -a before you start the vi session & make sure "!" is not a control character for the term type defined & verify your term type while you're at it.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Stuart Lloyd_2
Advisor

Re: vi commands in Single user mode

Tried the w1 and then q... nada.

The disk contains vg01.
Charlie don't surf.
Pete Randall
Outstanding Contributor

Re: vi commands in Single user mode

Stuart,

How about ?


Pete

Pete
Sean OB_1
Honored Contributor
Solution

Re: vi commands in Single user mode

If you are in a hurry use sed to modify the line into a new file and then cp it to fstab.

Stuart Lloyd_2
Advisor

Re: vi commands in Single user mode

Tried that too.

esc esc then
shift : then
wq! or
w! or
write or
write!

The only things that works are wq! (which doesn't write it just quits), q, and q!. So, I can quit the editor I just can't write to the file.
Charlie don't surf.
G. Vrijhoeven
Honored Contributor

Re: vi commands in Single user mode

Hi,

The sed option:

#cat /etc/fstab | sed 's%/dev/vg01%#/dev/vg01%' >>/etc/fstab.new && mv /etc/fstab.new /etc/fstab

But is does not explain the vi, Jeff's remark can.

Gideon
Jeff Schussele
Honored Contributor

Re: vi commands in Single user mode

What are the perms on the fstab file?
They should be 644 - if not chmod it & try it again.
You only need the ! when there are no write perms on the file.
So you *should* be able to use just "w" w/o the bang.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Pete Randall
Outstanding Contributor

Re: vi commands in Single user mode

Stuart,

After you check out the permissions, try writing to a test file just to make sure that it's not a problem with vi.


Pete

Pete
Todd McDaniel_1
Honored Contributor

Re: vi commands in Single user mode

I would also mount /tmp if your /var/tmp is linked to /tmp...

also, to save you can use shift ZZ NO COLON just shift ZZ gets you out if you had made changes... it saves and quits.


VI FAQ
http://www.faqs.org/faqs/editor-faq/vi/part2/

ZZ write (only if changes have been made) and quit
Unix, the other white meat.
Stuart Lloyd_2
Advisor

Re: vi commands in Single user mode

sed worked. Thanks. New fstab was moved into place and I rebooted. Machine still hung up. Error stated that /dev/dsk/c0t8d0 could not be found and then it locked up. 8 is the bad disk. New question: What else gets read on bootup other than fstab that I need to edit in order for it to bypass said disk and bootup into normal mode?
Charlie don't surf.
Jeff Schussele
Honored Contributor

Re: vi commands in Single user mode

Hi Stuart,

The actual disk-to-VG map is in /etc/lvmtab - BUT you can't edit it as it's a binary file.
You can rename/move it & run vgscan -av to create a new file however.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Stuart Lloyd_2
Advisor

Re: vi commands in Single user mode

Jeff,

How long does it take to create the new file? It's been chugging away now for about 10 minutes.
Charlie don't surf.
G. Vrijhoeven
Honored Contributor

Re: vi commands in Single user mode

HI again,

It would not take long ( depending on the number of disks you have). You best start with a vgscan -vpa ( preview ) and it it makes a difference mv the lvmtab and recreate it.

Gideon
Jeff Schussele
Honored Contributor

Re: vi commands in Single user mode

Shouldn't take too long unless you have a LOT of LUNs visible to the HBAs on this system.

Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Todd McDaniel_1
Honored Contributor

Re: vi commands in Single user mode

VGscan on my box with over 1000 luns takes 15 mins or more, maybe around 20...
Unix, the other white meat.
Sridhar Bhaskarla
Honored Contributor

Re: vi commands in Single user mode

Stuart,

I wouldn't do a vgscan. Even after recreating the /etc/lvmtab, it is still going to complain that lvmtab had fewer disk whereas than kernel.

If vg00 is not affected, then you can edit /etc/lvmrc and make AUTO_VG_ACTIVATE=0. This will not enable volume groups during the boot process. Once the system is up, you can activate all the volume groups except vg01. You can replace the bad disk in vg01 and then run a vgcfgrestore to get rid of lvmtab issue. You will miss the data but that's the safeway to do it.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try