Creating LVM Volumes

Like all file system management tasks in SUSE Linux Enterprise Server, you can use YaST to create LVM volumes, but as an alternative, some command-line utilities are available as well. In the next section, you can read how to accomplish this task from YaST; in the section after that, you will learn how to do it with the command-line utilities. Then, you can read about some advanced LVM features.

Creating LVM Volumes with YaST

The easiest way to create logical volumes is to use YaST. In the next steps, you will learn how to accomplish this task from the generic SUSE Linux management utility:

1. Start YaST, and enter the root password if prompted. Then from the Expert Partitioner, click LVM.

TIP YaST is modular, and each single module you work with from YaST can be called individually. To start the module to create LVM volumes from YaST, enter yast lvm_config from the command line and start working.

2. Since no logical volumes exist yet, the LVM Configuration utility prompts you to create a volume group first (see Figure 8-6). It suggests you use the volume group name system, which is fine, and also it needs to know the physical extent size you want to use. The physical extent is like a group of blocks that can be addressed by the LVM as one logical entity. The default value for the physical extent size is 4MB, which is fine. If you need to add logical volumes from a pre-SUSE Linux Enterprise Server 10 environment, check the option to use the old LVM1-compatible metadata format. Then click OK to create the volume group and continue.

Create a Volume Group

New we have to create a volume group. Typically you donl have to change anylhIng. bu1 If you are an expert, feel free to change our default:

Vol u me G rou p Name


Physical Eitern Size

| J Use Old LVM1 CompaHble Metadata Format | QK | | Cancel "|

Figure 8-6. To start volume creation, create a volume group first.

3. After creating the container to create the logical volumes in, you need to add physical volumes to it. By default, after creating the volume group, you will see a list of physical volumes that are available for that. These are typically hard disks and unused partitions. To mark a physical volume to be added to a volume group, click the physical volume, and then click Add Volume to add it to the volume group. By doing this, you will see the amount mentioned for the physical volume size increase to the total of all the physical devices. Also you will see that under Logical Volumes, the available size is indicated. You can see all this in Figure 8-7.

Figure 8-7. After creating the volume group, you need to add physical devices to it.

4. Now in the right pane, you can create the logical volumes in the volume group. Click Add to start the interface that helps you with that. The Create Logical Volume dialog box will appear (see Figure 8-8). This dialog box is pretty similar to the one used to create partitions. Some options are available that haven't been discussed so far:

• Logical Volume Name: This is the device name given to the logical volume. The name of the device in /dev will be /dev/volumegroupname/volumename, such as /dev/system/ datavol.

• Stripes: This is the number of stripes that are written simultaneously. If a volume consists of three disks, it makes sense to load balance writes to these three disks simultaneously. You can do this by selecting three stripes. The maximum number of stripes that LVM supports is eight, and it is never possible to use more stripes than the number of hard drives physically present in your server.

• Stripe Size: This refers to the size of the stripe. By default, a stripe is 64KB, which works well with most controllers of modern hard drives. Leave it at 64, unless you are sure your hard drives controller can do better.

Figure 8-8. When creating a logical volume, you need to specify the volume name, number of stripes, and stripe size, as well as all the properties you would specify for partitions as well.

5. After creating the logical volume, you will return to the LVM configuration screen. From there, create more logical volumes as needed, or click Apply to apply all the changes and write them to disk.

Creating LVM Volumes from the Command Line

You have just read how to create logical volumes from YaST. As an alternative, you can create them from the command line. Basically, this is a simple three-step procedure:

1. Use pvcreate to assign the physical volumes you want to add to the volume group. For example, use pvcreate /dev/sd{b,c,d} to assign the devices sdb, sdc, and sdd to be used by LVM.

2. Next create the volume group. If you have used pvcreate before to assign the physical volumes, now you can use vgcreate to create the volume group. For example, use vgcreate somegroup /dev/sd{b,c,d} to create the volume group. Note that in this name, somegroup is the name of the volume group that is created. When making volumes from the volume group, you have to refer to this volume group name.

3. Now use lvcreate to create the logical volumes. For example, lvcreate -n somevol -L150M somegroup would create the volume somevol as a new volume with a size of 150MB from the logical volume group somegroup.

Tip If you want to include a complete hard disk in a volume group, it is important that no partition table is present on that hard disk. To wipe an existing partition table, use dd if=/dev/zero of=/dev/sdx; after that, the hard disk will be ready for use by LVM. This is something you need to do when working from the command line. If you are using YaST, it will happen automatically.

After creating logical volumes this way, some commands are available to manage them. For example, you can add new devices to the volume group after the device has been installed in your computer. For this purpose, use vgextend somegroup /dev/sde, which will add the device /dev/sde to the volume group somegroup.

As long as the media is not in use, you can remove it from the volume group by using the vgreduce command. For example, vgreduce somegroup /dev/sde would remove sde from the volume group again. Another important task is to monitor the status of the volume group or the volume. Use vgdisplay somegroup to display the properties of the volume group; if you want to show properties of a logical volume, use lvdisplay somevol instead. (somegroup is the name of the volume group you want to monitor properties for, and somevol is the name of the volume you want to inspect.)

Was this article helpful?

0 0


  • Bandobras
    How to make logical partition in sles?
    7 months ago

Post a comment