Popular Posts

Showing posts with label Solaris11. Show all posts
Showing posts with label Solaris11. Show all posts

Aug 26, 2019

vi cheat sheet & vi basic commands

vi cheat sheet & vi basic commands


APPLIES TO :  Oracle SPARC Solaris and all unix OS

ISSUE : 

GOAL :  Easy reference to work in vi editor

SOLUTION :  


     1. To Move the cursor left  in vi editor
                 Press h
                 Press 5h - to move the cursor 5 characters left

     2. To Move the cursor right  in vi editor
                 Press l
                 Press 5l - to move the cursor 5 characters right

     3. To Move the cursor down  in vi editor
                 Press j
                 Press 5j - to move the cursor 5 lines down

     4. To Move the cursor up  in vi editor
                 Press k
                 Press 5k - to move the cursor 5 lines up

     5. To move the cursor to the right one word at a time in vi editor
                 Press w (“word”)
                 Press 5w - to move the cursor 5 words right

     6. To move the cursor to the left one word at a time  in vi editor
                 Press b (“back”)
                 Press 5b - to move the cursor 5 words left

     7. To move the cursor to the last character of the current word in vi editor
                 Press e (“end”)

     Moving to Start or End of Line
     8. To move the cursor to the start of the current line in vi editor
                 Press ^ or Press 0

     9. To move the cursor to the end of the current line in vi editor
                 Press $

     10. To move the cursor to the beginning of the next line down in vi editor
                 Press the Return key

     11. To move the cursor one character to the left in vi editor
                 Press the Back Space key

     12. To move the cursor one character to the right in vi editor
                 Press the Space Bar

     13. To move the cursor to the top of the screen in vi editor
                 Press H (“high”)

     14. Move to the first non-blank character of the line in vi editor
                 Press ^

     15. Jump forward one sentence in vi editor
                 Press )

     16. Jump backward one sentence in vi editor
                 Press (

     17. Jump forward one paragraph in vi editor
                 Press }

     18. Jump backward one paragraph in vi editor
                 Press {

     19. Jump to the middle of the screen in vi editor
                 Press M

     20. Jump to the bottom of the screen in vi editor
                 Press L

     21. Move the cursor to the end of file  in vi editor
                 Press G

     22. To create line numbers at the beginning of file  in vi editor
                 :set number

     23. Append or add a text next to the cursor in vi editor
                 Press a and type your content and press esc when finished

     24. Insert a text at the left of the cursor in vi editor
                 Press i and type your content and press esc when finished.

     25. Insert new line below the cursor  in vi editor
                 Press o

     26. Insert new line above the cursor  in vi editor
                 Press O

     27. Undoing a previous command or a change  in vi editor
                 Press u

     28. Undo all changes made to a line in vi editor
                 Press U

     29. To delete one character, position the cursor over the character to be deleted in vi editor
                 Press x

     30. To delete a word, place the cursor at the beginning of the word in vi editor
                 Press dw

     31. To delete a line, place the cursor anywhere on the line in vi editor
                 Press dd

     Copying Lines
     32. To Copy a line, place the cursor anywhere on the line  in vi editor
                 Press yy

     33. Paste the copied line, place the cursor above the line we need to paste in vi editor
                 Press p
                 Press P - paste the copied line to the above line


     Searching and Replacing
     34. Search a string in vi editor
                 :s/string
                 The first match of your string will be highlighted, Type n to see the additional occurance of nex match.

     35. Search and Replace a string in a line in vi editor
                 :s/pattern/replace/
                 This will replace the pattern with replace in the current line

     36. Search and Replace a string in a entire file in vi editor
                 :%s/pattern/replace/
                 This will replace every occurance of pattern with replace



~Judi~

Nov 9, 2018

Replace a ZFS Root Pool to another disk


Replace a ZFS Root Pool to another disk


APPLIES TO : Solaris 11.3 LDOM

ISSUE : Server is running in 100GB OS LUN, need to move the OS to another disk provided from another array. 

GOAL :  Replace a ZFS Root Pool with another disk, Move the OS LUN to the disk provided from another Storage Array

SOLUTION :  Attach the secondary disk in zpool, boot the server in both disks, detach the primary disk.

EXAMPLE :  

1.      Verify the secondary disk c1d1 is visible in format output
                root@judi-dev-01:~# echo | format
                Searching for disks...done
                
                AVAILABLE DISK SELECTIONS:
                       0. c1d0 <3PARdata-VV-3212-100.00GB>
                          /virtual-devices@100/channel-devices@200/disk@0
                       1. c1d1 <3PARdata-VV-3212-100.00GB>
                          /virtual-devices@100/channel-devices@200/disk@1
                Specify disk (enter its number): Specify disk (enter its number):

                root@judi-dev-01:~#

2.      Check the zpool list
                root@judi-dev-01:~# zpool list
                NAME    SIZE  ALLOC   FREE  CAP  DEDUP  HEALTH  ALTROOT
                rpool  99.5G  9.37G  90.1G   9%  1.00x  ONLINE  -

                root@judi-dev-01:~#

3.      Check the zpool Status
                root@judi-dev-01:~# zpool status
                  pool: rpool
                 state: ONLINE
                  scan: resilvered 7.37G in 30s with 0 errors on Thu Nov  8 11:51:10 2018

                config:

                        NAME    STATE     READ WRITE CKSUM
                        rpool   ONLINE       0     0     0
                          c1d0  ONLINE       0     0     0

                errors: No known data errors

                root@judi-dev-01:~#

4.      Verify the bootdisk path (The server booted with disk@0)
                root@judi-dev-01:~# prtconf -vp | grep bootpath
                        bootpath:  '/virtual-devices@100/channel-devices@200/disk@0'

                root@judi-dev-01:~#

5.      Attach the secondary disk c1d1 to zpool
                root@judi-dev-01:~# zpool attach rpool c1d0 c1d1
                Make sure to wait until resilver is done before rebooting.

                root@judi-dev-01:~#

6.      Check the status of the pool, Wait till the resilvered completes 
                root@judi-dev-01:~# zpool status
                  pool: rpool
                 state: ONLINE
                  scan: resilvered 7.37G in 34s with 0 errors on Thu Nov  8 12:34:45 2018

                config:

                        NAME        STATE     READ WRITE CKSUM
                        rpool       ONLINE       0     0     0
                          mirror-0  ONLINE       0     0     0
                            c1d0    ONLINE       0     0     0
                            c1d1    ONLINE       0     0     0

                errors: No known data errors

                root@judi-dev-01:~#

7.      Apply the boot blocks after the new disk is resilvered 
                root@judi-dev-01:~# bootadm install-bootloader

                root@judi-dev-01:~#

8.      Bring down the server to OK Prompt (OBP)
                {0} ok show-disks
                a) /reboot-memory@0
                b) /virtual-devices@100/channel-devices@200/disk@1

                c) /virtual-devices@100/channel-devices@200/disk@0

