Server Topic
   >  Introduction to RAID
   >  Installing a RAID Software
   >  Creating RAID Partitions
   >  Creating the RAID Device
   >  Creating Logical Volumes
   >  Mounting Logical Volumes
   >  Auto Mounting RAID Arrays
   >  Testing a RAID1 Array
   >  Troubleshooting RAID1 Problems


Creating Logical Volumes in Linux

Creating Logical Volumes

Once the Disc Partitions (-and the RAID Device, if you are using RAID) have been created, we need to initialise the device as a Physical Volume (PV) before LVM (Logical Volume Manager) can use it. We can do this using the following syntax:

pvcreate /dev/md<device>

Continuing with our RAID example, we would now initialise /dev/md0:

$ pvcreate /dev/md0
  Physical volume "/dev/md0" successfully created

For non-RAID, you would just replace the RAID device with the physical device name:

$ pvcreate /dev/sdb
  Physical volume "/dev/md0" successfully created

Next, we need to create a Volume Group (VG) on the newly created Physical Volume, using the syntax:

vgcreate <volume group name> <device>

For example, to create a volume group called "MYDATA01" on our RAID device:

$ vgcreate MYDATA01 /dev/md0
  Volume group "MYDATA01" successfully created

You can verify the VG creation using pvdisplay - you should see the new VG listed:

  --- Physical volume ---
  PV Name            /dev/md0
  VG Name            MYDATA01
  PV Size               931.51 GiB / not usable 3.12 MiB
  Allocatable          yes 
  PE Size               4.00 MiB
  Total PE              238466
  Free PE               8066
  Allocated PE        230400
  PV UUID              s3KoB3-vXY1-LCjr-5UeG-xxxx-yyyy-zzzzzz

Next, we need to create a Logical Volume on the new VG, using the syntax:

lvcreate --name <logical volume name> --size <size required> <volume group name>

For example, to create a 900Gb logical volume called "lv01" on the "MYDATA" physical volume:

$ lvcreate --name lv01 --size 900G MYDATA01
  Logical volume "lv01" created

To verify all went well, you can list out the new LV using:

$ lvdisplay MYDATA01
  --- Logical volume ---
  LV Name                 /dev/MYDATA01/lv01
  VG Name                 MYDATA01
  LV UUID                  TpxBU4-chLW-0A0Q-2QHn-i5HZ-7tqr-AOvCUd
  LV Write Access       read/write
  LV Status                 available
  # open                      0
  LV Size                     900.00 GiB
  Current LE                230400
  Segments                 1
  Allocation                  inherit
  Read ahead sectors  auto
  - currently set to        256
  Block device              251:2

To double check, we can also list out all the devices under Device Mapper (DM) control:

$ ls /dev/mapper/
control  myServer-root  myServer-swap_1  MYDATA01-lv01

The above shows that the "MYDATA01-lv01" VG/LV is now listed under the DM directory (-which means it is under control of the Device Mapper).

We can now create a filesystem of the desired type on the logical volume, using the syntax:

mkfs.<filesystem type> -m 0 <Logical Volume Address>

In our example, we will create an ext4 filesystem on our single LV:

$ mkfs.ext4 -m 0 /dev/MYDATA01/lv01
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=1 blocks, Stripe width=0 blocks
58982400 inodes, 235929600 blocks
0 blocks (0.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
7200 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
	102400000, 214990848

Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

Note: that this will take some time to complete: the bigger the LV size, the longer it will take!

Note: the -m option tells Linux not to reserve any system space, as this will be a pure data drive

HomeSite IndexDesktop GuideServer GuideHints and TipsHardware CornerVideo SectionContact Us

 sitelock verified Firefox Download Button