Chinaunix首页 | 论坛 | 博客
  • 博客访问: 115905
  • 博文数量: 9
  • 博客积分: 1485
  • 博客等级: 上尉
  • 技术积分: 310
  • 用 户 组: 普通用户
  • 注册时间: 2007-11-07 10:09
文章分类

全部博文(9)

文章存档

2009年(2)

2008年(7)

我的朋友

分类:

2008-05-06 14:15:25

原文来自一个外国朋友的网站链接

ADD A NEW LVM DRIVE

1.  If the disk was previously used with LVM, run mediainit to clear existing informations on the drive:
      $ mediainit /dev/rdsk/c1d0s2  
      Now, the disk has to be readied for LVM.
      $ pvcreate -f /dev/rdsk/c1d0s2           |  PVRA and VGRA are laid on disk
2.  Create the Volume Group (VG):
      $ mknod /dev/vg01/group c 64 0x010000
        (This is the group number in hex. For vg02, that  number would be 0x020000.)
        ( Range= 00 to 09 set by kernel-parameter maxvgs)
      $ vgcreate /dev/vg01 /dev/dsk/c1d0s2
    NOTE 1: specify max_pe here - It cannot be changed later on
    NOTE 2: max_pe limit for boot device: 5628 !!!! (5628x4mb=~20gb)
                    Not 65535 as mentionned in man page
3.  Create the Logical Volume (LV)
      $ lvcreate -L 120 /dev/vg01                          | create volume lvol1 and rlvol1 of 120MB
      $ lvcreate -l 30 /dev/vg01                             | create volume of 30 x 4MB=120MB
      $ lvcreate -L 120 -n marketing /dev/vg01    | create volume /dev/vg01/marketing
 
      $ newfs /dev/vg01/rlvol1 C2474S         | Use /etc/disktab to determine the proper disk
                                                               | At rev 10, no need to use disk model
4.  Mount the Logical Volume:
      $ mkdir /newdisk
      $ mount /dev/vg01/lvol1  /newdisk
5.  Save the lvm -configuration:
      $ vgcfgbackup vg01                            | done automatically at rev 10/11


INCREASE the size of a log. volume from xxx Mb to yyy Mb:
     $ lvextend -L yyy /dev/vg01/lvol1
                   (yyy= size of the new log volume in Mb.)
     $ umount /mountdir
     $ extendfs /dev/vg01/rlvol1
     $ mount /dev/vg01/lvol1 /mountdir
 

REMOVING A LVM LOGICAL VOLUME
- Backup all user data

    # lvdisplay  -v  /dev/vgXX/lvol*    | find name of logical  volume  on the volume group
    # cd ; umount  /dev/vgXX/lvolY    | unmount logical volume
    # lvremove  /dev/vgXX/lvolY         | remove logical volume

REMOVE A LVM VOLUME GROUP
- Backup all user data

    # lvdisplay  -v  /dev/vgXX/lvol*      | find name of all logical  volumes on the volume group
    # cd ; umount  /dev/vgXX/lvolY  | unmount all logical volume
    # lvremove  /dev/vgXX/lvolY     | remove one by one log. vol.

Case 1 : Volume group spans only one physical drive
    # strings /etc/lvmtab               | one device file per volume group
    # vgremove  /dev/vgXX
    # rm /dev/vgXX                        | delete /dev entries, vgremove will not do it !!!

Case 2 : Volume group spans multiple physical drives
    # strings  /etc/lvmtab          | multi device files per volume group
    # vgreduce  /dev/vgXX   /dev/dsk/cYdZsW    | REDUCE ALL BUT ONE PHYSICAL VOLUME!!!
    # vgremove  /dev/vgXX       | remove last physical volume
    # rm  /dev/vgXX                     | delete /dev entries, vgremove will  not do it !!!

 INCREASE PRIMARY SWAP:
  Because of the Contiguous Allocation policy, we have to create a bigger   lvol and modify the BDRA to make it primary.
 
     $ lvcreate -C y -L xxx  /dev/vg00     | This new lvol HAS to be in vg00
     $ lvlnboot -v /dev/vg00
           This will display the current root and swap volumes
           (Note: lvol2 is the default primary swap.)
     $ lvrmboot -s /dev/vg00                  | remove the swap link to the  current primary swap.
     $ lvlnboot -s  /dev/vg00                  | create a swap link  with the new lvol.
     $ lvlnboot -R /dev/vg00                   | to relink everything
     $ vi /etc/checklist or /etc/fstab         | update /etc/checklist or /etc/fstab
     $ shutdown -r 0                               | reboot


 Expanding VxFS

CAUTION : THIS MAY NOT WORK IF THE FILE SYSTEM IS ALREADY AT 100%(ERROR 28). You will need to remove or copy some files before you attempt this operation !!

If you are not using logical volumes, you can readily increase the size of a VxFS file system, provided additional disk space is available on the device where the file system resides. If the file system is contained within a logical volume, the logical volume may first need to be extended to provide the additional space.
You can perform these actions while the file system is online and in use.
If you are using logical volumes, here are the specific steps to follow:

   1. Determine how much to increase the size of the file system.
   2. Extend the logical volume to the above size.
      For example, suppose the file system you want to expand is /home and the file  system resides in the logical volume /dev/vg4/users_lv. The current file system  size is 50MB as verified by running bdf. You want the new file system as well as  logical volume size to be 72MB. Enter:

      lvextend -L 72 /dev/vg4/users_lv
      Be sure to specify the new size you want the logical volume to be, not the size of  the increment.
   3. Determine the appropriate number of 1K blocks to use. In this case, since the block is of size 1K, the correct number is 72 times 1024 = 73728.
   4. Once you have extended the logical volume, you can expand the file system to the same size, specifying the above number of blocks with the -b option of fsadm(1M):

      fsadm -b 73728 /home
      Upon completing these steps, you should verify that the file system's superblock reflects the expansion. You can do this by entering bdf, df, or fsadm -E.


