Difference between revisions of "LVM2"

From ArchWiki
Jump to: navigation, search
m (The Arch Installer)
m (lots o typos)
Line 3: Line 3:
 
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
 
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>
 
<br>
Anyone and everyone with knowledge and experinece with LVM2 are more than welcome to contribute.
+
Anyone and everyone with knowledge and experience with LVM2 are more than welcome to contribute.
 
<br>
 
<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]]
+
Since this page is far from complete, you should 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==
 
==Example 1: Install with root on lvm2==
 
'''Case:'''
 
'''Case:'''
Line 13: Line 13:
 
We need to create some partitions. One for /boot and one for the LVM setup. I prefer cfdisk for this, but you can use any tool you like.<br>
 
We need to create some partitions. 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 partition. It is possible to have the boot partition on lvm2, but you will have to use Lilo or Grub 1.95 or later. (arch provides grub 0.97 on the cd)
 
;/dev/sda1  100Mb Primary, type 83, bootable : This is going to be boot partition. It is possible to have the boot partition 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 partition for it, but it has some advantages. Mainly, many partition tools can't see a LVM setup, and just think that the space is free, unless you set up a normal partition for it. This can can cause problems e.g. if you later decide to set up dualboot with another os.
+
;/dev/sda2  20Gb  Primary, type 83 :This is where we are going to put the LVM. You don't really need to create a partition for it, but it has some advantages. Mainly, many partition tools can't see a LVM setup, and just think that the space is free, unless you set up a normal partition for it. This can can cause problems e.g. if you later decide to set up dualboot with another os.
 
<br>
 
<br>
  
Line 58: Line 58:
 
<br>
 
<br>
 
"Install Bootloader"
 
"Install Bootloader"
;/boot/grub/menu.lst : The installer usualy get this one right, but just check that everything is ok, specialy the root= line.
+
;/boot/grub/menu.lst : The installer usually get this one right, but just check that everything is ok, especially the root= line.
 
Install grub to /dev/sda and choose NO to the software raid question.
 
Install grub to /dev/sda and choose NO to the software raid question.
 
<br><br>
 
<br><br>
 
That's it, exit the installer, remove the cd, and reboot.
 
That's it, exit the installer, remove the cd, and reboot.

Revision as of 00:19, 30 September 2007

Tango-document-new.pngThis article is a stub.Tango-document-new.png

Notes: please use the first argument of the template to provide more detailed indications. (Discuss in Talk:LVM2#)

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
Anyone and everyone with knowledge and experience with LVM2 are more than welcome to contribute.
Since this page is far from complete, you should also take a look at Installing_with_Software_RAID_or_LVM, 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

Partitioning

We need to create some partitions. One for /boot and one for the LVM setup. I prefer cfdisk for this, but you can use any tool you like.

/dev/sda1 100Mb Primary, type 83, bootable 
This is going to be boot partition. It is possible to have the boot partition 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 really need to create a partition for it, but it has some advantages. Mainly, many partition tools can't see a LVM setup, and just think that the space is free, unless you set up a normal partition for it. This can can cause problems e.g. if you later decide to set up dualboot with another os.


Set up LVM2

First load the necessary kernel module:

# modprobe dm-mod


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


Create a volume group (you can use another name instead of vgroup1, if you want)

# lvm vgcreate vgroup1 /dev/sda2


Create some logical volumes(partitions) on the volume group. (you can give them any name you want)

  • 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


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.
Start the installer

# /arch/setup


In the installer, under "Prepare Hard Drive, skip directly to step 3 "Set Filesystem Mountpoints"(don't choose autoprepare or partition hard drive)

/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


"Configure System"
Important:' Answer YES to Preconfiguration with hwdetect, and to boot from LVM2

/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.


"Install Bootloader"

/boot/grub/menu.lst 
The installer usually get this one right, but just check that everything is ok, especially the root= line.

Install grub to /dev/sda and choose NO to the software raid question.

That's it, exit the installer, remove the cd, and reboot.