Sei sulla pagina 1di 10

Partitioning

LVM partitions must be of type 8e (Linux LVM.) We are going to use fdisk to define three (3) new
partitions on available disks installed in our server.

1. Lets begin by taking a look at our current disks and their associated partitions (you must be root)

[root@Linux01 ~]# fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes


255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System


/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1305 10377990 8e Linux LVM

Disk /dev/sdb: 4294 MB, 4294967296 bytes


255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 4294 MB, 4294967296 bytes


255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdc doesn't contain a valid partition table

Disk /dev/sdd: 4294 MB, 4294967296 bytes


255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdd doesn't contain a valid partition table


[root@Linux01 ~]#
2.
As you can see, we have one disk (/dev/sda) which already has a couple of partitions (for the running OS.) We have
highlighted the three available disks which we will use for our LVM file system (/dev/sdb, /dev/sdc/ and /dev/sdd).

3. Define a new partition of type 8e (Linux LVM) on /dev/sdb using fdisk

[root@Linux01 ~]# fdisk /dev/sdb


Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Physical Volume Creation

Physical volumes are the disk resources used to create the LVM. The volumes are
usually simple disk partitions (i.e. /dev/sda1, /dev/sda2 etc) or they can be Linux software
RAID volumes (i.e. /dev/md0, /dev/md1 etc.) It is important to note that LVM does not
provide data protection or redundancy such as RAID, so additional measures should be
taken to ensure fault tolerance is built into the LVM volumes.

We will use pvcreate to initialize the newly created partitions.

1. Check to see what (if any) physical volumes (PV's) already exist on the system

[root@Linux01 ~]# pvdisplay


--- Physical volume ---
PV Name /dev/sda2
VG Name VolGroup00
PV Size 9.90 GB / not usable 22.76 MB
Allocatable yes (but full)
PE Size (KByte) 32768
Total PE 316
Free PE 0
Allocated PE 316
PV UUID 3NzAOq-mdpQ-3XDA-eqAE-F0jf-Y22F-s1lTQ4

[root@Linux01 ~]#
2.
We already have one PV created on our system (this is in use by our OS) which is
a member of Volume Group VolGroup00.

3. Create 3 new physical volumes (PV's) from /dev/sdb1, /dev/sdc1 and /dev/sdd1

[root@Linux01 ~]# pvcreate /dev/sdb1 /dev/sdc1 /dev/sdd1


Physical volume "/dev/sdb1" successfully created
Physical volume "/dev/sdc1" successfully created
Physical volume "/dev/sdd1" successfully created
[root@Linux01 ~]#

4. Verify the creation of the new volumes with pvdisplay


[root@Linux01 ~]# pvdisplay

--- Physical volume ---


PV Name
/dev/sda2VG Name VolGroup00
PV Size 9.90 GB / not usable 22.76 MB
Allocatable yes (but full)
PE Size (KByte) 32768
Total PE 316
Free PE 0
Allocated PE 316
PV UUID 3NzAOq-mdpQ-3XDA-eqAE-F0jf-Y22F-s1lTQ4

"/dev/sdb1" is a new physical volume of "4.00 GB"


--- NEW Physical volume ---
PV Name
/dev/sdb1VG Name
PV Size 4.00 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID Co3JxS-qx30-clUX-wP3t-1xmV-tjBK-QmoyBr

"/dev/sdc1" is a new physical volume of "4.00 GB"


--- NEW Physical volume ---
PV Name
/dev/sdc1VG Name
PV Size 4.00 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID jcNBJ9-Mqh6-dsFD-Z14x-jpoo-Rhh2-z1hGIf

"/dev/sdd1" is a new physical volume of "4.00 GB"


--- NEW Physical volume ---
PV Name
/dev/sdd1VG Name
PV Size 4.00 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID
UQVaeK-sRTe-iKJw-IEVd-38fn-3kiK-qqWhEt

1. Lets begin by taking a look at the Volume Groups the are already present on the
system

[root@Linux01 ~]# vgdisplay


--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 6
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 5
Open LV 5
Max PV 0
Cur PV 1
Act PV 1
VG Size 9.88 GB
PE Size 32.00 MB
Total PE 316
Alloc PE / Size 316 / 9.88 GB
Free PE / Size 0/0
VG UUID zz6pnX-TR24-jPcE-zHrv-loz5-TPd2-eERHtq

2. Create a new Volume Group with the name TCPDumpVolGRP using /dev/sdb1,
/dev/sdc1 and /dev/sdd1 with a physical extent size of 32 MB
[root@Linux01 ~]# vgcreate TCPDumpVolGRP /dev/sdb1 /dev/sdc1 /dev/sdd1 -s
32M
Volume group "TCPDumpVolGRP" successfully created
[root@Linux01 ~]#
3. Verfiy the Volume Group was created successfully
[root@Linu01 ~]# vgdisplay
--- Volume group ---
VG Name TCPDumpVolGRP
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 3
Act PV 3
VG Size 11.91 GB
PE Size 32.00 MB
Total PE 381
Alloc PE / Size 0/0
Free PE / Size 381 / 11.91 GB
9fWFIS-vDlg-xOW6-Xmb8-Tkrg-GPZw-
VG UUID
ZnUZwh

--- Volume group ---


VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 6
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 5
Open LV 5
Max PV 0
Cur PV 1
Act PV 1
VG Size 9.88 GB
PE Size 32.00 MB
Total PE 316
Alloc PE / Size 316 / 9.88 GB
Free PE / Size 0/0
VG UUID zz6pnX-TR24-jPcE-zHrv-loz5-TPd2-eERHtq
4.

1. Define a new LV with 100 extents

[root@Linux01 ~]# lvcreate -l 100 -n TCPDumpLV TCPDumpVolGRP


Logical volume "TCPDumpLV" created
[root@Linux01 ~]#
2.
3. Verify the LV was created successfully

[root@Linux01 ~]# lvdisplay


--- Logical volume ---
LV Name /dev/TCPDumpVolGRP/TCPDumpLV
VG Name TCPDumpVolGRP
LV UUID hYQs4t-YtY7-51hl-c4ps-4N6d-2W7h-IidcxF
LV Write Access read/write
LV Status available
# open 0
LV Size 3.12 GB
Current LE 100
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:5
4. Note: As you can see, there are 100 logical extents in the TCPDumpLV. Since we
know the extent size is 32MB, the total size of the LV is 3.12 GB (100 x 32 =
3200MB / 1024MB = 3.12 GB)

We will now create another LV, but this time specifying the total size of the LV. Lets
begin:

1. Define a new LV that is 4GB in size

[root@Linux01 ~]# lvcreate -L 4GB -n 4GLV TCPDumpVolGRP


Logical volume "4GLV" created
[root@Linux01 ~]#
2.
3. Verify the LV was created successfully

[root@Linux01 ~]# lvdisplay


--- Logical volume ---
LV Name /dev/TCPDumpVolGRP/4GLV
VG Name TCPDumpVolGRP
LV UUID 2y9Ro0-N0xD-9Ys5-Nb5y-svc8-QgNE-tFr8mH
LV Write Access read/write
LV Status available
# open 0
LV Size 4.00 GB
Current LE 128
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:6
4. Note: Since we know the extent size is 32 MB and the LV size to be 4 GB, we can
calculate the number of extents with (4000GB / 32MB = 125 extents)

Lets take one last look at our TCPDumpVolGRP Volume Group before we move on.
You'll notice in the following output that our physical extents allocation has increased
and the number of free extents has decreased. These numbers will correlate with the LV's
that we created above: 128 extents + 100 extents = 228 total extents in use

[root@Linux01 ~]# vgdisplay


--- Volume group ---
VG Name TCPDumpVolGRP
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 0
Max PV 0
Cur PV 3
Act PV 3
VG Size 11.91 GB
PE Size 32.00 MB
Total PE 381
Alloc PE / Size 228 / 7.12 GB
Free PE / Size 153 / 4.78 GB
9fWFIS-vDlg-xOW6-Xmb8-Tkrg-GPZw-
VG UUID
ZnUZwh
 Format LV TCPDumpLV

[root@Linux01 ~]# mke2fs -j /dev/TCPDumpVolGRP/TCPDumpLV


mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
409600 inodes, 819200 blocks
40960 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=838860800
25 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912

Writing inode tables: done


Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 22 mounts or


180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@Linux01 ~]#

 Format LV 4GLV

[root@Linux01 ~]# mke2fs -j /dev/TCPDumpVolGRP/4GLV


mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
524288 inodes, 1048576 blocks
52428 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1073741824
32 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736

Writing inode tables: done


Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 20 mounts or


180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@Linux01 ~]#

Mount LV 4GLV on the mount point of /4GLV

[root@Linux01 ~]# mkdir /4GLV


[root@Linux01 ~]# mount /dev/TCPDumpVolGRP/4GLV /4GLV

1.
2. Mount LV TCPDumpLV on the mount point of /TCPDumpLV

[root@Linux01 ~]# mkdir /TCPDumpLV


[root@Linux01 ~]# mount /dev/TCPDumpVolGRP/TCPDumpLV /TCPDumpLV
3.
4. Verify the mounts points using df

[root@Linux01 ~]# df -kh


Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-
3.9G 2.2G 1.6G 59% /
LogVol04
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 1006M 0 1006M 0% /dev/shm
/dev/mapper/VolGroup00-
992M 41M 901M 5% /home
LogVol00
/dev/mapper/VolGroup00-
992M 69M 872M 8% /tmp
LogVol02
/dev/mapper/VolGroup00-
2.0G 150M 1.7G 8% /var
LogVol03
/dev/mapper/TCPDumpVolGRP-
4.0G 137M 3.7G 4% /4GLV
4GLV
/dev/mapper/TCPDumpVolGRP-
3.1G 69M 2.9G 3% /TCPDumpLV
TCPDumpLV
Updating fstab

Nice work, you are now ready to use your new LV. However, before we finish up, we
need to add the new LV to our fstab so that it will auto mount on reboot.

1. Using your favorite editor, add the following to your /etc/fstab file

/dev/mapper/TCPDumpVolGRP-4GLV /4GLV ext3 defaults 0 0


/dev/mapper/TCPDumpVolGRP-
/TCPDumpLV ext3 defaults 0 0
TCPDumpLV
2.
3. Verfy you syntax allowing mount to read from the fstab file

[root@Linux01 ~]# umount /4GLV


[root@Linux01 ~]# umount /TCPDumpLV
[root@Linux01 ~]# mount -a
[root@Linux01 ~]# df -kh
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-
3.9G 2.2G 1.6G 59% /
LogVol04
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 1006M 0 1006M 0% /dev/shm
/dev/mapper/VolGroup00-
992M 41M 901M 5% /home
LogVol00
/dev/mapper/VolGroup00-
992M 69M 872M 8% /tmp
LogVol02
/dev/mapper/VolGroup00-
2.0G 150M 1.7G 8% /var
LogVol03
/dev/mapper/TCPDumpVolGRP-
4.0G 137M 3.7G 4% /4GLV
4GLV
/dev/mapper/TCPDumpVolGRP-
3.1G 69M 2.9G 3% /TCPDumpLV
TCPDumpLV

Potrebbero piacerti anche