Contracting VxFS

You may want to shrink a file system that has been allocated more disk space than will be
needed, allowing that disk space to be freed up for some other use. Using the fsadm
command will shrink the file system provided the blocks it attempts to deallocate are not
currently in use; otherwise, it will fail. If sufficient free space is currently unavailable, file
system defragmentation of both directories and extents, previously described, may enable
you to consolidate free space toward the end of the file system, allowing the contraction
process to succeed when subsequently retried.

For example, suppose your VxFS file system now has a total of 90,000 blocks allocated.
However, you decide you really only need 60,000 with an additional 10,000 blocks for
reserve space. As a result, you wish to resize the file system to a new size of 70,000
blocks. Use fsadm with the -b option to specify the new size of the file system:

fsadm -b 70000 /home

Using a Snapshot File System for Online Backup Purposes
 
Determining the Size for Your Snapshot File System
The snapshot file system holds only those data blocks from the original file system that change between the time the snapshot is created and the time that it is unmounted.
Typically, as an upper bounds, 15 percent of a busy file system might change during the course of a day. This is only an approximate figure.
Creating Your Snapshot File System
Suppose you decide to create a snapshot for a file system that now uses 180,000 blocks of size 1K.
Assume you determine that the snapshot should allow for changes to 20,000 blocks.
    1. First, select a device or create a logical volume to contain the snapshot.
In this example, you decide to create a logical volume named snap_lv in the existing volume  group vg4. Assuming a block size of 1024 bytes, you will need to create a logical volume of  approximately 20MB.
      lvcreate -L 20 -n snap_lv /dev/vg4
    2. Create the mount point directory for the snapshot file system.
      mkdir /backuphome
    3. Now create the snapshot file system using the -o snapof= option to the mount command.
      mount -F vxfs -o snapof=/dev/vg4/orig_lv /dev/vg4/snap_lv /backuphome
      This command means: create a snapshot of the file system in /dev/vg4/orig_lv to reside  in the logical volume /dev/vg4/snap_lv mounted at /backuphome.
      If your snapshot file system runs out of space to hold copies of changed blocks, the system will disable it and the following message will be displayed:
xxx snapshot file system out of space.

If this happens, do the following:
    1.Unmount the snapshot.
    2.Create a new snapshot file system. Since you underestimated the needed size of the
      snapshot, you will probably want to create a larger snapshot.
Once a snapshot file system is unmounted, it will no longer exist and cannot be recovered. In order to unmount your original file system, you will first need to unmount its corresponding snapshot.
Performing the Online Backup
Once you are ready to perform an online backup using the snapshot file system, use vxdump(1M) or standard backup utilities such as tar(1) or cpio(1) to complete the backup. (If you wish to preserve your files extent attributes, you must use vxdump. Extent attributes are described in the next section.) Complete details for using backup utilities are covered in Chapter 9, "Backing Up and Restoring Data".
 

 EXPORTING A VOLUME GROUP ( AND ITS DISKS ) TO RELOCATE THEM ON ANOTHER SYSTEM
 
This allows you to remove a volume group from the system without modifying the Logical Volume information on the Physical Volumes ie; disks.
The information about the group and logical volumes, plus all the data can be retained on the disk(s) and the disk(s) can be relocated on another system.

The "vgexport" command sequence is also a good way to de-configure a volume group and to cleanly remove all traces of its configuration from the system.

# tar -cvf /dev/rmt/0m  >
        Backup the data before you export the group. The exporting & importing
        of a group will retain the data on the disks but let's be extra  careful!!
# vgdisplay -v /dev/vg01 | more
        .....
            --- Logical volumes ---
        LV Name     /dev/vg01/lvol_name1
        .....
        LV Name     /dev/vg01/lvol_name2
        .....
        LV Name     /dev/vg01/lvol_name3
        ....
        Record the names of the logical volumes in the group.
# umount  /dev/vg01/lvol_name           | Do this for every logical volume in the group.
# vgchange -a n /dev/vg01
        "Volume group "/dev/vg01" has been successfully changed."
        This de-activates the group & makes it unavailable.
# /etc/vgexport -p -v /dev/vg01
        "Beginning the export process on Volume Group /dev/vg01".
        /dev/dsk/c1d0s2
        /dev/dsk/c2d0s2
       This command uses the  -p (preview)  and  -v (verbose) options.
        It does not actually make any real changes to the system.
# /etc/vgexport  -mSave-LV-Config  /dev/vg01
        This command really exports the volume group.

        The volume group name is removed from the /etc/lvmtab file and the associated device files including the volume group's directory and  group file are removed from the system.
        -mmapfile (called Save-LV-Config in the example above ) names the file  that saves the Logical Volume names and numbers on the disk. If this option is not specified, no Logical Volume names are saved.
        The mapfile can be used as input to the "vgimport" command. If you  don't make the file, or don't use it with vgimport, Logical Volume  names are created on the target system using the default naming
        convention  lvol##  where  ##  is the Logical Volume minor number.
        You need to transfer the map file to the / directory on the new system.
# strings /etc/lvmtab
         Confirm that the group has been removed from the lvmtab file.
# vi /etc/checklist (9.x) or /etc/fstab (10-11)
        Remove any checklist entries that refer the the logical volumes in  the volume group that you exported.
# shutdown  -h  0
        Halt the system before you physically remove the disks from the  original system.
# reboot -r
        Then reboot with an autoboot option.


     IMPORTING A VOLUME GROUP ( AND ITS DISKS ) ONTO A DIFFERENT SYSTEM

# shutdown  -h  0
        Halt the system before you physically attach the disks to the system.
        Check the bus addesses to ensure no conflict, power on the disk(s) and reboot the host system.
# mkdir /dev/vg01
        Create a new directory for the volume group you are importing.
# mknod  /dev/vg01/group  c  64  0x010000
                **                 **
        Make a "group" character device file for the group. The "01" in the  device file corresponds to the "01" in the minor number ie; they  MUST be the same.
# ioscan -kfC disk
        Class  LU  H/W Path Driver            H/W Status S/W Status
        ===========================================================
        disk    1  52.2.0   scsi1.target.disc3  ok(0x0)      ok
        disk    0  52.3.0   scsi1.target.disc3  ok(0x0)      ok
        disk    2  52.5.0   scsi1.target.disc3  ok(0x0)      ok
        disk    3  52.6.0   scsi1.target.disc3  ok(0x202)    ok

        Determine the logical unit numbers for the new disk(s) eg; 2 & 3.
# vgimport -v -mSave-LV-Config  /dev/vg01  /dev/dsk/c2d0s2  /dev/dsk/c3d0s2

        If you made a map file on the old system, you need to transfer it to  the / directory on the new system before you issue this command.
        This adds the volume group and its two disks to the target system.
        The Physical Volumes are scanned to obtain the Volume Group information  and Logical Volume information.
        The volume group name is added to the /etc/lvmtab file and the associated logical volume device files are added to the system.
        The "vgimport" command assumes that the Volume Group information has already been created on the Physical Volumes.
        The mapfile, in this example called Save-LV-Config,  must have been created when the disks were exported from the original system.
        If you don't make the file, or don't use it with vgimport, Logical  Volume names are created on the target system using the default naming  convention  lvol##  where  ##  is the Logical Volume minor number.
# vgchange -a y /dev/vg01           |  Activate the volume group.

# vgdisplay -v /dev/vg01 | more      | Record the names of the logical volumes in the group.

        .....
            --- Logical volumes ---
        LV Name     /dev/vg01/lvol_name1
        .....
        LV Name     /dev/vg01/lvol_name2
        .....
        LV Name     /dev/vg01/lvol_name3
        ....
# mkdir /dir_name1 /dir_name2 /dir_name3
        Make a mount point directory in the root directory for each logical  volume in the newly imported volume group.
# vi /etc/checklist (or /etc/fstab)
        Make entries for all the file systems in the group's logical volumes eg;
         /dev/vg01/lvol_name   /dir_name  hfs  rw  0 3 0  # my new file system
# mount -a                  | Mounts all the file systems
# vgcfgbackup /dev/vg01
        This is essential!  Why not backup the other groups on the system too?   It backs up the lvm configuration of the group in the file system,  which then allows the configuarion to be backed up to tape.
        Do this for the relevent volume group after every configuration change!


To Boot Pseudo-SWAP for decreasing size of Primary SWAP:
 
     $ lvlnboot -v /dev/vg00  
           This will display the current root and swap volumes
Note 1 : lvol2 is the default primary swap.
Note 2 : lvol2 can also be the DUMP area !!!! If this is the case make sure the lvol2 space is at least the same size as your memory size.

     $ lvrmboot -s /dev/vg00               # remove the swap link to the  current primary swap.

     REBOOT the system into lvm maintenance mode:
 
     $ shutdown -r 0                       # reboot
 
     at ISL> boot -lm (;0)/stand/vmunix

     $ lvreduce -L XXX /dev/vg00/lvol2     # XXX is new size of lvol
     $ lvlnboot -s lvol2 /dev/vg00             # recreate a swap link  with the lvol.
     $ lvlnboot -R /dev/vg00                    # to relink everything
     $ shutdown -r 0                                # reboot
 

CHANGE ALTERNATE TO PRIMARY LINK (and vice versa)

# vgdisplay -v /dev/vg07
   --- Physical volumes ---
   PV Name                     /dev/dsk/c2t6d2
   PV Name                     /dev/dsk/c3t6d2  Alternate Link

# vgreduce vg07 /dev/dsk/c2t6d2
Device file path "/dev/dsk/c2t6d2" is an primary link.
Removing primary link and switching to an alternate link.
Volume group "vg07" has been successfully reduced.

# vgdisplay -v /dev/vg07
   --- Physical volumes ---
   PV Name                     /dev/dsk/c3t6d2

# vgextend vg07 /dev/dsk/c2t6d2
Volume group "vg07" has been successfully extended.
# vgdisplay -v /dev/vg07
 
  


CREATE A VOLUME GROUP WITH ALTERNATE LINK
Here are examples - adjust device file names to your configuration !!!

a) FOR A NEW VOLUME GROUP
# vgcreate vg07 /dev/dsk/c2t6d0 /dev/dsk/c3t6d2
Increased the number of physical extents per physical volume to 2102.
Volume group "/dev/vg07" has been successfully created.
Volume Group configuration for /dev/vg07 has been saved in /etc/lvmconf/vg0
                     or
# vgcreate vg07 /dev/dsk/c2t6d2
# vgextend vg07 /dev/dsk/c3t6d2

b) FOR AN EXISTING VOLUME GROUP (WITHOUT ALTERNATE LINK DEFINED)
 Add a PV link to one of the physical volumes in the volume group.
Where /dev/dsk/c0t4d0 and /dev/dsk/c1t4d0 refer to the same physical
volume (referenced via different controllers), and the volume group
already contains /dev/dsk/c0t4d0.  /dev/dsk/c0t4d0 remains the primary
link (in use) and /dev/dsk/c1t4d0 becomes an alternate link.
# vgextend  /dev/vg03 /dev/dsk/c1t4d0  (CAN BE DONE ON LINE !!!)
# vgdisplay  vg03                           | check if it worked !!!!
 --- Physical volumes ---
   PV Name                     /dev/dsk/c0t4d0
   PV Name                     /dev/dsk/c1t4d0  Alternate Link
 


MOVING DATA FROM ONE LVOL TO ANOTHER
Here are the instructions for moving a file system(ie:/usr) from one lvol to another:
Shutdown to single user mode
1.  lvcreate new lvol for /usr   
        IE: lvcreate -L xxx /dev/vgXX         (xxx= size of the log. vol. in Mb)

2.  mkdir /disk

3.  Temporarily mount /disk on new /usr lvol (from step 1).
     mount /dev/vgXX/lvolX /disk

4.  cd /usr  ** This is the source directory.**

5.  find . -print -hidden |cpio -pdumvxl /disk

6.  mv /usr /usr.old

7.  umount /disk 

8.  mkdir /usr

9.  modify /etc/fstab to reflect new dest of /usr lvol   IE: /dev/vgXX/lvolX /usr hfs defaults 0 2

10. mount /usr

11. lvlnboot -R /dev/vg00

You should be able to see and access all files in the newly moved directory.
Try out some applications for verification. Once verified, you can remove the old directory

12.  rm -R /usr.old


STRIPING A LOGIVAL VOLUME REV (10.x/11.x)

***DO NOT USE SAM TO CONFIGURE STRIPPING !!!!

To create a logical volume striped across 3 disks, with a stripe size of 32 Kb, for a total LV size of 24 Mb:
    # lvcreate -i 3 -I 32 -L 24 -n lvape /dev/vg01

The options are:
    -i Number of physical volumes
    -I Size of the stripe in Kb

STRIPING A LOGIVAL VOLUME REV (9.x) + MIRROR/STRIPING
    A logical volume (LV) can be set up to be 'striped' across multiple disks, although the default condition is unstriped.  When you stripe a LV across multiple disks, each stripe can consist of as many or few extents as you wish.  The stripe size you choose will depend on the contents of your LV and how the data is accessed.

When setting up LVM striping you can _not_ use these two shortcuts:

*  Don't use a single "lvcreate" command to create a LV of the desired size, because the LV will be created in a single  large chunk which doesn't span multiple physical volumes unless it  has to.  Instead, use the "lvextend" command repeatedly to create successive extents on different disks.
*  Don't use "sam" to set up your LVs, because "sam" will use a single "lvcreate" command, with the result as above.

Here are samples of the 5 basic steps required to create an LVM striped configuration:

1.  Make the disks into LVM disks with a "pvcreate" command for each one you are planning to use for the striped configuration:
    # pvcreate -f /dev/rdsk/c3d0s2

    This command removes all previous data and configuration details on  the disk.  The '-f' parameter is important when the disk has been  previously used for LVM, because the command will fail if it detects traces of an earlier LVM data.
    Repeat the "pvcreate" command for each disk in your planned configuration.

2. Create the volume group (VG) that will contain the striped disks:
        # mkdir  /dev/vg01
        # ll -d /dev/vg01
        drwxrwxrwx   2 root     sys         1024 May 28 12:45 vg01

    You could use a customised name for the group like '/dev/userdata'  instead of the name '/dev/vg01', but it is recommended that you use the  standard naming convention of vg00, vg01, vg02, and so on.
        # mknod  /dev/vg01/group  c  64 0x010000
        # ll group
        crw-rw-rw-   1 root     sys       64 0x010000 May 28 12:38 group
                                               ^^

    This "mknod" command makes the 'group' file for vg01.  The name 'group'  must be used in this command!  The '01' of the minor number reflects the VG number, which cannot be greater than 9 unless you increase the kernel parameter 'maxvgs'.
        # vgcreate  -s2  /dev/vg01   /dev/dsk/c3d0s2

    The "vgcreate" command assigns the first 'pv-created' disk to the new group.  The '-s' option allows you to specify a non-default extent size;  in this case it is specifying extents of 2Mb.  The default is 4Mb.

    Although the manual page implies that you can specify multiple disks in this command you should only add ONE at a time.  Naming multiple disks can cause corruption of the LVM configuration.  If the group is going to have several disks use "vgextend" to add the others later:
        # vgextend  /dev/vg01  /dev/dsk/c4d0s2
        # vgextend  /dev/vg01  /dev/dsk/c5d0s2

3.  Create the LV using an "lvcreate" command:
        # lvcreate -n logvol1 /dev/vg01

    In this example, '-n logvol1' creates a customised name for the volume.

    If you are planning to mirror the LV you will need to use the '-c' and  '-M' parameters. (Check the "lvcreate" manual page for these options).

    NOTE:  The "lvcreate" command has not specified a size for the volume at  this stage.

4.  For mirroring an LV skip to step 4b, otherwise continue at 4a:

4a. Use a series of "lvextend" commands to enlarge the volume, one stripe at a  time, specifying the disk for each successive stripe:

        # lvextend -l 2  /dev/vg01/logvol1 /dev/dsk/c3d0s2
        # lvextend -l 4  /dev/vg01/logvol1 /dev/dsk/c4d0s2
        # lvextend -l 6  /dev/vg01/logvol1 /dev/dsk/c5d0s2
        # lvextend -l 8  /dev/vg01/logvol1 /dev/dsk/c3d0s2
        # lvextend -l 10 /dev/vg01/logvol1 /dev/dsk/c4d0s2
        # lvextend -l 12 /dev/vg01/logvol1 /dev/dsk/c5d0s2

    These commands spread the LV over three disks.  Specify the increasing  size of the LV with the '-l' parameter in each "lvextend" command.  In  the above example, each command increases the volume by two extents.

    Instead of specifying the number of extents, you can specify the  progressive total size of the LV in megabytes with a '-L' parameter.

4b. Creating a mirrored LVM configuration that includes striping involves  the same preliminary steps as above to set up the disks, volume  group, and LV.

    To create the striped and mirrored LV, you need to create the first  stripe unmirrored:
        # lvextend -l 2 /dev/vg00/logvol1 /dev/dsk/c3d0s2

    Then establish the mirroring, initially onto disk /dev/dsk/c6d0s2:
        # lvextend -m 1 /dev/vg00/logvol1 /dev/dsk/c6d0s2

    The '-m 1' option synchronises the newly created mirror (that is,  copies the data from the primary extents to the mirrored extents).  This  could take some time, depending on the size of the mirrored stripe you just created.

    Then extend the volume, one mirrored stripe at a time:

        # lvextend -l 4  /dev/vg01/logvol1 /dev/dsk/c4d0s2  /dev/dsk/c7d0s2
        # lvextend -l 6  /dev/vg01/logvol1 /dev/dsk/c5d0s2  /dev/dsk/c8d0s2
        # lvextend -l 8  /dev/vg01/logvol1 /dev/dsk/c3d0s2  /dev/dsk/c6d0s2
        # lvextend -l 10 /dev/vg01/logvol1 /dev/dsk/c4d0s2  /dev/dsk/c7d0s2
        # lvextend -l 12 /dev/vg01/logvol1 /dev/dsk/c5d0s2  /dev/dsk/c8d0s2

    These commands spread the LV over three disks, which are mirrored onto a  further three disks.  The '-l' or '-L' size parameter refers to the  unmirrored size of the volume.

5.  When your new configuration is complete, back up the configuration  details with this command:
        # vgcfgbackup  /dev/vg01

    This backs up the configuration changes in the root file system, in
    /etc/lvmconf, which then allows the configuration details to be saved
    using normal backup utilities.

    Do this for the relevant VG after every configuration change!

############################################################################
# EXAMPLE script for performing non-mirrored LVM striping
# NOTE: This script is not support by Hewlett Packard and is representative
#       of how you can automate the striping process.
# AUTHOR: Gavan Turner
############################################################################
# NUM_DISKS=    Number of disks to stripe across
# NEWSIZE=      Counter used in extending the LV by extents
# SIZE=         MB size of LV
# count=        used to index the array of disks we are striping across
# TOTAL=        used to round the LV size to an even number of extents on
#                       each disk
# PESIZE=       Size of a Physical Extent (PE).. 4 MB is the default
# LV=           Name of Logical Volume to create
# VG=           Volume Group LV resides within
# DISK[]=       Array containing block device files for the disks we will
#                       be striping across
############################################################################
typeset -i NUM_DISKS NEWSIZE SIZE count TOTAL PESIZE LVOL VG

DISK[1]=/dev/dsk/c2d0s2
DISK[2]=/dev/dsk/c3d0s2
DISK[3]=/dev/dsk/c4d0s2

LVOL=lvol1
VG=/dev/vg01

# NOTE the SIZE figure should be set to the # of PESIZE MB extents you
# want in the LV, ie the TOTAL size (in MB) divided by PESIZE

SIZE=1500
NUM_DISKS=3
PESIZE=4
NEWSIZE=0
TOTAL='SIZE/NUM_DISKS'
TOTAL='TOTAL*NUM_DISKS'

# Ensure even number of extents on each of the disks
if [ 'TOTAL' -ne 'SIZE' ]
then
        echo "Adjusting SIZE to $TOTAL, from $SIZE"
        SIZE=TOTAL
fi

lvcreate -n $LVOL $VG

while [ NEWSIZE -le SIZE ]
do
        count=1
# Loop to put an extent on each disk
        while [ count -le NUM_DISKS ]
        do
                NEWSIZE=NEWSIZE+1
                lvextend -l $NEWSIZE $VG/$LVOL ${DISK[$count]}
                count=count+1
        done
done


 

Moving 10.10 root disk to a new physical location

Can I move an HP-UX 10.10 root disk from one hardware location to
a new location without having to rebuild the root Volume Group (VG)?

Version - 10.10

Solution

This is not supported by HP; therefore, be aware you do this at your own risk.

Make sure that you have a good backup and recovery system prior to attempting this procedure.

Review the following procedure for moving a SCSI boot disk:

1. Edit the /etc/fstab file and /etc/mnttab file and comment out any lines having anything to do with your root VG.
2. Shutdown and reboot system.
3. Once the system is rebooted you are prompted with the following:
     Autoboot from primary boot path enabled.  To override, press any key within 10 seconds.
4. Press any key to continue with this procedure.
5. From the Main Menu: Enter command or menu > prompt "bo pri".
6. From Interact with Initial Program Load (IPL) (Y or N)?> prompt, select Y.
7. From the ISL prompt do a:
    hpux -lm (;0)/stand/vmunix

   This will boot the system in maintenance mode but won't activate  the root VG, usually vg00.
8. From the # prompt, do a:
    vgexport -p -v -m /rootmapfile

   This will export the VG information and put it in the mapfile.
9. Shutdown the system, power it off, and move the SCSI disk.
10. When the disk is in its new home, reboot the system and press any key to get to the main menu.
11. From the Main Menu: Enter command or menu > prompt
     pa pri
     This changes the primary hardware boot path.
12. From the Main Menu: Enter command or menu > prompt bo pri.
13. From the Interact with IPL (Y or N)?> prompt, select Y.
14. From the ISL prompt, do a:
     hpux -lm (;0)/stand/vmunix
   This will boot the system in maintenance mode, but will not activate  the root VG, vg00 at the new address.
15. insf -e      to create the device files for the new drive locations

      ioscan -fnH     to get new device file names
      mv /etc/lvmtab lvmtab.old
16. To find the new physical volume name, from the # prompt, do a:
     vgimport -v -m /rootmapfile /dev/root_volume  /dev/dsk/C????? ( from ioscan)

 This will import the VG information from the mapfile.
17. Do a:
 
     vgscan         (you might get errors here: disk xxxx is already in lvmtab....ignore it)

18. To recreate /etc/lvmtab, do a:
     lvlnboot -R

19. Then check if the lvlnboot information is pointing to the right  disk with a:
     lvlnboot -v

    It should specify the new physical volume name.
