Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Components > Hard Drives & Storage

Reply
 
LinkBack Thread Tools
Old 02-16-08   #1 (permalink)
The Game
 
lattyware's Avatar
 
intel nvidia

Join Date: Feb 2007
Location: In A Faraday Cage
Posts: 2,656

Rep: 280 lattyware is a proven memberlattyware is a proven memberlattyware is a proven member
Unique Rep: 206
Folding Team Rank: 564
Hardware Reviews: 1
Trader Rating: 0
Lightbulb A Guide To LVM: Making Your Hard Drives Fit Your Data, Not The Other Way Around.

A Guide To LVM: Making Your Hard Drives Fit Your Data, Not The Other Way Around.

LVM? What is this? LVM - Logical Volume Management - is a way you make your hard drives fit your data.

Let me explain further, I'll use a specific example.

Let's say a user has 3 hard drives as so:

hda: 250GB hard drive
hdb: 500GB hard drive
hdc: 80GB hard drive

Now, say this user has his drives partitioned as so:

hda1: (/) 50GB System Partition.
hda2: 2GB Swap Partition.
hda3: (/home) 148GB Storage Partition.
hdb1: (/media/storage1) 500GB Storage Partition.
hdc1: (/media/storage2) 80GB Storage Partition.

Now, this works. Problem is, the user has a lot of video, but he runs out of space, so he moves to to his other drive, but this means when he wants something, he has to go to /media/storage1 and /home to look for the files. Then if he uses all three, he has to do it again. This ends up getting very annoying.

So, how does LVM help?

Well, it works like this:

(Same system)

hda1: (/) 50GB System Partition.
hda2: 2GB Swap Partition.
hda3: 148GB LVM Partition.
hdb1: 500GB LVM Partition.
hdc1: 80GB LVM Partition.

The user then adds hda4, hdb1 & hdc1 to a Logical Volume Group. Then he creates a logical volume 'data' and assigns 148GB of storage to it. This gives him the same effect as before, and, as before, he runs out of space. This time, he just adds to the volume. He puts on another 100GB of space. When he needs more he adds more, and no data is lost in doing so. It all gets mounted at /home.

LVM makes seamless space. Different drives are all seen as one large space, which can be used as needed. You can create as many logical volumes as you want, and mount them anywhere, and give them any amount of space you wish.

The Good & The Bad

Good Points About LVM:
  • Fits hard drives to data, where classically data is fitted to hard drives. It's easier.
  • Logical Volumes can be expanded as needed, and if you get a new drive, you can add it to the Logical Volume Group and expand your existing Logical Volumes out to fill that space.
  • You can have as many partitions as you want without using Extended partitions.

Bad Points About LVM:
  • LVM is not RAID - it does not speed up your drives by writing to them simultainously. LVM will not give performance.
  • If one drive in a Logical Volume Group dies, the whole group goes with it.
  • When it comes to checking file systems, you now have both the LVM file systems and the partition within the Logical Volume.
  • Boot loaders can not read LVM filesystems - if you want to use LVM for your root filesystem, you will need a separate /boot.

How would I create an LVM setup?
First of all, install the stuff needed for LVM. You'll be looking for the lvm2 & dmsetup packages ('sudo apt-get install lvm2 dmsetup' for those 'buntu users, pacman -S lvm2 dmsetup for Arch, etc...). Next you will need to partition your drives. Unfortunatly gParted doesn't support LVM partitions, so you'll have to use the command-line fdisk to create them - don't worry, it's not too hard. First of all, clear out your drives till you have all the blank space you want to put your LVM volumes into - you can do that with gParted. Then just do 'fdisk /dev/hdx' replacing hdx with your volume you want to add an LVM partition to. Once done, do 'n' for new partition, make it a primary one and use up all the availible space (so just hit enter spacing-wise), then do t, choose the partition you just made, and make it type 8e (Linux LVM). Then hit 'w' to write it to disc. Then do the same for any other LVM partitions you want to make.
Now we use 'pvcreate' - this creates our physical volumes for use with LVM. You just need to put all of the LVM volumes you just made into it. So, with out example the command would be 'pvcreate /dev/hda3 /dev/hdb1 /dev/hdc1'. Once this is done you can do 'pvdisplay' to see about the volumes.
Next we create our Volume Group - this is our heap of storage space. 'vgcreate' is the command. You need to do 'vgcreate name volumes' - the name can be anything you want, lower case and one word. So for our example we could use 'vgcreate data /dev/hda3 /dev/hdb1 /dev/hdc1' - the name is just for your benefit - data generally suits. You can use 'vgdisplay' to show your volume groups, 'vgscan' to look for Volume Groups, and 'vgrename <old name> <new name>' to... well, I'm sure you can work it out.
Now we can create our Logical Volume. Can you guess the command? The inventively named 'lvcreate' is here to do the job. 'lvcreate --name <name> --size xGB <volume group>' - so if I wanted one as per the example I'd use 'lvcreate --name data --size 100GB data' - I'm being unimaginative and using the same name for logical volume and volume group. Say we want a backup Logical Volume as well, we could do 'lvcreate --name backup --size 100GB data' to make it. We can use 'lvdisplay' to take a look at our handywork, and 'lvscan' and 'lvrename' are there too.
We can also do 'lvextend' or 'lvreduce' - the latter being risky to your data. 'lvextend -L10GB /dev/data/data' and 'lvreduce -L10GB /dev/data/backup' for example.
At the moment, we have Logical Volumes, but they are useless. Let's create an ext3 filesystem on our 'data' logical volume in our 'data' logical volume group. 'mkfs.ext3 /dev/data/data' will do the trick, and, obviously, 'mkfs.ext3 /dev/data/backup'
You can now mount your filesystems. 'mount /dev/data/data /home/user/Documents' - for example. Remember to add them to fstab if you want them to be mounted at boot. (so do 'sudo nano /etc/fstab' or 'su && nano /etc/fstab' and then add a line such as '/dev/data/data /home/user/Documents ext3 rw,noatime 0 0' to the end.

Changing the LVM setup.
You can add another hard disc to a Volume Group with 'vgextend <volume group name> <physical volume>' after creating the physical volume.
You can extend a volume after it's got a file system on by extending with 'lvextend', then doing 'e2fsck -f' and 'resize2fs' on your logical volume. You can shrink by doing the same thing in reverse (e2fsck and resize2fs, then lvreduce).

Where can I get more help?
Ask here, google it, or check out the man pages for that command.
__________________
Lattyware | Main (Sig) Rig: gBOX42 | Lan Rig: gLAN42
Never been convinced by Linux? Here is a challenge. | Using LVM
Scratched Disc? | Guide To LAN Parties | Writing a GUI application in Python/Glade
Etching an image into your case. | Wireless Access Points: Easy wireless networking.
A Member Of The OCN Anime/Manga Club

"I disapprove of what you say, but I will defend to the death your right to say it." --Evelyn Beatrice Hall

System: gBOX42
CPU
Core 2 Duo E6600 @ 3.51GHz
Motherboard
Asus P5B Deluxe/WiFi-AP
Memory
2 x OCZ DDR2 Platinum 1Gb PC6400 C4
Graphics Card
256MB MSI 8600GTS
Hard Drive
2x 1TB SATA, 2 x 500GB SATA
Sound Card
Creative Soundblaster Audigy SE
Power Supply
SEASONIC S12-600
Case
CoolerMaster Cosmos
CPU cooling
XSPC X2O Delta CPU Waterblock V2
GPU cooling
D-Tek FuZion GFX Block
OS
Arch Linux x64
Monitor
Dell 2407WFP, Dell E248WFP
lattyware is offline I fold for Overclock.net Overclocked Account lattyware's Gallery   Reply With Quote
Old 02-17-08   #2 (permalink)
Sup'
 
Duckydude's Avatar
 
intel nvidia

Join Date: May 2005
Location: Charlottesville, VA
Posts: 2,988

Trader Rating: 20
Default

Interesting... Sort of sounds like the linux equal to Dynamic drives in Windows. Good guide though .

System: i7 Amazazingness
CPU
Core i7 920 At 3.8Ghz 1.364v
Motherboard
EVGA X58
Memory
Gskill DDR3 3 x 2GB DDR1600 9-9-9-24
Graphics Card
EVGA GTX 260 Core 216 626/2100
Hard Drive
2 150GB Raptors + 2 1TB WD Blacks Each In RAID 0
Sound Card
Auzen X-Fi Prelude + Zhaolu DAC D3.0
Power Supply
Corsair HX620
Case
Antec P180
CPU cooling
TR. Ultra 120 Extreme (Lapped) w/ 2 120mm fans
GPU cooling
Stock EVGA Cooler
OS
Windows Vista Ultimate x64 SP1 (Vlited)
Monitor
Dell 2407WFP Rev. A02
Duckydude is offline Overclocked Account   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -4. The time now is 09:04 PM.


Overclock.net is a Carbon Neutral Site Creative Commons License

Terms of Service / Forum Rules | Privacy Policy | DMCA Info | Advertising | Become an Official Vendor
Copyright © 2009 Shogun Interactive Development. Most rights reserved.
Page generated in 0.11906 seconds with 8 queries