现在的位置: 首页 > 综合 > 正文

(2007 5月11日)Linux 下 LVM sample

2013年09月19日 ⁄ 综合 ⁄ 共 6290字 ⁄ 字号 评论关闭
 

一个入门级的sample, 有空再给相关命令注释
 
[root@rhel ~]# fdisk -l
Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        1044     8281507+  8e  Linux LVM
Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table  
[root@rhel ~]# pvcreate /dev/sdb
  Physical volume "/dev/sdb" successfully created
  
[root@rhel ~]# vgcreate VolGroup10 /dev/sdb
  Volume group "VolGroup10" successfully created
[root@rhel ~]# vgchange -a y VolGroup10
  0 logical volume(s) in volume group "VolGroup10" now active
[root@rhel ~]# vgdisplay
  --- Volume group ---
  VG Name               VolGroup10
  System ID            
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               8.00 GB
  PE Size               4.00 MB
  Total PE              2047
  Alloc PE / Size       0 / 0  
  Free  PE / Size       2047 / 8.00 GB
  VG UUID               MJN9a2-yj4j-3hES-OUsY-diUp-KShe-sXO6hs
  
  --- Volume group ---
  VG Name               VolGroup00
  System ID            
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               7.88 GB
  PE Size               32.00 MB
  Total PE              252
  Alloc PE / Size       252 / 7.88 GB
  Free  PE / Size       0 / 0  
  VG UUID               Eelu7Z-Ow8a-X6tK-xAnz-k2i0-1NTd-rvF4WZ
  
[root@rhel ~]# lvcreate -L2000 -nrdb VolGroup10
  Logical volume "rdb" created
[root@rhel ~]# mkdir /rdb
[root@rhel ~]# mkfs.ext3 /dev/VolGroup10/rdb
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
256000 inodes, 512000 blocks
25600 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=524288000
16 block groups
32768 blocks per group, 32768 fragments per group
16000 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912
Writing inode tables: done                           
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@rhel ~]# mount /dev/VolGroup10/rdb /rdb/
[root@rhel ~]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/VolGroup10/rdb
  VG Name                VolGroup10
  LV UUID                w2tneE-y48m-5MYS-rQ9j-HtJo-j0Pl-IMYLRk
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                1.95 GB
  Current LE             500
  Segments               1
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:2
  
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                A7v7MI-dWql-ejH7-xdul-uQXe-IYGY-GP0XzH
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                6.88 GB
  Current LE             220
  Segments               1
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:0
  
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol01
  VG Name                VolGroup00
  LV UUID                WGE5Ld-fTC8-b8gU-lb7e-bNEu-OMkI-wZ8Lvl
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                1.00 GB
  Current LE             32
  Segments               1
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:1
  
[root@rhel ~]# lvcreate -L2000 -noradata VolGroup10
  Logical volume "oradata" created
[root@rhel ~]# mkfs.ext3 /dev/VolGroup10/oradata
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
256000 inodes, 512000 blocks
25600 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=524288000
16 block groups
32768 blocks per group, 32768 fragments per group
16000 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912
Writing inode tables: done                           
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@rhel ~]# mkdir /oradata
[root@rhel ~]# mount /dev/VolGroup10/oradata /oradata
[root@rhel ~]# mount
/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
.host:/ on /mnt/hgfs type vmhgfs (rw,ttl=5)
none on /proc/fs/vmblock/mountPoint type vmblock (rw)
/dev/mapper/VolGroup10-rdb on /rdb type ext3 (rw)
/dev/mapper/VolGroup10-oradata on /oradata type ext3 (rw)
[root@rhel /]# vi /etc/fstab
/dev/VolGroup00/LogVol00 /                       ext3    defaults        1 1
/dev/VolGroup10/rdb /rdb                       ext3    defaults        1 1
/dev/VolGroup10/oradata /oradata                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
sysfs                   /sys                    sysfs   defaults        0 0
/dev/VolGroup00/LogVol01 swap                    swap    defaults        0 0
# Beginning of the block added by the VMware software
.host:/                 /mnt/hgfs               vmhgfs  defaults,ttl=5     0 0
# End of the block added by the VMware software  
[root@rhel /]# umount /rdb
[root@rhel /]# e2fsck -f /dev/VolGroup10/rdb
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/VolGroup10/rdb: 11/256000 files (9.1% non-contiguous), 16996/512000 blocks
[root@rhel /]# mount /dev/VolGroup10/rdb /rdb 单用户进入系统后(可能系统是只读的) 运行下面的命令:
#mount -o remount,rw /
重新修改fstab
【上篇】
【下篇】

抱歉!评论已关闭.