20. You should be able to reboot and boot into multi-user mode.  If  the system doesn't come up, try booting hpux -lm; again and  doing another lvlnboot -R.
 


Find if badblock in bbdir (rev 10)

# echo 2400?20X | adb /dev/dsk/c4t6d0

If there are no entries in the BBDIR this will return:
2400:             44454645        43543031        0               0
                                0               0               0               0
                                0               0               0               0
                                0               0               0               0
                                0               0               0               0

The first two words being the magic label for a BBDIR. If the first two words are 44454645, 43543031 and the rest are NOT zeroes then you have entries in the BBDIR.
  


Check_alternate_link
 
Because PV-links use different physical volume path, LVM driver has to use PVID in physical volume to identify the volumes.

Warning:    Copying  whole data by dd command also copies the PVID to the new physical volume.
This may cause LVM to think a Physical volume is a alternate link, which it is not.
 
There are 4 possible methods for finding the vgid:
Assuming that /dev/dsk/c3t6d0 is the root disk.

    1) using q4:

a. % q4 -F /dev/dsk/c3t6d0 /stand/vmunix
b. q4> load -r struct lv_lvmrec from 0x2000
c. q4> print -tx
      indexof  0
.
.
    vg_id.id1  0x2c80715b
    vg_id.id2  0x3241e1d2

So, the volume group id is: 2c80715b3241e1d2

    2) using dd:

dd if=/dev/rdsk/c3t6d0 of=root.disk bs=8k skip=1 count=1

 # Address 0000010 the first two fields are the root volume group ID
look at the file with: od -Ax -tx root.disk
od -Ax -tx root.disk
0000000         4c564d52        45433031        2c80715b        3241e1cf
0000010         2c80715b        3241e1d2          143213               0
0000020              130             860              86               a
0000030              860             8f8               8             8f0
0000040              988          142000             b60              16
0000050             1000             6b3          142b60              a1
0000060                0              10              80               2
0000070               80              88               6              82
0000080               8a               0               0               0
0000090                0               0               0               0
*
0000400         44454645        43543031               0               0
0000410                0               0               0               0
*
0002000

Note on the 2nd line down the first two fields:

2c80715b3241e1d2

3) using adb:
adb -k /stand/vmunix /dev/mem
volgrp/10x
volgrp:
volgrp:     67      0xD000  6A      0xB000  6D      9000    70      7000
            73      5000
67d000/40x
67D000:     60      0xE840  0       0       0       0       0       1
            87      8400    0       100     67      0xC2E0  90      0xDC00
            0       0xFF    0       2       0       40      2C80    715B
            3241    0xE1D2  0xC     9       0       4       67      0xC240
            6       3160    0       0       67      0xC260  0       0

using the last 2 words on the third line and the first 2 on the 4th line,
we get:
                2c80715B3241e1d2

4) Only on systems with MC/Lockmanager or MC/Serviceguard installed:
vgexport -s -p -v -m map.file /dev/vg00.

 HP Only Info




EXPORT/IMPORT VG's WITH ALTERNATE LINKS (PVLINKS)
Operating System - HP-UX
Version - 10.20
Hardware System - HP 9000

Use the following steps for the move:

1. vgchange -a n /dev/vg01
   Volume group "/dev/vg01" has been successfully changed.
2. vgexport -m /tmp/vg01.map -s /dev/vg01    | -s copies VGID- Needed for PVLINKS !!!
3. cat /tmp/vg01.map
   VGID 77aaa838349558b2   ---> created with -s option !!!!
   1 lvbal

   2 lvol2
If drives are moved to another system: ftp or rcp /tmp/vg01.map to the other system. Then:

4. mkdir /dev/vg01
5. mknod /dev/vg01/group c 64 0x010000
6. vgimport -m /tmp/vg01.map -s /dev/vg01    | must specify -s option !!!!!
7. vgchange -a y /dev/vg01
   Activated volume group

Yes, the procedure will import all the pvlinks. Be aware of the following issues:

- Use the -s option for both vgexport and vgexport !!!!
- vg with > 255 pv causes core dump.
- The vgimport sets path A as the primary path for all LUNs. Fix with a vgreduce and vgextend on the primary link for each LUN for which you want to change the primary.
- maxfiles must be more than double the number of disks free.



MIRROR ROOT

     Version -10.x/9.x

 

To mirror the root file system, you must first add a bootable LVM disk. Follow these steps to do this:
Note: Substitute the proper device file !!
1. lvlnboot -v
Boot Definitions for Volume Group /dev/vg00:
Physical Volumes belonging in Root Volume Group:
        /dev/dsk/c0t5d0 (4.5.0) -- Boot Disk
        /dev/dsk/c0t8d0 (4.8.0) -- Boot Disk
Boot: lvol1     on:     /dev/dsk/c0t5d0
Root: lvol3     on:     /dev/dsk/c0t5d0
Swap: lvol2     on:     /dev/dsk/c0t5d0
Dump: lvol2     on:     /dev/dsk/c0t5d0, 0
2. Create a physical volume using pvcreate with the -B option:
        pvcreate -B /dev/rdsk/c0t3d0
or    pvcreate -B -f /dev/rdsk/cxtydz
Note 1: (use -f if drive was used on a previous vg - getting error : physical volume already belongs to volume group)
Note 2:  the -B option creates a region for a LIF volume and boot   utilities, and creates a BDRA (Boot data Reserved Area) on this  disk.

3. Add the physical volume to your existing root volume group with vgextend:
        vgextend /dev/vg00 /dev/dsk/c0t3d0
Volume group "/dev/vg00" has been successfully extended.
Volume Group configuration for /dev/vg00 has been saved in /etc/lvmconf/vg00.conf (this line only at rev 10/11)

4. Use mkboot(1M) to place boot utilities in the boot area:
        mkboot /dev/rdsk/c0t3d0

