AIX

 View Only
Expand all | Collapse all

AIX 7.2 commands to mount filesystem in order to write script

  • 1.  AIX 7.2 commands to mount filesystem in order to write script

    Posted Wed February 23, 2022 04:44 PM

    Hi, I am an AIX newbie trying to write a script to automate the process of cloning and refreshing volume groups on AIX 7.2.0.0.  The source data is on Dell PowerStore storage.

    In order to write the script I am trying to determine the commands needed to get the filesystems mounted in AIX.  What I have so far is:

    1. Use PowerStore GUI to create thin clone CL_clonedata and map to host
    2. Run cfgmgr and physical disks appear in lspv list with no PVID or VG
    3. Run chdev to add PVIDs to physical disks
    4. Run mkvg to create volume group: mkvg -y CL_clonedata_vg hdiskpower0 hdiskpower1
    5. Run mklv to create logical volume: mklv -c 1 -t jfs2 CL_clonedata_vg 1
    6. This creates a logical volume with the following properties, I don't know if these are correct:

    lslv -L fslv00

    LOGICAL VOLUME:     fslv00                 VOLUME GROUP:   CL_clonedata_vg

    LV IDENTIFIER:      00fb3c9900004c000000017f22b7149d.1 PERMISSION:     read/write

    VG STATE:           active/complete        LV STATE:       closed/syncd

    TYPE:               jfs2                   WRITE VERIFY:   off

    MAX LPs:            512                    PP SIZE:        4 megabyte(s)

    COPIES:             1                      SCHED POLICY:   parallel

    LPs:                1                      PPs:            1

    STALE PPs:          0                      BB POLICY:      relocatable

    INTER-POLICY:       minimum                RELOCATABLE:    yes

    INTRA-POLICY:       middle                 UPPER BOUND:    32

    MOUNT POINT:        N/A                    LABEL:          None

    MIRROR WRITE CONSISTENCY: on/ACTIVE

    EACH LP COPY ON A SEPARATE PV ?: yes

    Serialize IO ?:     NO

    INFINITE RETRY:     no                     PREFERRED READ: 0

    ENCRYPTION:         no

     

    The next step seems to be to use 'crfs' to create the filesystem, running the command below gives me an error, but I'm not sure what the options should be or if the logical volume has the correct properties.

     

    # /usr/sbin/crfs -v jfs2 -g CL_clonedata_vg -a size=200M -m /usr/dell/CL_clonedata  -A yes  -p rw -a agblksize=4096 -a logsize=100M

    crfs: 0506-963 Invalid attribute value: 100M

    Usage: crfs -v Vfs {-g Volumegroup | -d Device} -m Mountpoint

            [-u Mountgroup] [-A {yes|no}] [-t {yes|no}] [-p {ro|rw}]

            [-l Logpartitions] [-n nodename] [-a Attribute=Value]

     

    Hoping someone in this group can point me in the right direction! 
    Thanks
    Geoff

     



    ------------------------------
    Geoff Bradford
    ------------------------------


  • 2.  RE: AIX 7.2 commands to mount filesystem in order to write script

    IBM Champion
    Posted Thu February 24, 2022 02:26 AM
    Hi Geoff,

    Here's example of commands I use for creating for example all my Oracle vg's / lv's / fs's :

    #volumegroup
    /usr/sbin/mkvg -S -y oraadmvg -f -V 51 -s 32 hdisk2

    #LV
    /usr/sbin/mklv -c 1 -t jfs2 -y lvoradmin -e x -a im -T O -x 8192 oraadmvg 1

    #FS
    crfs -v jfs2 -d lvoradmin -m /oradmin -A yes -p rw -a options=rw,noatime -a logname=INLINE
    mount /oradmin
    chfs -a size=10G /oradmin

    ​​​Of course there are many ways how to do these, but I have found those to be working well, and are easy to be used in scripting too:

    Explanation for all attributes used can be found from IBM command documentation;

    #mklv
    mklv Command

    #crfs
    https://www.ibm.com/docs/en/aix/7.2?topic=c-crfs-command​​

    #mkvg
    https://www.ibm.com/docs/en/aix/7.2?topic=m-mkvg-command​​

    ------------------------------
    Tommi Sihvo, Lead Service Architect
    TietoEVRY, Compute Services
    email tommi.sihvo@tietoevry.com mobile +358 (0)40 5180 Finland
    ------------------------------



  • 3.  RE: AIX 7.2 commands to mount filesystem in order to write script

    Posted Thu February 24, 2022 03:15 AM

    As I understand, you want to create a logical volume and in that lv a filesystem.
    So you can't specify a size for the filesystem as it's determined by the lv.

    My advise: add the filesystem by "smitty jfs2" ("Add an Enhanced Journaled File System on a Previously Defined Logical Volume").

    But don't press Enter to add it, instead press F6 ("F6=command") - smitty shows you a popup with the commands it would do it.



    ------------------------------
    Achim Haag
    ------------------------------



  • 4.  RE: AIX 7.2 commands to mount filesystem in order to write script

    Posted Thu February 24, 2022 05:33 AM

    Hi Geoff,

    So you're making a clone of a LUN and mapping it to an AIX server/LPAR?

    Does the source LUN already contain a VG?

    If it does then you should not need to create VG, LVs and file systems. After cfgmgr in step 2, the new disk should have a PVIDs and step 3 would be importvg -y <VGname> hdiskXXX



    ------------------------------
    Zaki Jääskeläinen
    ------------------------------



  • 5.  RE: AIX 7.2 commands to mount filesystem in order to write script

    Posted Thu February 24, 2022 07:32 AM

    Geoff,

    These are two working commands create LV and FS (jfs2).

    INLINE log size is automatically created proportionally to the size of file system.

    Even after wards , when you increase the size of file system, it will show that INLINE log has been increased to "xxxxx"

     

      /root# mklv -t jfs2 -y lv-qarsreports -e x datavg 75G

     

    /root# crfs -v jfs2 -d lv-qarsreports -Ay -prw -m /xtord/.p_qarsreports -a log=INLINE

    File system created successfully.

    78333404 kilobytes total disk space.

    New File System size is 157286400

     

    Thanks,

    Afzal Muhammad

     

    IBM Certified AIX System Administrator AIX 6.1

    IBM Certfired AIX System Administrator AIX 4.3

    IBM Certified WebSphere 6.0 Adminstrator

    Red Had Linux 7 Certified  System Administrator (RHCSA)

    Global pSeries platform services – AIX

    Ford Motor Company,  Dearborn Michigan

    United States of America

    Tel: Cell 1-704-492-0586

    Email: mafzal10@ford.com

     






  • 6.  RE: AIX 7.2 commands to mount filesystem in order to write script

    Posted Thu February 24, 2022 07:35 AM

    Geoff,

    These are two working commands create LV and FS (jfs2).

    INLINE log size is automatically created proportionally to the size of file system.

    Even after wards , when you increase the size of file system, it will show that INLINE log has been increased to "xxxxx"

     

      /root# mklv -t jfs2 -y lv-qarsreports -e x datavg 75G

     

    /root# crfs -v jfs2 -d lv-qarsreports -Ay -prw -m /xtord/.p_qarsreports -a log=INLINE

    File system created successfully.

    78333404 kilobytes total disk space.

    New File System size is 157286400

     

     

    Thanks,

    Afzal Muhammad

     

    IBM Certified AIX System Administrator AIX 6.1

    IBM Certfired AIX System Administrator AIX 4.3

    IBM Certified WebSphere 6.0 Adminstrator

    Red Had Linux 7 Certified  System Administrator (RHCSA)

    Global pSeries platform services – AIX

    Ford Motor Company,  Dearborn Michigan

    United States of America

    Tel: Cell 1-704-492-0586

    Email: mafzal10@ford.com

     






  • 7.  RE: AIX 7.2 commands to mount filesystem in order to write script

    Posted Thu February 24, 2022 09:44 AM
    Geoff, I think you're working too hard.  A lot of the parameters that you're providing have lovely defaults.  Of course, if you truly need to specify them, then specify them.  But if you're lazy like me, here's what you do.

    mklv -t jfs2 -y sas sas01vg 100G

    You need to specify

    -t jfs2 so that the logical volume is marked for JFS2.
    -y <LVname>...well you don't actually have to, but otherwise you end up with fs00lv and like that.  That's confusing and could lead you to issue a command against the wrong logical volume.  So if I'm creating a filesystem called "/sas", then I use "-y sas".  There are some limits as to length and content of the LV name.

    crfs -v jfs2 -m /sas -d sas -A yes

    Here you specify

    -v jfs2 so that AIX builds a JFS2 filesystem.  If I had written the code, it would have figured this out from the LV type (which does, IIRC, *have* to be "jfs2").
    -m <mountpoint>
    -d <LVname>
    -A yes to automount at boot.  I consistently forget this.

    mount /sas

    I consistently forget this too.  After it's mounted, remember to chmod and chown as appropriate.

    I hope that helps.  

    And welcome to AIX!  It's a great OS.



    ------------------------------
    Anker Lerret
    Blue Cross Blue Shield of Massachusetts
    ------------------------------



  • 8.  RE: AIX 7.2 commands to mount filesystem in order to write script

    Posted Thu February 24, 2022 03:35 PM

    Thanks for all the responses, I am replying to Anker's as it seems to map most closely to my issue. When I look at my VG I see it has PPs=192M which must have come from PowerStore, where I created 2x 100M volumes for testing

     

     

     # lsvg -l CL_clonedata_vg

    CL_clonedata_vg:

    LV NAME             TYPE       LPs     PPs     PVs  LV STATE      MOUNT POINT

    root@s20da01:/ # lsvg -L CL_clonedata_vg

    VOLUME GROUP:       CL_clonedata_vg          VG IDENTIFIER:  00fb3c9900004c000000017f22b7149d

    VG STATE:           active                   PP SIZE:        4 megabyte(s)

    VG PERMISSION:      read/write               TOTAL PPs:      48 (192 megabytes)

    MAX LVs:            256                      FREE PPs:       48 (192 megabytes)

    LVs:                0                        USED PPs:       0 (0 megabytes)

    OPEN LVs:           0                        QUORUM:         2 (Enabled)

    TOTAL PVs:          2                        VG DESCRIPTORS: 3

    STALE PVs:          0                        STALE PPs:      0

    ACTIVE PVs:         2                        AUTO ON:        yes

    MAX PPs per VG:     32512

    MAX PPs per PV:     1016                     MAX PVs:        32

    LTG size (Dynamic): 1024 kilobyte(s)         AUTO SYNC:      no

    HOT SPARE:          no                       BB POLICY:      relocatable

    PV RESTRICTION:     none                     INFINITE RETRY: no

    DISK BLOCK SIZE:    512                      CRITICAL VG:    no

    FS SYNC OPTION:     no                       CRITICAL PVs:   no

    ENCRYPTION:         no

     

    So I successfully created the LV as follows:

    mklv -t jfs2 -y CL_clonedata CL_clonedata_vg 192M

    CL_clonedata

     

    However the crfs command fails:

    crfs -v jfs2 -m /usr/dell/CL_clonedata -d CL_clonedata -A yes

    0516-404 allocp: This system cannot fulfill the allocation request.

            There are not enough free partitions or not enough physical volumes

            to keep strictness and satisfy allocation requests.  The command

            should be retried with different allocation characteristics.

    0516-822 mklv: Unable to create logical volume.

    crfs: 0506-973 Cannot create logical volume for log device.

     

    It looks like this error is related to the log device.  This is a mystery to me but I guess that the log device should also be on the SAN?  It looks like the usual SAN setup (Oracle SAP) is one data vg and 2 log vgs.

     

    In /etc/filesystems it looks like these are related, as in the following entry:

     

    /usr/sap:

            dev             = /dev/usrsaplv

            vfs             = jfs2

            log             = /dev/loglv01

     

    I saw a couple of responses suggesting that I create these in smitty and then look at the command line to see what the commands are.  I tried that already, I guess I could try again, though I failed to get it to work before and the command was a ksh script so I had to try to figure out how the variables were being substituted to create the final command.  I'm writing my script in Python.

     

    Thanks

    Geoff



    ------------------------------
    Geoff Bradford
    ------------------------------



  • 9.  RE: AIX 7.2 commands to mount filesystem in order to write script

    Posted Fri February 25, 2022 10:16 AM
    I don't have a definite answer, Geoff.  But I'm wondering if 192M is just too little space to create a JFS2 filesystem.  Back in the day, filesystems were megabytes in size, but it's been a long time since I've seen a filesystem smaller than a few gigabytes.  Can you try making it a few gigabytes, just to see if that's the issue?

    ------------------------------
    Anker Lerret
    Blue Cross Blue Shield of Massachusetts
    ------------------------------



  • 10.  RE: AIX 7.2 commands to mount filesystem in order to write script

    IBM Champion
    Posted Fri February 25, 2022 10:28 AM

    It seems like you don't have enough space. 

     

    FREE PPs:       48 (192 megabytes)

     

    You are creating the fs as 192M.  That doesn't leave any space to create the log device.  That's what the error is saying.

     

    crfs: 0506-973 Cannot create logical volume for log device.

    Try adding another volume to the VG or create a smaller fs.

     

    Norman Owens

    2021 IBM Champions, 2021 Red Hat Accelerators

    Sr. AIX Administrator / Infrastructure Architect – Global IS
    Mohawk Industries

    1155 Roberts Boulevard, Ste. 200, Kennesaw, GA 30144
    Phone: 678.355.5853 | Internal: 55853 | Office Main Line: 770.792.6300 | Fax: 678.355.5810
    Email:  norman_owens@mohawkind.com

    CertPowerSystems_color

    mohawk

     

     

     

     






  • 11.  RE: AIX 7.2 commands to mount filesystem in order to write script

    Posted Thu February 24, 2022 10:03 AM
    On Wed, Feb 23, 2022 at 09:44:27PM +0000, Geoff Bradford via IBM Community wrote:
    > Hi, I am an AIX newbie trying to write a script to automate the
    > process of cloning and refreshing volume groups on AIX 7.2.0.0. The
    > source data is on Dell PowerStore storage.

    By cloning VGs, I assume you mean you want to duplicate the disk
    layout and not that you want to mount a SAN clone of your disks.

    If you want to duplicate a VG layout, perhaps consider using savevg
    and restvg. This is common for DR and recovery.

    'mkvgdata -X VG' will save information about the volume group to
    /tmp/vgdata.

    You can then recreate the VG, including all filesystems, names, mount
    points, and parameters on a new disk using:

    restvg -r -d /tmp/vgdata/VG/VG.data hdiskNEW

    That VG cannot already exist on the system. This could be a simpler
    avenue for recreating the same VG on multiple systems.

    Every system I setup I add a cron job to do this to help optimize DR restores.

    5 0 * * * lsvg -o | xargs -n1 mkvgdata -X ; tar -cf /home/vgdata.tar /tmp/vgdata

    This saves the VG layout for every open VG to /tmp/vgdata, and then
    tars that directory to /home. The tar step is *critical* because
    mksysbs silently omit /tmp/vgdata. The goal here is to rapidly
    recreate the VG for DR and system recovery, and so if the mksysb is
    missing these files we're back to making them by hand. The tarball in
    /home would be captured by a mksysb, assuming you have /home.

    References:

    https://www.ibm.com/docs/en/aix/7.1?topic=m-mkvgdata-command

    https://www.ibm.com/docs/en/aix/7.2?topic=r-restvg-command#restvg__row-d3e147292

    https://techchannel.com/SMB/09/2020/mkvgdata-restvg-to-solve-issues

    ------------------------------------------------------------------
    Russell Adams Russell.Adams@AdamsSystems.nl
    Principal Consultant Adams Systems Consultancy
    http://adamssystems.nl/




  • 12.  RE: AIX 7.2 commands to mount filesystem in order to write script

    IBM Champion
    Posted Thu February 24, 2022 10:05 AM
    Hi Geoff,

    The error is saying "invalid attribute value: 100M".  The problem is that you need to drop the M.  Just put logsize=100.
    A couple tips for you: 
    1. Check the man(manual pages for details on the command).    ie:  man crfs
    2. You can go into smitty (smitty fs) and enter the values and do   ESC 6  to see the command for scripting purposes.

    Hope this helps.  AIX is a great OS.  Have fun.

    ------------------------------
    Norman Owens
    Open Systems Architect
    Mohawk Industries
    ------------------------------



  • 13.  RE: AIX 7.2 commands to mount filesystem in order to write script

    Posted Mon February 28, 2022 10:31 AM
    Geoff,

    This is due to the fact when you create a file system you also need a log device. We have 2 options for that:

        INLINE
        External

    External log require a separate LV. INLINE logs are contained within the file system itself. Unless you explicitly state you want an INLINE log when you create the file system, we will attempt to use external logs. The correct way to avoid this is by using '-a log=INLINE' in your crfs command:
    crfs -v jfs2 -/dev/xxxxx -m /Mount -A yes -a log=INLINE

    INLINE must be entered as all UPPERCASE. Otherwise it will fail.
    And since you are trying to model another file system, you can see what kind of log is used by looking at the mount output:

    $ mount
    node mounted mounted over vfs date options
    -------- --------------- --------------- ------ ------------ ---------------
    /dev/hd4 / jfs2 Mar 22 18:20 rw,log=/dev/hd8
    /dev/hd2 /usr jfs2 Mar 22 18:20 rw,log=/dev/hd8

    Please note the 'log=.....' stanza in the output. If the file system is using INLINE logs, it will say so here.
    PLEASE do not change anything in the native rootvg as far as the file system logs. You will break things.
    Once the file system is created with INLINE or external logs, there is no way to change it. You have to back/delete/recreate/restore the files to the file system. 

    For a variety of reasons, I prefer to create all non-rootvg file systems as INLINE.

    ------------------------------
    Grover Davidson
    ------------------------------



  • 14.  RE: AIX 7.2 commands to mount filesystem in order to write script

    Posted Mon February 28, 2022 11:00 AM
    Grover, would you mind saying more about why you prefer INLINE logs for non-rootvg filesystems?  Years ago I researched this, but I've forgotten my conclusions.  I've gotten lazy and I accept the default.

    ------------------------------
    Anker Lerret
    Blue Cross Blue Shield of Massachusetts
    ------------------------------



  • 15.  RE: AIX 7.2 commands to mount filesystem in order to write script

    Posted Tue March 01, 2022 01:36 PM
    Hi, I was able to get my logical volume mounted via smitty.  

    Dell Support found this blog post which seems to describe exactly what I am trying to do: Storage Meat: How to Mount Cloned Volume Groups in AIX [storagemeat.blogspot.com]

    It's from 2011 but I will try to go through this.
    Thanks
    Geoff

    ------------------------------
    Geoff Bradford
    ------------------------------



  • 16.  RE: AIX 7.2 commands to mount filesystem in order to write script

    Posted Wed March 02, 2022 09:07 AM
    Running recreatevg is necessary if VG/PV IDs are already know by local system as used by another VG/PV.
    If you are trying to access a clone of a VG that is not known to the local system, importvg will do the job.
    If you are trying to access a clone of a VG that is known to the local system, you have to use recreatevg to fix the "duplicates in LVM" problem.

    ------------------------------
    Lech Szychowski
    ------------------------------



  • 17.  RE: AIX 7.2 commands to mount filesystem in order to write script

    Posted Mon February 28, 2022 11:38 AM
    Anker,

    You asked:
    Grover, would you mind saying more about why you prefer INLINE logs for non-rootvg filesystems? Years ago I researched this, but I've forgotten my conclusions. I've gotten lazy and I accept the default.

    INLINE and external logs give the same performance without special log placement. The external logs can be explicitly placed on super high speed storage. We cannot do with with INLINE logs.

    INLINE logs means that you will have 1 less LV for file system in the volume group to manage. If you mirror a file system with INLINE logs, you do not need to perform another step to mirror the file system log. Just one less thing to miss by mistake.

    And for performance reasons, but file systems you always have their own logs. 2 busy file systems can see performance issues when sharing file system logs. Shared logs can only happen with external logs. It cannot happen with INLINE logs.

    ------------------------------
    Grover Davidson
    ------------------------------