Difference between revisions of "LVM2"

From ArchWiki
Jump to: navigation, search
m (Set up LVM2)
(Redirected page to LVM)
 
(5 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{stub}}
+
#REDIRECT [[LVM]]
=Logical Volume Manager v.2=
+
This is going to be a page dedicated to LVM2, with information on "what, why and how", complete with several examples. What is LVM2, Why use LVM2, How to use LVM2
+
<br>
+
Anyone and everyone with knowledge and experinece with LVM2 are more than welcome to contribute.
+
<br>
+
Since this page is far from complete, you shoud also take a look at [[Installing_with_Software_RAID_or_LVM]], [http://www.tldp.org/HOWTO/LVM-HOWTO/ TLDP LVM HOWTO] and [[RAID_Encryption_LVM]]
+
==Example 1: Install with root on lvm2==
+
'''Case:'''
+
:A desktop system with one disc, 20GB. No other os installed.
+
:''The install medium used in this example is the Archlinux-i686-2007.05-Duke-Linuxtag2007.ftp.iso
+
===Partioning===
+
We need to create some partions. One for /boot and one for the LVM setup. I prefer cfdisk for this, but you can use any tool you like.<br>
+
;/dev/sda1  100Mb Primary, type 83, bootable : This is going to be boot partion. It is posible to have the boot partion on lvm2, but you will have to use Lilo or Grub 1.95 or later. (arch provides grub 0.97 on the cd)
+
;/dev/sda2  20Gb  Primary, type 83 :This is where we are going to put the LVM. You don't realy need to create a partion for it, but it has some advantages. Mainly, many partion tools can't see a LVM setup, and just thinks that the space is free, unless you set up a normal partion for it. This can can cause e.g. if you later decide to set up dualboot with another os.
+
<br>
+
===Set up LVM2===
+
First load the necessary kernel module:
+
# modprobe dm-mod
+
<br>
+
Initialize the partition so that lvm can use it:
+
''Note: On the install cd, you have to run ''lvm [some_tool]'' instead of [some_tool] as you would on an already installed system.''
+
# lvm pvcreate /dev/sda2
+
<br>
+
Create a volume group (you can use another name instead of vgroup1, if you want)
+
# lvm vgcreate vgroup1 /dev/sda2
+
<br>
+
Create some logical volumes(partitions) on the volume group. (you can give them any name you want)<br>
+
*First, lets create a 5GB / partition:
+
# lvm lvcreate -L 5G vgroup1 -n root
+
*Next, a 512MB swap
+
# lvm lvcreate -L 512M vgroup1 -n swap
+
*And last, let's use the remaining free space for /home
+
# lvm lvcreate -l 100%FREE vgroup1 -n home
+
<br>
+
Now we need to activate the volume group before we start the installer:
+
# lvm vgchange -a y vgroup1
+
 
+
===The Arch Installer===
+
''Note: This only list the steps that have to do with lvm2. Refer to the install guide for more information about the other steps of the install.''
+
<br>
+
Start the installer
+
# /arch/setup
+
<br>
+
In the installer, under "Prepare Hard Drive, skip directly to step 3 "Set Filesystem Mountpoints"(don't choose autoprepare or partion hard drive)<br>
+
;/dev/sda1 : /boot with ext3
+
;/dev/mapper/vgroup1-root : /root with ext3
+
;/dev/mapper/vgroup1-swap : swap with swap
+
;/dev/mapper/vgroup1-home : /home with ext3
+
<br>
+
"Configure System"<br>
+
''Important:' Answer YES to Preconfiguration with hwdetect, and to boot from LVM2
+
<br>
+
;/etc/rc.conf : Chang USELVM="no" to USELVM="yes"
+
;/etc/mkinitcpio.conf : Make sure that lvm2 is present in HOOKS=
+
;/etc/fstab : Just glance over it to check that the mount points are correct.
+
<br>
+
"Install Bootloader"
+
;/boot/grub/menu.lst : The installer usualy get this one right, but just check that everything is ok, specialy the root= line.
+
Install grub to /dev/sda and choose NO to the software raid question.
+
<br><br>
+
That's it, exit the installer, remove the cd, and reboot.
+

Latest revision as of 07:48, 21 June 2009

Redirect to: