So, a quick lesson in disk allocations. Apologies if this is already know to you.
- Originally you would have to allocate s physical volume for each filesystem. Very difficult to use on servers with few disks or lots of small disks. You might end up having far more filesystems that you want and have to mount them in some hodge-podge to get enough space in the right locations. Yes, I am that old! It was still better than having data on tape and stream-reading it in. I just about remember punched card and paper tape too, but lets not go there!
- Then you could slice the disk and allocate a slice for a filesystem. This was better, but very rigid.
- More recently we got volume managers. You allocate disk slices to them, and they give much more functionality.
Fortunately, (so far as I know) AIX has always been with a volume manager built in and nearly (if not all) other unix flavours have them too. Some were purchasable extras like Veritas but most are built in.
With a volume manager, you can allocate it whole physical disks (real local disk, SAN provided etc.) or slices of physical disks. They build them into Volume Groups and you can then allocate a portion of the volume group as a logical volume to build your filesystems on. They also allow you to mirror data (protecting against a disk failure) and other useful features such as the ability to grow/shrink logical volumes and filesystems without having to save and restore your data.
There are therefore two things you are trying to measure here:-
- How much space have I allocated
- How much space have I used
Allocated space
This is what LVM has blended and configured as logical volumes for formatting as filesystems, allocating as swap/paging space or giving to software such as a database which can use the raw disk space. On AIX, you can do
lsvg rootvg to get a summary of the root volume group (or other volume group you choose. On most Linux systems it will be
vgdisplay -v <<vgname>>
You can also do this on AIX for a single physical volume with
lspv hdisk0 or whatever (and
pvdisplay for Linux etc.) but the
lsvg/
vgdisplay will probably be what you want. This should give you the total/allocated/free physical partitions (PPs) or physical extents (PEs) in the volume group. Hopefully you have some free space here so you can manoeuvre.
Used space
This is space in filesystems used by files. This is what most people will want to know most of the time.
df -k or
df -h will probably give you what you need here, that is total filesystem size, used space, frespace and a percentage used. It also may include information about i-nodes, the space allocated to keep information about all the files in the filesystem (block lists etc.)
Adjusting space with a volume manager
AIX is easy. Something like
chfs -a size=+1 my_lv will grow the logical volume & filesystem by one 512-byte block, but because the volume group has a definition of the PP size, you will actually get the whole next PP allocated. You can, of course allocated a specific bigger number rather than adding 1 PP at a time.
Linux servers are quite easy too. Something but you work on the logical volume instead. Something like
lvextend -r -L +1G /dev/mapper/my_lv will add 1Gb to the logical filesystem and the
-r flag will extend the filesystem, indeed you can also reduce a filesystem on Linux with
lvreduce and if you use the
-r flag it will move your blocks that have data in them to within the remaining part of the logical volume. Depending on your OS version, it may unmount the filesystem to do the work and fail if it is busy.
Do you have enough information to work with or is there something you are stuck with? What sort of report do you need to produce?
I hope that this input helps,
Robin