Diff for /wikisrc/tutorials/how_to_use_lvm_on_netbsd.mdwn between versions 1.1 and 1.2

version 1.1, 2011/11/20 20:55:21 version 1.2, 2012/02/05 07:14:36
Line 1 Line 1
 **Contents**  **Contents**
   
 [[!toc]]  [[!toc]]
   
 #  Introduction  #  Introduction 
   
 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.  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. 
   
 LVM support has been merged to NetBSD-current on the 23rd of December 2008.  LVM support has been merged to NetBSD-current on the 23rd of December 2008. 
   
 #  Details  #  Details 
   
 Tasks needed to get LVM on NetBSD working  Tasks needed to get LVM on NetBSD working 
   
   * Get latest sources    * Get latest sources 
   * Compile new kernel and tools    * Compile new kernel and tools 
   * Create PV, LV and VG's and enjoy :)    * Create PV, LV and VG's and enjoy :) 
   
 ##  Howto update/checkout sources  ##  Howto update/checkout sources 
   
 You can checkout the latest sources with this command  You can checkout the latest sources with this command 
          
          
     $ export CVS_RSH="ssh"      $ export CVS_RSH="ssh"
     $ export CVSROOT="anoncvs@anoncvs.se.netbsd.org:/cvsroot"      $ export CVSROOT="anoncvs@anoncvs.se.netbsd.org:/cvsroot"
     $ cvs checkout -dfP src      $ cvs checkout -dfP src
          
   
 Or update by command  Or update by command 
          
          
     $ export CVS_RSH="ssh"      $ export CVS_RSH="ssh"
     $ export CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"      $ export CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"
     $ cvs update -dfP      $ cvs update -dfP
          
   
 There are only 3 directories which were changed in my branch  There are only 3 directories which were changed in my branch 
   
   1. sys/dev/dm    1. sys/dev/dm 
   2. external/gpl2/libdevmapper    2. external/gpl2/libdevmapper 
   3. external/gpl2/lvm2tools    3. external/gpl2/lvm2tools 
   
 ##  Howto setup NetBSD system to use lvm  ##  Howto setup NetBSD system to use lvm 
   
 The easiest way is to build distribution and sets. You need to build with flag MKLVM set to yes.  The easiest way is to build distribution and sets. You need to build with flag MKLVM set to yes. 
   
 $ cd /usr/src $ ./build.sh -u -U -V MKLVM=yes tools distribution sets  $ cd /usr/src $ ./build.sh -u -U -V MKLVM=yes tools distribution sets 
   
 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.  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. 
   
      
   
   
 ###  Howto compile new kernel  ###  Howto compile new kernel 
   
 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  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 
   
   
     pseudo-device dm      pseudo-device dm
          
   
 ###  Using new MODULAR modules  ###  Using new MODULAR modules
   
 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.  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. 
   
 For loading new style modules new module utils are needed. You need to add  For loading new style modules new module utils are needed. You need to add 
          
          
     MKMODULAR=YES      MKMODULAR=YES
          
   
 to /etc/mk.conf and build *modload*, *modstat* and *modunload*.  to /etc/mk.conf and build *modload*, *modstat* and *modunload*. 
   
 ###  Compile lvm2tool and libdevmapper  ###  Compile lvm2tool and libdevmapper 
   
 To get lvm working it is needed to compile and install linux lvm tools. They are located in  To get lvm working it is needed to compile and install linux lvm tools. They are located in 
   
   * external/gpl2/libdevmapper    * external/gpl2/libdevmapper 
   * external/gpl2/lvm2tools    * external/gpl2/lvm2tools 
   
 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).  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). 
   
 ##  Using lvm on NetBSD  ##  Using lvm on NetBSD 
   
 lvm2tools are used to manage your lvm devices.  lvm2tools are used to manage your lvm devices. 
          
     lvm pvcreate /dev/raw_disk_device # create Physical Volume      lvm pvcreate /dev/raw_disk_device # create Physical Volume 
     lvm vgcreate vg00 /dev/raw_disk_device #create Volume Group-> pool of available disk space.      lvm vgcreate vg00 /dev/raw_disk_device #create Volume Group-> pool of available disk space.
     lvm lvcreate -L20M -n lv1 vg00 # create Logical volume aka Logical disk device      lvm lvcreate -L20M -n lv1 vg00 # create Logical volume aka Logical disk device
     newfs  /dev/vg00/rlv1 # newfs without -F and -s doesn't work      newfs  /dev/vg00/rlv1 # newfs without -F and -s doesn't work
     mount /dev/vg00/lv1 /mnt # Enjoy      mount /dev/vg00/lv1 /mnt # Enjoy
          
   
 After reboot, you can activate all existing Logical Volumes (LV) in the system with the command:  After reboot, you can activate all existing Logical Volumes (LV) in the system with the command: 
          
     lvm vgchange -a y      lvm vgchange -a y
          
   
 You can use:  You can use: 
          
     lvm lvdisplay vgdisplay pvdisplay to see the status of your LVM devices.      lvm lvdisplay vgdisplay pvdisplay to see the status of your LVM devices.
          
   
 You can also use lvm lvextend/lvreduce to change size of LV.  You can also use lvm lvextend/lvreduce to change size of LV. 
   
 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).  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). 
   
 TODO:  TODO: 
   
   * Review locking - I will probably allow only one ioctl call to be inside dm driver at time. *DONE*    * Review locking - I will probably allow only one ioctl call to be inside dm driver at time. *DONE* 
   
   * Write snapshot driver -only skeleton was written yet.    * Write snapshot driver -only skeleton was written yet. 
   
   * Add ioctls needed to correct newfs functionality. I tried to implement them in device-mapper.c::dmgetdisklabel but it doesn't work yet. *DONE*    * Add ioctls needed to correct newfs functionality. I tried to implement them in device-mapper.c::dmgetdisklabel but it doesn't work yet. *DONE* 
   
   * Write lvm rc.d script to enable LVM before disk mount so we can use lvm for system partitions. *DONE*    * Write lvm rc.d script to enable LVM before disk mount so we can use lvm for system partitions. *DONE* 

Removed from v.1.1  
changed lines
  Added in v.1.2


CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb