Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1842233
  • 博文数量: 334
  • 博客积分: 11301
  • 博客等级: 上将
  • 技术积分: 3452
  • 用 户 组: 普通用户
  • 注册时间: 2006-10-18 10:19
个人简介

路虽弥,不行不至;事虽少,不做不成。

文章分类

全部博文(334)

文章存档

2013年(4)

2012年(19)

2011年(27)

2010年(71)

2009年(45)

2008年(15)

2007年(84)

2006年(69)

分类: LINUX

2006-11-20 09:24:18

一)LVM问题
1)What is Logical Volume Manager (LVM)?

    LVM is a method of allocating hard drive space into logical volumes that can be easily resized instead of partitions.

    With LVM, the hard drive or set of hard drives is allocated to one or more physical volumes. A physical volume can not span over more than one drive.

    The physical volumes are combined into logical volume groups, with the exception of the /boot/ partition. The /boot/ partition can not be on a logical volume group because the boot loader can not read it. If the root / partition is on a logical volume, create a separate /boot/ partition which is not a part of a volume group.

    Since a physical volume can not span over more than one drive, to span over more than one drive, create one or more physical volumes per drive.

    The logical volume group is divided into logical volumes, which are assigned mount points such as /home and / and file system types such as ext3. When "partitions" reach their full capacity, free space from the logical volume group can be added to the logical volume to increase the size of the partition. When a new hard drive is added to the system, it can be added to the logical volume group, and the logical volumes that are the partitions can be expanded.

    On the other hand, if a system is partitioned with the ext3 file system, the hard drive is divided into partitions of defined sizes. If a partition becomes full, it is not easy to expand the size of the partition. Even if the partition is moved to another hard drive, the original hard drive space has to be reallocated as a different partition or not used.

    LVM support must be compiled into the kernel. The default Red Hat kernel is compiled with LVM support.

2)How do I configure LVM with Disk Druid ?
 
    LVM can be configured during the graphical installation process or during a kickstart installation. You can use the utilities from the lvm package to create your LVM configuration, but these instructions focus on using Disk Druid during installation to complete this task.

An overview of the steps required to configure LVM:

  • Create physical volumes from the hard drives.
  • Create volume groups from the physical volumes.
  • Create logical volumes from the volume groups and assign the logical volumes mount points.

Note: You can only edit LVM volume groups in GUI installation mode. In text installation mode, you can assign mount points to existing logical volumes.

To create a logical volume group with logical volumes during installation:

  1. On the Disk Partitioning Setup screen, select Manually partition with Disk Druid.
  2. Select New.
  3. Select physical volume (LVM) from the File System Type pulldown menu as shown in the following figure.
  4. You will not be able to enter a mount point (you will be able to do that once you have created your volume group).
  5. A physical volume must be constrained to one drive. For Allowable Drives, select the drive on which the physical volume will be created. If you have multiple drives, all drives will be selected, and you must deselect all but one drive.
  6. Enter the size that you want the physical volume to be.
  7. Select Fixed size to make the physical volume the specified size, select Fill all space up to (MB) and enter a size in MBs to give range for the physical volume size, or select Fill to maximum allowable size to make it grow to fill all available space on the hard disk. If you make more than one growable, they will share the available free space on the disk.
  8. Select Force to be a primary partition if you want the partition to be a primary partition.
  9. Click OK to return to the main screen.

Repeat these step to create as many physical volumes as needed for your LVM setup. For example, if you want the volume group to span over more than one drive, create a physical volume on each of the drives.

Warning: The /boot partition can not be on a volume group because the boot loader can not read it. If you want to have your root partition on a logical volume, you will need to create a separate /boot partition which is not a part of a volume group.

Once all the physical volumes are created, follow these steps:

  1. Click the LVM button to collect the physical volumes into volume groups. A volume group is basically a collection of physical volumes. You can have multiple logical volume groups, but a physical volume can only be in one volume group.

    Note: There is overhead disk space reserved in the logical volume group. The summation of the physical volumes may not equal the size of the volume group; however, the size of the logical volumes shown is correct.

  2. Change the Volume Group Name if desired.
  3. All logical volumes inside the volume group must be allocated in physical extent units. By default, the physical extent is set to 4 MB; thus, logical volume sizes must be divisible by 4 MBs. If you enter a size that is not a unit of 4 MBs, the installation program automatically selects the closest size in units of 4 MBs. It is not recommended that you change this setting.
  4. Select which physical volumes to use for the volume group.
  5. Create logical volumes with mount points such as /home. Remember that /boot can not be a logical volume. To add a logical volume, click the Add button in the Logical Volumes section. A dialog window as shown in the following figure will appear.

Repeat these steps for each volume group you want to create.

Tip: You may want to leave some free space in the logical volume group so you can expand the logicalvolumes later.

 
3)How do I configure LVM with command line?   

An overview of the steps required to configure LVM:

  • Prepare new partitions for pv.
  • Create physical volumes from the hard drives.
  • Create volume groups from the physical volumes.
  • Create logical volumes from the volume groups and assign the logical volumes mount points

3.1)Prepare new partitions for pv
   fdisk /dev/sda--->add a new partition(repeate)--->change a    partition's system id(8e:Linux LVM)

3.2)Create physical volumes from the hard drives
   pvcreate /dev/sda10 /dev/sda11  /dev/sda12

   pvscan

3.3)Create volume groups from the physical volumes
   vgcreate vg0 /dev/sda1[0-1] 

   vgdisplay

3.4)Create logical volumes from the volume groups 
   lvcreate -n data -L 100M vg0
   
   lvdispllay (ls /dev/vg0/data)

   lvscan
   
   mkfs.ext3 /dev/vg0/data

   mount /dev/vg0/data /mnt/vgdata

3.5)Extend logical volumes 
   lvextend -L +100M /dev/vg0/data (change partition)

   ext2online /dev/vg0/data 200M

3.6)Reduce logical volumes 
   ext2online /dev/vg0/data 100M
  (or resize2fs /dev/vg0/data 100M, you must umount /dev/vg0/data before you use 'resize2fs')

   lvreduce -L -100M /dev/vg0/data

3.7)Extend logical groups
   vgextend vg0 /dev/sda12

3.8)Reduce logical groups
   vgreduce vg0 /dev/sda12

二)临时解决swap满的问题
   1.在硬盘上找一个大分区,进入

   2.创建一个文件
   dd if=/dev/zero  of=swapfs bs=1M count=512

   3.格式化swapfs
     mkswap swapfs(就是上面建的文件)

   4.swapon swapfs

三)硬盘配额问题(/home单独分区)
  
1.编辑/etc/fstab中的分区对应的参数,在defaults后加“,usrquota,grpquota",然后重启机器(或者mount -o remount /home,这种方法比较实用);

   2.建立硬盘配额文件
     quotacheck -cug /home

   3.打开硬盘配额
     quotaon /home

   4.配置硬盘配额
     edquota 

  说明:soft,hard中单位为k,例如下例中,soft限制为4M,硬限制为5M.

Disk quotas for user read (uid 502):
  Filesystem   blocks       soft       hard     inodes     soft     hard
  /dev/hda7     11          4096       5120       10        0        0

阅读(1483) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~