You are on page 1of 5

IBM AIX - Commands (Contd) - LVM - Disks &

Filesystems
IBM AIX - Commands (contd)
IBM AIX Operating System - Some useful Commands gathered from IBM and
other websites!!!

LVM - Disks & Filesystems


List all PVs in a system (along) with VG membership

lspv

List all LVs on PV hdisk6

lspv -l hdisk6

List all imported VGs

lsvg

List all VGs that are imported and on-line

lsvg -o

›››   The difference between lsvg and lsvg -o are the imported VGs that are offline.


List all LVs on VG vg01

lsvg -l vg01

List all PVs in VG vg02

lsvg -p vg02

List filesystems in a fstab-like format

lsfs

Get extended info about the /home filesystem

lsfs -q /home

Create the datavg VG on hdisk1 with 64 MB PPs

mkvg -y datavg -s 64 hdisk1

Create a 1 Gig LV on (previous) datavg

mklv -t jfs2 -y datalv datavg 16

Create a log device on datavg VG using 1 PP


mklv -t jfs2log -y datalog1 datavg 1

Format the log device created in previous example

logform /dev/datalog1

Place a filesystem on the previously created datalv

crfs -v jfs2 -d datalv -m /data01 -A y

›››   A jfs2 log must exist in this VG and be logform(ed). (This was done in the
previous steps.) -m specifies the mount point for the fs, and -A y is a option to
automatically mount (with mount -a).
Create a scalable VG called vg01 with two disks

mkvg -S -y vg01 hdisk1 hdisk2


Create a FS using the VG as a parameter

crfs -v jfs2 -g simplevg -m /data04 -A y -a size=100M

›››   The VG name here is "simplevg". A default LV naming convention of fslvXX will


be used. The LV, and in this case log-LV, will be automatically created.
Take the datavg VG offline

varyoffvg datavg
Vary-on the datavg VG

varyonvg datavg

›››   By default the import operation will vary-on the VG. An explicit vary-on will
be required for concurrent volume groups that can be imported onto two (or more)
systems at once, but only varied-on on one system at a time.
Remove the datavg VG from the system

exportvg datavg
Import the VG on hdisk5 as datavg

importvg -y datavg hdisk5

›››   The VG in this example spans multiple disks, but it is only necessary to specify
a single member disk to the command. The LVM system will locate the other
member disks from the metadata provided on the single disk provided.
Import a VG on a disk by PVID as datavg

importvg -y datavg 00cc34b205d347fc


Grow the /var filesystem by 1 Gig

chfs -a size=+1G /var

›››   In each of the chfs grow filesystem examples, AIX will automatically grow the
underlying LV to the appropriate size.
Grow the /var filesystem to 1 Gig

chfs -a size=1G /var

List the maximum LPs for LV fslv00

lslv fslv00 | grep MAX


Increase the maximum LPs for fslv00 LV

chlv -x 2048 fslv00

Create a mirrored copy of fslv08

mklvcopy -k -s y fslv08 2

›››   syncvg -l fslv08 must be run if the -k (sync now) switch is not used


for mklvcopy.
Add hdisk3 and hdisk4 to the vg01 VG

extendvg vg01 hdisk3 hdisk4

Mirror rootvg (on hdisk0) to hdisk1

extendvg rootvg hdisk1

mirrorvg -S rootvg hdisk1

bosboot -ad hdisk0


bosboot -ad hdisk1
bootlist -m normal hdisk0 hdisk1

›››   The -S option to mirrorvg mirrors the VG in the background.


Running bosboot on hdisk0 is not required - just thorough.
Find the file usage on the /var filesystem

du -smx /var

List users & PIDs with open files in /data04 mount

fuser -xuc /data04

List all mounted filesystems in a factor of Gigabytes

df -g → (-m and -k are also available)


Find what PV the LV called datalv01 is on

lslv -l datalv01

›››   The "COPIES" column relates the mirror distribution of the PPs for each LP.
(PPs should only be listed in the first part of the COPIES section. See the next
example.) The "IN BAND" column tells how much of the used PPs in this PV are used
for this LV. The "DISTRIBUTION" column reports the number of PPs in each region of
the PV. (The distribution is largely irrelevant for most modern SAN applications.)
Create a LV with 3 copies in a VG with a single PV

mklv -c 3 -s n -t jfs2 -y badlv badvg 4

›››   Note: This is an anti-example to demonstrate how the COPIES column works.


This LV violates strictness rules. The COPIES column from lslv -l badlv looks
like: 004:004:004
Move a LV from hdisk4 to hdisk5

migratepv -l datalv01 hdisk4 hdisk5


Move all LVs on hdisk1 to hdisk2

migratepv hdisk1 hdisk2

›››   The migratepv command is an atomic command in that it does not return until


complete. Mirroring / breaking LVs is an alternative to explicitly migrating them.
See additional migratepv, mirrorvg, and mklvcopy examples in this section.
Put a PVID on hdisk1
chdev -l hdisk1 -a pv=yes
›››   PVIDs are automatically placed on a disk when added to a VG
Remove a PVID from a disk

chdev -l hdisk1 -a pv=clear

›››   This will remove the PVID but not residual VGDA and other data on the
disk. dd can be used to scrub remaining data from the disk. The AIX install CD/DVD
also provides a "scrub" feature to (repeatedly) write patterns over data on disks.
Move (migrate) VG vg02 from hdisk1 to hdisk2

extendvg vg02 hdisk2


migratepv hdisk1 hdisk2
reducevg vg02 hdisk1

›››   Mirroring and then unmirroring is another method to achieve this. See the


next example
Move (mirror) VG vg02 from hdisk1 to hdisk2

extendvg vg02 hdisk2


mirrorvg -c 2 vg02
unmirrorvg vg02 hdisk1
reducevg vg02 hdisk1

›››   In this example it is necessary to wait for the mirrors to synchronize before
breaking the mirror. The mirrorvg command in this example will not complete until
the mirror is established. The alternative is to mirror in the background, but then
it is up to the administrator to insure that the mirror process is complete.
Create a striped jfs2 partition on vg01

mklv -C 2 -S 16K -t jfs2 -y vg01_lv01 vg01 400 hdisk1 hdisk2


›››   This creates a stripe width of 2 with a (total) stripe size of 32K. This command
will result in an upper bound of 2 (same as the stripe size) for the LV. If this LV is
to be extended to another two disks later, then the upper bound must be changed
to 4 or specified during creation. The VG in this example was a scalable VG.
Determine VG type of VG myvg

lsvg myvg | grep "MAX PVs"

›››   MAX PVs is 32 for normal, 128 for big, and 1024 for scalable VGs.
Set the system to boot to the CDROM on next boot

bootlist -m normal cd0 hdisk0 hdisk1

›››   The system will boot to one of the mirror pairs (hdisk0 or hdisk1) if the boot
from the CD ROM does not work. This can be returned to normal by repeating the
command without cd0.
List the boot device for the next boot

bootlist -m normal -o

You might also like