5. Use mkboot -a to add an AUTO file in boot LIF area:
        mkboot -a "hpux (52.3.0;0)/stand/vmunix" /dev/rdsk/c0t3d0    (10.x)
        mkboot -a "hpux (52.3.0;2)/hp-ux" /dev/rdsk/c3d0s2                (9.x)

6. lvextend -m 1 /dev/vg00/lvol1 /dev/dsk/c0t3d0
7. lvextend -m 1 /dev/vg00/lvol2 /dev/dsk/c0t3d0
The newly allocated mirrors are now being synchronized. This operation will take some time. Please wait ....
Logical volume "/dev/vg00/lvol3" has been successfully extended.
Volume Group configuration for /dev/vg00 has been saved in /etc/lvmconf/vg00.conf (this line only at rev 10/11)

        NOTE: The lvextend command has to be done on all logical volumes on the primary disk. This means that lvextend has to be done on lvol1 -> lvolX. This also  includes /dev/vg00/lvol2, which by default is primary swap)

8. lvlnboot -R
9. lvlnboot -v                | make sure all volumes are mirrored in BDRA
Boot Definitions for Volume Group /dev/vg00:
Physical Volumes belonging in Root Volume Group:
        /dev/dsk/c0t5d0 (4.5.0) -- Boot Disk
        /dev/dsk/c0t8d0 (4.8.0) -- Boot Disk
Boot: lvol1     on:     /dev/dsk/c0t5d0
                        /dev/dsk/c0t3d0
Root: lvol3     on:     /dev/dsk/c0t5d0
                        /dev/dsk/c0t3d0
Swap: lvol2     on:     /dev/dsk/c0t5d0
                        /dev/dsk/c0t3d0
Dump: lvol2     on:     /dev/dsk/c0t5d0, 0

For more information, refer to your System Administration Tasks manual,
HP Part No. B2355-90079.



Move the boot disk to a new disk using pvmove
 
Version -10.01
 
The following summarizes the procedure to put a new boot disk in place:

1. pvcreate -B .
2. mkboot -l .
3. mkboot -a .
4. vgextend /dev/vg00 /dev/dsk/.
5. pvmove /dev/vg00/root-lvol /dev/dsk/ /dev/dsk/.
6. pvmove /dev/vg00/swap-lvol /dev/dsk/ /dev/dsk/.
7. pvdisplay -v /dev/dsk/ # make sure the root/lvol resides on the first PEs on the disk.
8. lvlnboot -R /dev/vg00.
9. lvlnboot -v /dev/vg00 #check the lvlnboot-entries.
10. pvmove /dev/vg00/lvolX /dev/dsk/ /dev/dsk/   for all other logical volumes.
11. pvdisplay -v /dev/dsk/ #make sure old_disk is empty.
12. vgreduce /dev/vg00 /dev/dsk/



How to boot from a split mirror

Operating System - HP-UX
Version -10. xx
Hardware System - HP 9000

It is possible to boot successfully from a split mirrored drive. However, to protect yourself in the event an install or patch installation goes bad is to use copyutil or to create an alternate boot disk.

Neither the split logical volume or the primary logical volume can be increased or decreased in size while they are split. Any changes in the sizes of the lvol will result in the inability to merge and resynchronize.

Particular attention must be paid to the order in which the logical volumes are split.  It is critical that the last logical volume to be split is the root logical volume.  In default, this would mean that a system running HP-UX 10.10 or older would use lvol1 to /.  In an upgraded 10.20 system, where /stand
is not it's own logical volume this would also apply.  In the situation where 10.20 has been cold installed, lvol1 contains /stand, and lvol3 contains the rest of the root file system mounted to /.

This can be verified with the lvlnboot -v command and bdf.

In order to successfully boot from a mirror:
Prior to splitting the logical volumes:

1.   Make 2 copies of the fstab file:
       cp /etc/fstab /etc/fstab.b4split
       cp /etc/fstab /etc/fstab.aftersplit

2.   Modify the fstab.aftersplit file to reflect the split logical volumes:
       vi /etc/fstab.aftersplit
          /dev/vg00/lvol1b / hfs defaults 0 1
          /dev/vg00/lvol3b /home vxfs delaylog 0 2
          /dev/vg00/lvol4b /opt vxfs delaylog 0 2
          ...
          /dev/vg00/lvol7b /var vxfs delaylog 0 2

3.   Split the logical volumes in DESCENDING order:

      lvsplit /dev/vg00/lvol7
      lvsplit /dev/vg00/lvol6
      lvsplit /dev/vg00/lvol5
      lvsplit /dev/vg00/lvol4
      lvsplit /dev/vg00/lvol3
      lvsplit /dev/vg00/lvol2
      lvsplit /dev/vg00/lvol1

After splitting all the logical volumes, make sure you have all device files for your lvols in the /dev/vg00 directory.  For example, for lvol1 you should have:

     lvol1
     rlvol1
     lvol1b
     rlvol1b

4. Run fsck on each lvolb to ensure there has not been any corruption.
      fsck /dev/vg00/lvol1b
      fsck -F vxfs -o full,nolog /dev/vg00/lvol3b
      fsck -F vxfs -o full,nolog /dev/vg00/lvol4b
      fsck -F vxfs -o full,nolog /dev/vg00/lvol5b
      fsck -F vxfs -o full,nolog /dev/vg00/lvol6b
      fsck -F vxfs -o full,nolog /dev/vg00/lvol7b

5. Perform whatever tasks you need to do to the primary logical volumes such as adding patches, upgrading the operating system.

6.   In the event of a problem, perform the following steps to boot from the mirror drive:

7.   Reboot the system and come back up in LVM maintenance mode:
      shutdown -r 0

When the message is displayed telling you to press Esc (or any key) within 10 seconds to stop the selection process, do so.  Select s from the menu, or type search to identify bootable devices.
When it finds the mirror disk, enter the appropriate command to boot from the mirror drive:
        b Px ipl (where x = mirror disk)
        Interact with ISL? y
        At the ISL> prompt, enter:

        hpux -lm boot

