5: # Introduction
7: This page describes howto setup NetBSD to be able to use linux lvm tools and libdevmapper for lvm. For now my work was done on haad-dm branch in main netbsd repository I want to merge my branch back to main repository as soon as it will be possible.
9: LVM support has been merged to NetBSD-current on the 23rd of December 2008.
11: # Details
13: Tasks needed to get LVM on NetBSD working
15: * Get latest sources
16: * Compile new kernel and tools
17: * Create PV, LV and VG's and enjoy :)
19: ## Howto update/checkout sources
21: You can checkout the latest sources with this command
24: $ export CVS_RSH="ssh"
25: $ export CVSROOT="firstname.lastname@example.org:/cvsroot"
26: $ cvs checkout -dfP src
29: Or update by command
32: $ export CVS_RSH="ssh"
33: $ export CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"
34: $ cvs update -dfP
37: There are only 3 directories which were changed in my branch
39: 1. sys/dev/dm
40: 2. external/gpl2/libdevmapper
41: 3. external/gpl2/lvm2tools
43: ## Howto setup NetBSD system to use lvm
45: The easiest way is to build distribution and sets. You need to build with flag MKLVM set to yes.
47: $ cd /usr/src $ ./build.sh -u -U -V MKLVM=yes tools distribution sets
49: After successful build update your system with them. You can also run make install (as root) in src/external/gpl2/lvm2 to install userland part of LVM into the existing NetBSD system. There is also simple driver used by LVM2 tools in our kernel in src/sys/modules/dm you have to install and load this driver before you test lvm. The NetBSD LVM uses same tools as Linux and therefore we have the same user interface as is used in many common linux distributions.
54: ### Howto compile new kernel
56: Kernel compilation procedure is described here <http://www.netbsd.org/docs/guide/en/chap-kernel.html#chap-kernel-build.sh> To get device-mapper compiled in kernel you have to add this option to kernel config file
59: pseudo-device dm
62: ### Using new MODULAR modules
64: There are two versions of modules in NetBSD now old LKM and new MODULAR modules. New modules are build in sys/modules/. All GENERIC kernels are compiled with support for new modules. There is reachover makefile for dm driver in sys/modules/dm. You can use it to build dm module.
66: For loading new style modules new module utils are needed. You need to add
72: to /etc/mk.conf and build *modload*, *modstat* and *modunload*.
74: ### Compile lvm2tool and libdevmapper
76: To get lvm working it is needed to compile and install linux lvm tools. They are located in
78: * external/gpl2/libdevmapper
79: * external/gpl2/lvm2tools
81: Only make/make install is needed to build/install tools to machine. Tools are not integrated in to lists and build system now. Therefore it is possible that when you try to add them to build process it will fail(with error to many file in destdir).
83: ## Using lvm on NetBSD
85: lvm2tools are used to manage your lvm devices.
87: lvm pvcreate /dev/raw_disk_device # create Physical Volume
88: lvm vgcreate vg00 /dev/raw_disk_device #create Volume Group-> pool of available disk space.
89: lvm lvcreate -L20M -n lv1 vg00 # create Logical volume aka Logical disk device
90: newfs /dev/vg00/rlv1 # newfs without -F and -s doesn't work
91: mount /dev/vg00/lv1 /mnt # Enjoy
94: After reboot, you can activate all existing Logical Volumes (LV) in the system with the command:
96: lvm vgchange -a y
99: You can use:
101: lvm lvdisplay vgdisplay pvdisplay to see the status of your LVM devices.
104: You can also use lvm lvextend/lvreduce to change size of LV.
106: I haven't tested my driver on SMP system there are probably some bugs in locking so be aware of it :) and do not try to extend/reduce partition during I/O (something bad can happend).
110: * Review locking - I will probably allow only one ioctl call to be inside dm driver at time. *DONE*
112: * Write snapshot driver -only skeleton was written yet.
114: * Add ioctls needed to correct newfs functionality. I tried to implement them in device-mapper.c::dmgetdisklabel but it doesn't work yet. *DONE*
116: * Write lvm rc.d script to enable LVM before disk mount so we can use lvm for system partitions. *DONE*
CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb