- mdadm & lvm exercise
- This is my experience with these 2 tools on sme. They concern hard disks and raids.
- This was confusing for me, so I wanted to write it down for later use.
- I'm not going to explain what a raid is. That is outside the scope of this document.
- I'm not an expert and this info was pulled by from different sources on the internet and man pages.
- You can follow along but I'm going to put a dash (-) to indicate every command. Don't include the dash in the command.
- SCENERIO
Normally I would partition a hard disk with 3 partitions to get my linux going: boot, swap and root. Boot is what's used to boot the computer. Swap is a memory swap or virtual memory. Root is everything else including all your documents.
- PROBLEM
I can't understand volumes and the lvm.
- PLAIN ENGLISH EXERCISE
mdadm & lvm are new tools to sme, replacing other tool that are no longer available.
mdadm stands for multiple device administrator. This is the linux software raid tool. It is one tool that manages drives. You can take 2 hard disks and raid them together to make multiple disk or md. You can view your md's by: --cat /proc/mdstat
When I do this, I get: Personalities : raid1 md2 : active raid1 hda20
78047936 blocks 2/1 U_
md1 : active raid1 hda10
102400 blocks 2/1 U_
This shows I have 2 md's known as md1 and md2. It also shows that I'm missing a hd. You can see this in the 2/1 U_. If the md was correct, it would show 2/2 UU. Fixing it is beyond this doc.
Sme automatically creates md's during installation, *even with only 1 disk. Here's how it stacks up: 1 disk: One-way RAID1 mirror 2 disks: Two-way RAID1 mirror 3-5 disks: RAID5 6+ disks: RAID6 NOTE: All disks must be the same size in 7.0
Previously, you would end here because your md's would be your boot, swap and root "partitions." But not in v7. This is just the beginning.
Some md's are used at this level. md1 is the boot "partition." It's not passed to lvm because you can't boot with lvm easily (yet). Some md's are passed to the lvm.
lvm stands for linux volume manager. This is the linux volume raid tool. It is a group of many of tools that manages volumes (as compared to a single tool). This whole lvm thing is hard for me to understand but basically I think of it as a raid for a raid. This only made sense for when going through an exercise. When the md's are passed on, lvm sees them as physical volume or pv's (which is interesting because in my mind the volumes aren't physical, they're logical). It's easier for me if I think of them as volume disks. You can view your pv's by: --pvscan
- When I do this, I get
- PV /dev/md2 VG vg_primary lvm2 74.41 GB / 32.00 MB free Total: 1 74.41 GB / in use: 1 74.41 GB / in no VG: 0 0
You can see a detail view of the pv by doing a: --pvdisplay
- When I do this, I get
- --- Physical volume --- PV Name /dev/md2 VG Name vg_primary PV Size 74.41 GB / not usable 0 Allocatable yes PE Size (KByte) 32768 Total PE 2381 Free PE 1 Allocated PE 2380 PV UUID kppa2F-77j7-l0VL-otIE-zeAn-9Cty-PX4qEm
Basically, the same info with a little extra details. You'll notice the pv name is: /dev/md2.
Physical volumes are then grouped together to create volume groups or vg's (this is that raid on raid thing because you are grouping raids together). It's easier for me if I thing of them as volume raids. To make things simple, in this example we only have 1 pv so sme doesn't group anything together. It just uses the 1 pv as the vg. You can view your vg's by doing a: --vgscan
- When I do this, I get
- Reading all physical volumes. This may take a while... Found volume group "vg_primary" using metadata type lvm2
You can see a detail view of the vg by doing a: --vgdisplay
- When I do this, I get
- --- Volume group --- VG Name vg_primary System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 1 Act PV 1 VG Size 74.41 GB PE Size 32.00 MB Total PE 2381 Alloc PE / Size 2380 / 74.38 GB Free PE / Size 1 / 32.00 MB VG UUID aUVYMh-vIud-5rKK-PJJU-6goM-lELz-CY2u67
Once again, basically the same info with a little extra details. You'll notice the vg name is: vg_primary
Volume groups are then broken up into logical volumes or lv's. It's easier for me if I think of them as volume partitions. You can view your lv's by doing a: --lvscan
- When I do this, I get
- ACTIVE '/dev/vg_primary/lv_root' 73.62 GB inherit ACTIVE '/dev/vg_primary/lv_swap' 768.00 MB inherit
You can see a detail view of the lv by doing a: --lvdisplay
- When I do this, I get
--- Logical volume --- LV Name /dev/vg_primary/lv_root VG Name vg_primary LV UUID KVKgor-3s4Z-L2ML-V8Yq-YwQg-JzZY-0Rd8P2 LV Write Access read/write LV Status available
- open 1
LV Size 73.62 GB Current LE 2356 Segments 1 Allocation inherit Read ahead sectors 0 Block device 253:0
--- Logical volume --- LV Name /dev/vg_primary/lv_swap VG Name vg_primary LV UUID F1LZFK-DqJy-eDim-cf1M-F7RP-Z3KV-Gs4Zq1 LV Write Access read/write LV Status available
- open 1
LV Size 768.00 MB Current LE 24 Segments 1 Allocation inherit Read ahead sectors 0 Block device 253:1
Once again, basically the same info with a little extra details. You'll notice the lv names are: lv_root & lv_swap
- OVERVIEW
Here's an visual overview for people who learn by seeing. You can see in the crude diagram below we still end up with our boot, swap and root.
hda1 hdc1
\ /
\ /
md1 & md2
| |
boot pv (named: /dev/md2)
| |
vg (named: vg_primary) /\
/ \
/ \
lv_root lv_swap
- WHY I WOULD WANT THIS
You can add, remove, grow or reduce lv's on the fly! It's kinda like using partition magic or qparted without having to pull your system off-line. Secondly, lvm is in Centos and Sme. If you run into a problem, the info may help you figure out why.
- DEFINITIONS (from base to top)
mdadm (multiple device administration) =a single tool to manage disks
lvm (linux volume manager) =a group of tools to manage volumes
hd (hard disk) =a hard disk or hard drive (you'll see why this is spelled out later).
md (mulitple device) =better known as a raid. This is a group of hd's (partitions actually) in a raid config.
pv (physical volume) =a multiple device or md as seen in lvm. I think of this as volume disks.
vg (volume group) =a group of pv's together. I think of this as a volume raid.
lv (logical volume) =a section of a lv. I think of this as a volume partition.
- LINKS
http://www.tldp.org/HOWTO/LVM-HOWTO
http://www.linuxdevcenter.com/pub/a/linux/2006/04/27/managing-disk-space-with-lvm.html?page=1