LAB %add a new partion and set to LVM 1. create LVM (partition type: 8e) [root@server1 ~]# pvcreate /dev/sdb8 Physical volume "/dev/sdb8" successfully created [root@server1 ~]# vgcreate vg0 /dev/sdb8 Volume group "vg0" successfully created [root@server1 ~]# vgs VG #PV #LV #SN Attr VSize VFree VolGroup00 1 2 0 wz--n- 74.41G 0 vg0 1 0 0 wz--n- 96.00M 96.00M [root@server1 ~]# lvcreate -L 96M -n data vg0 Logical volume "data" created 2. extend LVM (partition type:8e) [root@server1 ~]# pvcreate /dev/sdb9 Physical volume "/dev/sdb9" successfully created [root@server1 ~]# vgextend vg0 /dev/sdb9 Volume group "vg0" successfully extended [root@server1 ~]# vgs VG #PV #LV #SN Attr VSize VFree VolGroup00 1 2 0 wz--n- 74.41G 0 vg0 2 1 0 wz--n- 192.00M 96.00M [root@server1 ~]# lvextend -L +96M /dev/vg0/data Extending logical volume data to 192.00 MB Logical volume data successfully resized #resize2fs -p /dev/vg0/data #df -h [root@server1 ~]# lvs LV VG Attr LSize Origin Snap% Move Log Copy% Convert LogVol00 VolGroup00 -wi-ao 72.47G LogVol01 VolGroup00 -wi-ao 1.94G data vg0 -wi-a- 192.00M [root@server1 ~]# mkfs.ext3 /dev/vg0/data mke2fs 1.39 (29-May-2006) Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) 49152 inodes, 196608 blocks 9830 blocks (5.00%) reserved for the super user First data block=1 Maximum filesystem blocks=67371008 24 block groups 8192 blocks per group, 8192 fragments per group 2048 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729 Writing inode tables: done Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 29 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. 3. reduce LVM (注意, 須先備份, 預防資料遺失) [root@server1 ~]# fsck -f /dev/vg0/data fsck 1.39 (29-May-2006) 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/vg0/data: 11/49152 files (9.1% non-contiguous), 11869/196608 blocks You have new mail in /var/spool/mail/root [root@server1 ~]# resize2fs /dev/vg0/data 92M resize2fs 1.39 (29-May-2006) Resizing the filesystem on /dev/vg0/data to 94208 (1k) blocks. The filesystem on /dev/vg0/data is now 94208 blocks long. [root@server1 ~]# lvreduce /dev/vg0/data -L 92M WARNING: Reducing active logical volume to 92.00 MB THIS MAY DESTROY YOUR DATA (filesystem etc.) Do you really want to reduce data? [y/n]: y Reducing logical volume data to 92.00 MB Logical volume data successfully resized [root@server1 ~]# pvmove /dev/sdb8 /dev/sdb8: Moved: 34.8% /dev/sdb8: Moved: 69.6% /dev/sdb8: Moved: 100.0% [root@server1 ~]# vgreduce vg0 /dev/sdb8 Removed "/dev/sdb8" from volume group "vg0" [root@server1 ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 VolGroup00 lvm2 a- 74.41G 0 /dev/sdb8 lvm2 -- 97.81M 97.81M /dev/sdb9 vg0 lvm2 a- 96.00M 4.00M [root@server1 ~]# vgs VG #PV #LV #SN Attr VSize VFree VolGroup00 1 2 0 wz--n- 74.41G 0 vg0 1 1 0 wz--n- 96.00M 4.00M [root@server1 ~]# lvs LV VG Attr LSize Origin Snap% Move Log Copy% Convert LogVol00 VolGroup00 -wi-ao 72.47G LogVol01 VolGroup00 -wi-ao 1.94G data vg0 -wi-a- 92.00M
文章標籤
全站熱搜
創作者介紹
創作者 aquatower 的頭像
aquatower

2006隨手札記

aquatower 發表在 痞客邦 留言(0) 人氣(246)