8. Once the system is booted to LVM maintenance mode, activate vg00.

        vgchange -a y /dev/vg00

9. Mount the split logical volume for usr to /usr.  This will give access to the cp command.

        mount /dev/vg00/lvol4b /usr

10. Copy /etc/fstab.aftersplit to /etc/fstab
        cp /etc/fstab.aftersplit /etc/fstab

11. Modify lvlnboot to reflect the split logical volumes:
If this is a pre 10.20 OS or an upgraded 10.20, then use:

        lvrmboot -r /dev/vg00

        lvlnboot -r /dev/vg00/lvol1b
        lvlnboot -s /dev/vg00/lvol2b
        lvlnboot -d /dev/vg00/lvol2b

If this is a cold installed 10.20 or newer with /stand in lvol1 use:

        lvrmboot -r /dev/vg00

        lvlnboot -b /dev/vg00/lvol1b
        lvlnboot -r /dev/vg00/lvol3b
        lvlnboot -s /dev/vg00/lvol2b
        lvlnboot -d /dev/vg00/lvol2b

12. Reboot the system, and come up in single user mode on the mirror drive:

        reboot -q

Interrupt the boot sequence and do a search, select the mirror drive:

        b Px ipl (where x = mirror drive)

At the ISL> prompt enter hpux -is boot

13. Mount all logical volumes:
        mount -a

14. Ensure all lvols mounted properly.

        bdf
        The output should display the "b" versions of each lvol
        being mounted to the mount points.

15. If / is mounted to /dev/root, remove /etc/mnttab, and execute the mountall command to recreate /etc/mnttab.

       rm /etc/mnttab
       mountall

16. Run bdf again.  Everything should look correct now, with lvol1b mounted to /.

17. If desired, move to multi-user mode.

     init 4

System should behave normally now, but be booted from the split mirrordisk.

If the modifications were successful, and you now want to merge yourmirrors with both sides reflecting the changes you made:

1.   Reboot the system:

       shutdown -r 0

2.   Interrupt the boot sequence and boot to lvm maintenance mode on the primary drive.  Refer to step 7, and select the primary drive.

3. After the system has successfully booted, modify the lvm structure as follows:

        For upgraded 10.20, or all previous versions:

        lvrmboot -r /dev/vg00

        lvlnboot -r /dev/vg00/lvol1
        lvlnboot -s /dev/vg00/lvol2
        lvlnboot -d /dev/vg00/lvol2
        lvlnboot -R

        For cold installed 10.20 or newer with /stand on lvol1:

        lvrmboot -r /dev/vg00

        lvlnboot -b /dev/vg00/lvol1
        lvlnboot -r /dev/vg00/lvol3
        lvlnboot -s /dev/vg00/lvol2
        lvlnboot -d /dev/vg00/lvol2

4. Mount the appropriate lvol to /usr

        mount /dev/vg00/lvol6 /usr

5. Copy /etc/fstab.b4split to /etc/fstab

        cp /etc/fstab.b4split /etc/fstab

Verify it is correct with more /etc/fstab.

6. Reboot the system and allow it to come back up by itself.

7. Merge the mirrors back together.  Be careful to merge them the right way.

     lvmerge /dev/vg00/lvol8b /dev/vg00/lvol8
     lvmerge /dev/vg00/lvol7b /dev/vg00/lvol7
     ...
     lvmerge /dev/vg00/lvol1b /dev/vg00/vlol1

If the changes you made to the primary side were unsuccessful, you can remerge your mirrors from your current configuration.

CAUTION: Review the man page on lvmerge before performing this step.  It should go as follows:

     lvmerge /dev/vg00/lvol7 /dev/vg00/lvol7b
     lvmerge /dev/vg00/lvol6 /dev/vg00/lvol6b
     ...
     lvmerge /dev/vg00/lvol1 /dev/vg00/lvol1b

After the resync has completed, you will have lvolb device files left in /dev/vg00.  These can be renamed using the mv command.

     mv /dev/vg00/lvol1b /dev/vg00/lvol1
     mv /dev/vg00/rlvol1b /dev/vg00/rlvol1

You will end up with new minor numbers, but that should not be a problem.
 
 


 
 
 

HOW TO FIND WHICH DRIVES BELONG TO WHICH VOLUME GROUP

# echo 0x2008?4D|adb /dev/dsk/c0t0d4
2008:           418374281       915654113       418374281      909512229

above is the command he can use to try and find which disks belong to the same vg. The vg name is not important at this point, but finding the disks that belong to the same vg is..

Notice the first field to the left: "2008" this represents the address on the disk for the lvm data. It will always be the same.

next field: "418374281" this is the system or cpu id. You should see the same number if a uname -i was done.

next field: "915654113" is the pvid, not important at this time.

next field: "418374281" is the cpu id again

Now the last field is the one we want to pay attention to: "909512229" this is the vgid field and represents the volume group.

If the ce runs this command on his device files for all his disks he can then match up the vgid's. He can then import the volume groups.


 

How to check whether an EMC Symmetrix LUN has the BCV attribute

BCV = Business  Continuity Volume (split mirror on the fly)

You can check whether an EMC Symmetrix LUN has the BCV attribute by examining the output from a diskinfo -v.  Bit 3 (bit 0 is LSB) in byte 103 is the BCV flag.  If 1, then the disc is a BCV.

e.g. c1t2d0 is not a BCV whilst c0t0d2 is.

# diskinfo -v  /dev/rdsk/c1t2d0 | tr ' ' '\012' | grep 103
(103)4
# diskinfo -v /dev/rdsk/c0t0d2 | tr ' ' '\012' | grep 103
(103)c     -->=BCV
 

阅读(7788) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~