LVM, multipath and Filesystems
Fiber Channel
...
Oracle ASM
Check for ASM allocated partitions
You can run the following shell code to get the list of the ASM allocated disks along with some other data (minor device number, wwn and size of the lun)
ls -l /dev/oracleasm/disks/ | sort -n -k 6 | \
while read i i i i i minor i i i rawname; do
[ "$rawname" ] || continue
let "nl+=1"
lun="$(cat /sys/block/dm-$minor/dm/name 2>/dev/null)"
size="$(cat /sys/block/dm-$minor/size 2>/dev/null)"
echo -e "$nl. $rawname (minor:$minor) lun:$lun size:$size"
done
LVM2
Manage Volume Groups
Add a disk to and exending VG
pvcreate /dev/sde1
vgextend datavg /dev/sde1
Clustered Volume Groups
Convert a Volume Group into a Clustered Volume Group
vgchange -c y data01vg
Manual (and dangerous) procedure (tested on RHEL5 only)
vgcfgbackup -f /root/data02vg data02vg
Volume group "data02vg" successfully backed up.
# edit the file /root/data02vg
# - status = ["RESIZEABLE", "READ", "WRITE"]
# + status = ["RESIZEABLE", "READ", "WRITE", "CLUSTERED"]
vim /root/data02vg
vgremove data20vg
Do you really want to remove volume group "data02vg" containing 13 logical volumes?[y/n]: y
vgcfgrestore -f /root/data02vg data02vg
Restored volume group data02vg
vgs data02vg
VG #PV #LV #SN Attr VSize VFree
data02vg 6 13 0 wz--nc 259.81G 3.81G
vgchange -ay data02vg
Manage Logical Volumes
Create an ext3/ext4 filesystem
lvcreate -L10G -n lvdata01 datavg
mkfs.ext4 /dev/datavg/lvdata01
# setting reserved blocks percentage to 0% (0 blocks)
tune2fs -m0 /dev/datavg/lvdata01
mkdir /data01
# [/etc/fstab]
# /dev/datavg/lvdata01 /data01 ext4 defaults 1 2
mount /data01
# eventually change the owner and permissions for /data01
Extent an ext3/ext4 filesystem
lvextend -L+1G /dev/datavg/lvdata01
ext2online /dev/datavg/lvdata01 # RHEL4
resize2fs /dev/datavg/lvdata01 # RHEL5 and better
Disk Quota
A disk quota is a limit set by a system administrator that restricts certain aspects of file system usage on modern operating systems.
The function of using disk quotas is to allocate limited disk space in a reasonable way.
Mount the filesystems with quota support
If you need to add quota support to a filesystem, use the following attributes in the /etc/fstab
defaults,usrjquota=aquota.user,jqfmt=vfsv1,grpjquota=aquota.group,jqfmt=vfsv1
Then remount the filesystem
mount -o remount /your/filesystems/with/quota
Add quotas to users
Install the required software.
On RedHat, CentOS and Fedora the package is aptly called "quota":
yum install -y quota
Execute the command quotacheck (from now on we'll use as an example /srv/data01)
quotacheck -cu /srv/data01
and manually edit the quota for each user
edquota -F vfsv1 -f /srv/data01 user1
# a vi editor will be executed - we set 16Gb (hard limit) ..
Disk quotas for user pr11 (uid 501):
Filesystem blocks soft hard inodes soft hard
/dev/mapper/srv01vg-data01lv 8 0 16G 2 0 0
# ... save the text file and exit
edquota -F vfsv1 -f /srv/data01 user2
...
You can also set the same quota at command line (or in a script)
setquota user1 -F vfsv1 0 16777216 0 0 /srv/data01
Note that 16777216 is the result of 16 * 1024 * 1024.
Turn filesystem quotas on.
quotaon /srv/data01
- or all the mounted filesystems configured with the quota attribute
quotaon -a
The command quotaon announces to the system that disk quotas should be enabled on one or more filesystems. The filesystem quota files must be present in the root directory of the specified filesystem and be named either aquota.user (for version 2 user quota), quota.user (for version 1 user quota), aquota.group (for version 2 group quota), or quota.group (for version 1 group quota).
And finally check the running configuration:
quotaon -pua
user quota on /srv/data01 (/dev/mapper/srv01vg-data01lv) is on
You can also create a large file in order to get an evidence of the successful configuration
su - user1
dd if=/dev/zero of=/srv/data01/largefile bs=1G count=17