Linux LVM扩展-练习

查看物理硬盘大小:

[root@jkdb-2 ~]# fdisk -l

Disk /dev/sda: 17.1 GB, 17179869184 bytes

255 heads, 63 sectors/track, 2088 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 2088 16667437+ 8e Linux LVM

Disk /dev/sdb: 644.2 GB, 644245094400 bytes

255 heads, 63 sectors/track, 78325 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot Start End Blocks Id System

格式化、分区:

[root@jkdb-2 ~]# fdisk /dev/sdb

The number of cylinders for this disk is set to 78325.

There is nothing wrong with that, but this is larger than 1024,

and could in certain setups cause problems with:

1) software that runs at boot time (e.g., old versions of LILO)

2) booting and partitioning software from other OSs

   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/sdb: 644.2 GB, 644245094400 bytes

255 heads, 63 sectors/track, 78325 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot Start End Blocks Id System

Command (m for help): n

Command action

   e extended

   p primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-78325, default 1): 

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-78325, default 78325): 

Using default value 78325

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

p[root@jkdb-2 ~]# pvdisplay

  /dev/hdc: open failed: No medium found

  --- Physical volume ---

  PV Name /dev/sda2

  VG Name VolGroup00

  PV Size 15.90 GB / not usable 20.79 MB

  Allocatable yes (but full)

  PE Size (KByte) 32768

  Total PE 508

  Free PE 0

  Allocated PE 508

  PV UUID aOMkD6-nEO9-jVU6-kXEJ-Ba4E-7feS-afGKdb

[root@jkdb-2 ~]# fdisk -l

Disk /dev/sda: 17.1 GB, 17179869184 bytes

255 heads, 63 sectors/track, 2088 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 2088 16667437+ 8e Linux LVM

 

Disk /dev/sdb: 644.2 GB, 644245094400 bytes

255 heads, 63 sectors/track, 78325 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot Start End Blocks Id System

/dev/sdb1 1 78325 629145531 83 Linux

创建pv

[root@jkdb-2 ~]# pvcreate /dev/sdb1

  Wiping swap signature on /dev/sdb1

  Physical volume "/dev/sdb1" successfully created

[root@jkdb-2 ~]# vgdisplay

  /dev/hdc: open failed: No medium found

  --- 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 15.88 GB

  PE Size 32.00 MB

  Total PE 508

  Alloc PE / Size 508 / 15.88 GB

  Free PE / Size 0 / 0  

  VG UUID QTrzPX-64oJ-m88I-ar9d-huWM-FpZI-ViFhQQ

创建vg:

vgcreate VolGroup00 /dev/sdb1

扩展vg

[root@jkdb-2 ~]# vgextend VolGroup00 /dev/sdb1

  /dev/hdc: open failed: No medium found

  Volume group "VolGroup00" successfully extended

[root@jkdb-2 ~]# vgdisplay

  --- Volume group ---

  VG Name VolGroup00

  System ID            

  Format lvm2

  Metadata Areas 2

  Metadata Sequence No 4

  VG Access read/write

  VG Status resizable

  MAX LV 0

  Cur LV 2

  Open LV 2

  Max PV 0

  Cur PV 2

  Act PV 2

  VG Size 615.84 GB

  PE Size 32.00 MB

  Total PE 19707

  Alloc PE / Size 508 / 15.88 GB

  Free PE / Size 19199 / 599.97 GB

  VG UUID QTrzPX-64oJ-m88I-ar9d-huWM-FpZI-ViFhQQ

 

[root@jkdb-2 ~]# lvdisplay

  --- Logical volume ---

  LV Name /dev/VolGroup00/LogVol00

  VG Name VolGroup00

  LV UUID diT4lz-1Exi-1NPR-c94t-0xAy-2ZqS-JBXF3E

  LV Write Access read/write

  LV Status available

  # open 1

  LV Size 13.91 GB

  Current LE 445

  Segments 1

  Allocation inherit

  Read ahead sectors auto

  - currently set to 256

  Block device 253:0

 

  --- Logical volume ---

  LV Name /dev/VolGroup00/LogVol01

  VG Name VolGroup00

  LV UUID DPxe5D-QDYj-kc33-WtQl-0ur3-7UU0-ESzobT

  LV Write Access read/write

  LV Status available

  # open 1

  LV Size 1.97 GB

  Current LE 63

  Segments 1

  Allocation inherit

  Read ahead sectors auto

  - currently set to 256

  Block device 253:1

扩展swap

[root@jkdb-2 ~]# swapon -s

Filename Type Size Used Priority

/dev/mapper/VolGroup00-LogVol01 partition 2064376 0 -1

[root@jkdb-2 ~]# lvextend -L+50G /dev/mapper/VolGroup00-LogVol01 

  Extending logical volume LogVol01 to 51.97 GB

  Logical volume LogVol01 successfully resized

 

[root@jkdb-2 ~]# swapoff /dev/mapper/VolGroup00-LogVol01

[root@jkdb-2 ~]# mkswap /dev/mapper/VolGroup00-LogVol01

Setting up swapspace version 1, size = 55801016 kB

[root@jkdb-2 ~]# swapon /dev/mapper/VolGroup00-LogVol01

[root@jkdb-2 ~]# swapon -s

Filename Type Size Used Priority

/dev/mapper/VolGroup00-LogVol01 partition 54493176 0 -3

[root@jkdb-2 ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/VolGroup00-LogVol00

                       14G 3.6G 9.3G 28% /

/dev/sda1 99M 13M 82M 14% /boot

tmpfs 16G 0 16G 0% /dev/shm

创建lv

 lvcreate -L 500G -n VolGroup00-LogVol00 VolGroup00

扩展lv

[root@jkdb-2 ~]# lvextend -L+17G /dev/mapper/VolGroup00-LogVol00

  Extending logical volume LogVol00 to 30.91 GB

  Logical volume LogVol00 successfully resized

[root@jkdb-2 ~]# resize2fs /dev/mapper/VolGroup00-LogVol00

resize2fs 1.39 (29-May-2006)

Filesystem at /dev/mapper/VolGroup00-LogVol00 is mounted on /; on-line resizing required

Performing an on-line resize of /dev/mapper/VolGroup00-LogVol00 to 8101888 (4k) blocks.

The filesystem on /dev/mapper/VolGroup00-LogVol00 is now 8101888 blocks long.

 

[root@jkdb-2 ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/VolGroup00-LogVol00

                       30G 3.6G 25G 13% /

/dev/sda1 99M 13M 82M 14% /boot

tmpfs 16G 0 16G 0% /dev/shm

[root@jkdb-2 ~]# fdisk -l

 

Disk /dev/sda: 17.1 GB, 17179869184 bytes

255 heads, 63 sectors/track, 2088 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 2088 16667437+ 8e Linux LVM

 

Disk /dev/sdb: 644.2 GB, 644245094400 bytes

255 heads, 63 sectors/track, 78325 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot Start End Blocks Id System

/dev/sdb1 1 78325 629145531 83 Linux

[root@jkdb-2 ~]# vgdisplay

  --- Volume group ---

  VG Name VolGroup00

  System ID            

  Format lvm2

  Metadata Areas 2

  Metadata Sequence No 6

  VG Access read/write

  VG Status resizable

  MAX LV 0

  Cur LV 2

  Open LV 2

  Max PV 0

  Cur PV 2

  Act PV 2

  VG Size 615.84 GB

  PE Size 32.00 MB

  Total PE 19707

  Alloc PE / Size 2652 / 82.88 GB

  Free PE / Size 17055 / 532.97 GB

  VG UUID QTrzPX-64oJ-m88I-ar9d-huWM-FpZI-ViFhQQ

 

[root@jkdb-2 ~]# lvdisplay

  --- Logical volume ---

  LV Name /dev/VolGroup00/LogVol00

  VG Name VolGroup00

  LV UUID diT4lz-1Exi-1NPR-c94t-0xAy-2ZqS-JBXF3E

  LV Write Access read/write

  LV Status available

  # open 1

  LV Size 30.91 GB

  Current LE 989

  Segments 2

  Allocation inherit

  Read ahead sectors auto

  - currently set to 256

  Block device 253:0

 

  --- Logical volume ---

  LV Name /dev/VolGroup00/LogVol01

  VG Name VolGroup00

  LV UUID DPxe5D-QDYj-kc33-WtQl-0ur3-7UU0-ESzobT

  LV Write Access read/write

  LV Status available

  # open 1

  LV Size 51.97 GB

  Current LE 1663

  Segments 2

  Allocation inherit

  Read ahead sectors auto

  - currently set to 256

  Block device 253:1

创建lv

[root@jkdb-2 ~]# lvcreate -n lv1_opt -L 450G VolGroup00

  Logical volume "lv1_opt" created

[root@jkdb-2 ~]# lvdisplay

  --- Logical volume ---

  LV Name /dev/VolGroup00/LogVol00

  VG Name VolGroup00

  LV UUID diT4lz-1Exi-1NPR-c94t-0xAy-2ZqS-JBXF3E

  LV Write Access read/write

  LV Status available

  # open 1

  LV Size 30.91 GB

  Current LE 989

  Segments 2

  Allocation inherit

  Read ahead sectors auto

  - currently set to 256

  Block device 253:0

 

  --- Logical volume ---

  LV Name /dev/VolGroup00/LogVol01

  VG Name VolGroup00

  LV UUID DPxe5D-QDYj-kc33-WtQl-0ur3-7UU0-ESzobT

  LV Write Access read/write

  LV Status available

  # open 1

  LV Size 51.97 GB

  Current LE 1663

  Segments 2

  Allocation inherit

  Read ahead sectors auto

  - currently set to 256

  Block device 253:1

 

  --- Logical volume ---

  LV Name /dev/VolGroup00/lv1_opt

  VG Name VolGroup00

  LV UUID RM8RhC-E7r6-NhQM-6rZm-jqsS-EQ51-bLPH4i

  LV Write Access read/write

  LV Status available

  # open 0

  LV Size 450.00 GB

  Current LE 14400

  Segments 1

  Allocation inherit

  Read ahead sectors auto

  - currently set to 256

  Block device 253:2

建文件系统:

[root@jkdb-2 ~]# mkfs.ext3 /dev/VolGroup00/lv1_opt

mke2fs 1.39 (29-May-2006)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

58982400 inodes, 117964800 blocks

5898240 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=4294967296

3600 block groups

32768 blocks per group, 32768 fragments per group

16384 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

 

Writing inode tables: done                           

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: 

done

 

This filesystem will be automatically checked every 38 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

修改开机挂在点:

[root@jkdb-2 ~]# vi /etc/fstab

 

/dev/VolGroup00/LogVol00 / ext3 defaults 1 1

LABEL=/boot /boot ext3 defaults 1 2

tmpfs /dev/shm tmpfs defaults 0 0

devpts /dev/pts devpts gid=5,mode=620 0 0

sysfs /sys sysfs defaults 0 0

proc /proc proc defaults 0 0

/dev/VolGroup00/LogVol01 swap swap defaults 0 0

/dev/VolGroup00/lv1_opt /opt ext3 defaults 0 0

~

~

~

~

"/etc/fstab" 8L, 611C written

[root@jkdb-2 ~]# mount -a

[root@jkdb-2 ~]# 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)

sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

/dev/mapper/VolGroup00-lv1_opt on /opt type ext3 (rw)

[root@jkdb-2 ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/VolGroup00-LogVol00

                       30G 3.6G 25G 13% /

/dev/sda1 99M 13M 82M 14% /boot

tmpfs 16G 0 16G 0% /dev/shm

/dev/mapper/VolGroup00-lv1_opt

                      443G 199M 421G 1% /opt

[root@jkdb-2 ~]# swapon -s

Filename Type Size Used Priority

/dev/mapper/VolGroup00-LogVol01 partition 54493176 0 -3

[root@jkdb-2 ~]# reboot

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值