9.      Boot the server with secondary disk from OK Prompt (OBP) [Now server is booting with disk@1]
                {0} ok boot /virtual-devices@100/channel-devices@200/disk@1
                Boot device: /virtual-devices@100/channel-devices@200/disk@1  File and args:
                SunOS Release 5.11 Version 11.3 64-bit
                Copyright (c) 1983, 2018, Oracle and/or its affiliates. All rights reserved.

                Hostname: judi-dev-01

10.      Verify the bootdisk path (The server should have booted through the secondary disk disk@1)
                root@judi-dev-01:~# prtconf -vp | grep bootpath
                        bootpath:  '/virtual-devices@100/channel-devices@200/disk@1'

                root@judi-dev-01:~#

                IF YOU FACE ANY ISSUE IN BOOTING THE SERVER IN SECONDARY DISK THEN ROLL BACK THE CHANGE BY BOOTING THE SERVER WITH PRIMARY DISK
                /virtual-devices@100/channel-devices@200/disk@0

                FOLLOW THE BELOW PROCEDURE IF YOU THE SERVER BOOTS IN SECONDARY DISK WITHOUT ANY ISSUE.

11.      Check the zpool Status
                root@judi-dev-01:~# zpool status
                  pool: rpool
                 state: ONLINE
                  scan: resilvered 7.37G in 34s with 0 errors on Thu Nov  8 12:34:45 2018

                config:

                        NAME        STATE     READ WRITE CKSUM
                        rpool       ONLINE       0     0     0
                          mirror-0  ONLINE       0     0     0
                            c1d0    ONLINE       0     0     0
                            c1d1    ONLINE       0     0     0

                errors: No known data errors

                root@judi-dev-01:~#

12.      Detach the old(primary) disk c1d0 from the pool, since the server is booting without any issue from the secondary disk.
                root@judi-dev-01:~# zpool detach rpool c1d0

                root@judi-dev-01:~#

13.      Check the status of the zpool, the zpool contains only the secondary disk
                root@judi-dev-01:~# zpool status
                  pool: rpool
                 state: ONLINE
                  scan: resilvered 7.37G in 34s with 0 errors on Thu Nov  8 12:34:45 2018

                config:

                        NAME    STATE     READ WRITE CKSUM
                        rpool   ONLINE       0     0     0
                          c1d1  ONLINE       0     0     0

                errors: No known data errors

                root@judi-dev-01:~#

14.      reboot the server again to confirm the change is successful and the bootdisk path.
                root@judi-dev-01:~# prtconf -vp | grep bootpath
                        bootpath:  '/virtual-devices@100/channel-devices@200/disk@1'

                root@judi-dev-01:~#



Known Errors :  You may be getting the below error while booting the server from secondary disk.
                {0} ok boot /virtual-devices@100/channel-devices@200/disk@1
                Boot device: /virtual-devices@100/channel-devices@200/disk@1  File and args:

                ERROR: Last Trap: Fast Data Access MMU Miss

                After attaching the secondary disk you might have used the installboot command as below.
                installboot -F zfs /usr/platform/`uname -i`/lib/fs/zfs/bootblk /dev/rdsk/cwtxdys0
                This command is incorrect to use in this procedure, 
                
                the correct caommnd to install the bootblock is 
                bootadm install-bootloader










~Judi~


Solaris Root Mirror
zpool detach disk and boot
zpool replace disk
Replace a ZFS Root Pool
single disk root pool
solaris 11 zpool mirror
zpool mirror replace disk
zpool mirror status

zpool mirror rpool
Replace a ZFS Root Pool to another disk



Popular Posts