- Linux Training
- Desktop Tutorials
- Server Tutorials
|Creating Logical Volumes on Ubuntu 8.04|
|Server Training - Server Management|
The logical volume management is an abstract layer that allows the administrator to manipulate the volumes that are created. This manipulation includes resizing the volumes when needed. The LVM recognizes and manages volumes spanning several drives. In addition physical devices can be added to the LVM.
Advantages of LVM
2. Re-sizable Volumes
3. Disk Striping
6. Volume Snapshots
Notice that in the illustration, the foundation for Logical Volume Management is the creation of partitions on separate disks that can become physical volumes. These physical volumes are "glued" together to form a volume group. The volume group then can be divided into logical volumes and mounted on the file system.
The LVM2 is the new version of LVM in the CentOS/RHEL 5 version but must be installed in Ubuntu, even Ubuntu 8.04. The LVM2 provides more efficient use of metadata storage and redundancy, stronger recovery formatting, and atomic changes to the metadata.
Perform these tasks at your own risk...back up your data...!
Create a Linear Logical Volume on hdd
Note it you are following our virtual machine for a practice server you may have created a SCSI drive so the second drive is actually called sdb so you need to replace /dev/hdd with /dev/sdb. The first thing you need to do is create partitions on the hard drive so that you have partitions to work on to create physical volumes for the logical volume management. Note: the example shows small drive partitions, this is simply for the sake of practice and obviously you would make much larger partitions on a production server. It is always a good idea to practice these skills before you are on a production server.
# fdisk /dev/hdd
The number of cylinders for this disk is set to 3736.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/hdd: 30.7 GB, 30735581184 bytes
255 heads, 63 sectors/track, 3736 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hdd1 * 1 127 1020096 8e Linux LVM
Command (m for help): n
p primary partition (1-4)
Partition number (1-4): 2
First cylinder (128-3736, default 128):
Using default value 128
Last cylinder or +size or +sizeM or +sizeK (128-3736, default 3736): +500M
Partition number (1-4): 2
Hex code (type L to list codes): 8e
Changed system type of partition 2 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
This now means that you have an new partition /dev/hdd2 which is a LVM of 500 MB.
Once you create the LVM it is important to either restart or run partprobe so the new partition is recognized.
Create Logical Volumes
# pvcreate /dev/hdd2
Physical volume "/dev/hdd2" successfully created
# vgcreate vg1 /dev/hdd2
Volume group "vg1" successfully created
# lvcreate -L 450M -n data vg1
Rounding up size to full physical extent 452.00 MB
Logical volume "data" created
# mke2fs -j /dev/vg1/data
mke2fs 1.39 (29-May-2006)
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
115824 inodes, 462848 blocks
23142 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67633152
57 block groups
8192 blocks per group, 8192 fragments per group
2032 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
This sequence has created the logical volumes and has placed the file system on the logical volume.
Mount the Logical Volume on the File System
# mkdir /data
# mount /dev/vg1/data/ /data
If this all works fine then edit your /etc/fstab to enter the volume to be mounted at boot time.
Copyright CyberMontana Inc. and BeginLinux.com
All rights reserved. Cannot be reproduced without written permission. Box 1262 Trout Creek, MT 59874