Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

LVM logical Volume Management under Linux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Partition [root@db01 ~] # fdisk-l

Disk / dev/sda: 10.7 GB, 10737418240 bytes

255 heads, 63 sectors/track, 1305 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 1305 10377990 8e Linux LVM

Disk / dev/sdb: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk / dev/sdb doesn't contain a valid partition table

[root@db01 ~] #

[root@db01 ~] # fdisk / dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel. Changes will remain in memory only

Until you decide to write them. After that, of course, the previous

Content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w (rite)

Command (m for help): M

Command action

A toggle a bootable flag

B edit bsd disklabel

C toggle the dos compatibility flag

D delete a partition

L list known partition types

M print this menu

N add a new partition

O create a new empty DOS partition table

P print the partition table

Q quit without saving changes

S create a new empty Sun disklabel

T change a partition's system id

U change display/entry units

V verify the partition table

W write table to disk and exit

X extra functionality (experts only)

Command (m for help): n

Command action

E extended

P primary partition (1-4)

P

Partition number (1-4): 1

First cylinder (1,652, default 1):

Using default value 1

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

Using default value 652

Command (m for help): W

The partition table has been altered!

Calling ioctl () to re-read partition table.

Syncing disks.

[root@db01 ~] #

[root@db01 ~] # fdisk-l

Disk / dev/sda: 10.7 GB, 10737418240 bytes

255 heads, 63 sectors/track, 1305 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 1305 10377990 8e Linux LVM

Disk / dev/sdb: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/ dev/sdb1 1 652 5237158 + 83 Linux

[root@db01 ~] #

[root@db01 ~] #

[root@db01 ~] # pvcreate / dev/sdb1

Physical volume "/ dev/sdb1" successfully created

[root@db01 ~] #

[root@db01 ~] # vgcreate testvg / dev/sdb1

/ dev/hdc: open failed: No medium found

Volume group "testvg" successfully created

[root@db01 ~] #

[root@db01 ~] # vgdisplay

-Volume group

VG Name testvg

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

PE Size 4.00 MB

Total PE 1278

Alloc PE / Size 0 / 0

Free PE / Size 1278 / 4.99 GB

VG UUID SMGvyj-hKdO-ILqF-Z9y3-1qPb-WHyQ-K7zN5d

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

PE Size 32.00 MB

Total PE 316

Alloc PE / Size 316 / 9.88 GB

Free PE / Size 0 / 0

VG UUID wH67cF-9Z6s-YEXC-yf0U-q0ep-NK0g-7gC25V

[root@db01 ~] #

[root@db01] # lvcreate-L100-n lv_test01 testvg

Logical volume "lv_test01" created

[root@db01 ~] #

[root@db01] # df-h

Filesystem Size Used Avail Use% Mounted on

/ dev/mapper/VolGroup00-LogVol00

7.7G 4.3G 3.0G 60% /

/ dev/sda1 99m 12m 82m 13% / boot

Tmpfs 506m 0506m 0% / dev/shm

Create a new lv

Create pv

Pvcreate / dev/sdb1

Create vg

Vgcreate testvg / dev/sdb1

Create a lv in M

Lvcreate-L100-n lv_test01 testvg

Or specify the number of pe

Lvcreate-l45230 testvg-n lv_test01

Extended lv

Add sdc2 extensions to testvg

Vgextend testvg / dev/sdc2

Extend lv_test01 to 12G

Lvextend-L12G / dev/testvg/lv_test01

Increase lv_test01 by 1G

Lvextend-L + 1G / dev/testvg/lv_test01

File system

Create a file system in ext3 format

Mkfs.ext3 / dev/testvg/lv_test01

Or

Mkfs-t ext3 / dev/testvg/lv_test01

Mount to / mount_test

Mount / dev/testvg/lv_test01 / mount_test

After extending lv, you need to resize the file system (facing ext2, ext3, ext4, etc.)

Df-h-T view file system format

E2fsck-f / dev/testvg/lv_test01-- can not be executed

Resize2fs-p / dev/testvg/lv_test01

If the file system format is reiserfs

Resize_reiserfs-f / dev/testvg/lv_test01

Delete

Delete the pv,pvdisplay in testvg to confirm that pv is in use

Vgreduce testvg / dev/hda1

Delete lv

Umount / dev/testvg/lv_test01

Lvremove / dev/testvg/lv_test01

Activate vg

Deactivate vg

Vgchange-an / dev/vg001

Activate vg

Vgchange-ay vg001

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report