The lack of available disk storage frequently plagues Linux systems administrators. The most common reasons for this are expanding databases, increasing numbers of users, and the larger number of tasks your Linux server is expected to perform until a replacement is found.
This chapter explores how to add a disk to a Linux system in two ways. The first is by moving directories from a full partition to an empty one made available by the new disk and then linking the directory structures of the two disks together. The second is by merging the partitions together to create a combined partition using the Linux Logical Volume Manager (LVM).
Features
2. LVM masks the underlying physical technology (ATA,ATAPI,IDE,SCSI,SATA,PATA,etc.)
3. LVM represents storage using a hierarchy:
a. Volume groups
a1. Physical volumes (/dev/sda2, /dev/sdb2, etc.)
b. Logical Volumes
b1. File systems
4. LVM physical volumes can be of various sizes
5. Ability to resize volumes on the fly
Note: Volume groups join: physical volumes (PVs) and Logical Volumes (LVs)
Steps to setup LVM
> Create LVM partitions via fdisk or parted
a. fdisk /dev/sda, /dev/sdb, /dev/sdc
b. n
c. p
d. +10G
e. t - change to type '8e' (LVM)
f. w
g. partprobe /dev/sda
> Create Physical Volumes using 'pvcreate'
# pvcreate /dev/sda3 /dev/sdb3 /dev/sdc3
> Create Volume Groups using 'vgcreate'
# volgroup001 /dev/sda3 /dev/sdb3 /dev/sdc3
Note: Volume groups can be segmented into multiple logical volumes
> Create one or more Logical Volumes
# lvcreate -L 10GB -n logvolvar1 volgroup001
# lvcreate -L 10GB -n logvolusr1 volgroup001
> Create File system on logical volume(s)
# mke2fs -j /dev/volgroup001/logvolvar1
# mke2fs -j /dev/volgroup001/logvolusr1
> Mount logical volume
# mkdir /var1
# mount /dev/volgroup001/logvolvar1 /var1
# /usr1
# mount /dev/volgroup001/logvolusr1 /usr1
3-tiers of LVM display commands include:
# pvdisplay <--physical volumes - represent raw LVM partitions
# vgdisplay <-- volume groups - aggregate physical volumes
# lvdisplay <-- logical volumes - file systems - mount here
Steps to Remove Logical Volume
Task: Remove 'logvolusr1' from the logical volume pool
# umount /usr1
# lvremove /dev/mapper/volgroup001-logvolusr1
> use 'lvdisplay' to confirm removal
Steps to Resize Logical Volume
Task: Grow (resize) 'logvolopt1' to 20GB
# lvresize -L 20GB /dev/volgroup001/logvolopt1
# lvdisplay - to confirm new size of logical volume
> df -h - will still reveal the current size
>Resize the file system to update the INODE table on the logical volume to account for the new storage in 'logvolopt1'
# resize2fs -f -p /dev/volgroup001/logvolopt1'
Note: You may resize file systems online if the following are met:
1. 2.6x kernel series
2. MUST be formatted with ext3
LVM GUI Utility:
system-config-lvm
No comments:
Post a Comment