Use LVM partitioning

Source: Internet
Author: User
Practice: perform LVM partitioning thanks to the lvm documentation provided by nntp. Based on this document, I made an lvm partition in my own book, combine two partitions that are far away into one partition for xen-based virtual machines. Environment: rhel5clientfdisk-l command output: Disk/dev/sda: 120.0 GB, 201734123776bytes255heads, 63 s

Practice: perform LVM partitioning

Thanks to the lvm documentation provided by nntp. Based on this document, I made an lvm partition in my own book and combined two very distant partitions into one, usedXen.

Environment: rhel5 client

Fdisk-l command output:

Disk/dev/sda: 120.0 GB, 120034123776 bytes

255 heads, 63 sectors/track, 14593 cylinders

Units = cylinders of 16065*512 = 8225280 bytes

Device Boot Start End Blocks Id System

/Dev/sda1*1 2330 18715693 + 7 HPFS/NTFS

/Dev/sda2 3826 14593 86493960 f W95 Ext 'd (LBA)

/Dev/sda3 2331 3825 12008587 + 83 Linux

/Dev/sda5 3826 9179 43005973 + 7 HPFS/NTFS

/Dev/sda6 9180 9192 104391 83 Linux

/Dev/sda7 9193 10497 10482381 83 Linux

/Dev/sda8 10498 10752 2048256 82 Linux swap/Solaris

/Dev/sda9 10753 10765 104391 83 Linux

/Dev/sda10 10766 11982 9775521 83 Linux

/Dev/sda11 11983 14593 20972826 83 Linux

Partition table entries are not in disk order

Specifically,/dev/sda3 is separated by a partition magician from/dev/sda1 (windows xp c drive, which was originally allocated too much.

Now we need to make/dev/sda3 and/dev/sda11 into a logic volume.

1. create physical volume on the two partitions respectively:

# Pvcreate/dev/sda3/dev/sda11

Physical volume "/dev/sda3" successfully created

Physical volume "/dev/sda11" successfully created

Pvscan command output:

PV/dev/sda3 lvm2 [11.45 GB]

PV/dev/sda11 lvm2 [20.00 GB]

Total: 2 [31.45 GB]/in use: 0 [0]/in no VG: 2 [31.45 GB]

2. use the vgcreate command to create a volume group. this volume group combines the two physical volume:

# Vgcreate xen-volume/dev/sda3/dev/sda11

Volume group "xen-volume" successfully created

Let's look at the output of the pvscan command, which is different from the previous one:

PV/dev/sda3 VG xen-volume lvm2 [11.45 GB/11.45 GB free]

PV/dev/sda11 VG xen-volume lvm2 [20.00 GB/20.00 GB free]

Total: 2 [31.45 GB]/in use: 2 [31.45 GB]/in no VG: 0 [0]

Let's take a look at the output of the vgdisplay command:

# Vgdisplay-v xen-volume

Using volume group (s) on command line

Finding volume group "xen-volume"

--- Volume group ---

VG Name xen-volume

System ID

Format lvm2

Metadata Areas 2

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 2

Act PV 2

VG Size 31.45 GB

PE Size 4.00 MB

Total PE 8051

(Note: the default Size of the PE is 4 M. This VG has a total of 8051 PES, and the total Size is the value of the VG Size of 31.45 GB)

Alloc PE/Size 0/0

Free PE/Size 8051/31 .45 GB

Vg uuid DTRys2-7H4v-0cej-CSai-08PK-munx-fCNp7N

--- Physical volumes ---

PV Name/dev/sda3

Pv uuid 0y5f7n-nk3b-er1_pktr-erqp-52uq-npf5ns

PV Status allocatable

Total PE/Free PE 2931/2931

PV Name/dev/sda11

Pv uuid 0khn2p-QALW-N7c3-Xb60-uEXg-0QZ5-iyfHdu

PV Status allocatable

Total PE/Free PE 5120/5120

3. create a logic volume with a capacity of 31 GB and named "xen-lv" on the volume group created above:

# Lvcreate-L 31G-n xen-lv xen-volume

Logical volume "xen-lv" created

View the device node of Logic volume. the naming rule of this device node is volume group + logic volume:

# Ls-al/dev/mapper/

Total 0

Drwxr-xr-x 2 root 80 10-05 14:14.

Drwxr-xr-x 14 root 3940 10-05 ..

Crw ------- 1 root 10, 62 10-05 control

Brw-rw ---- 1 root disk 253, 0 10-05 xen -- volume-xen -- lv

In addition, there is a directory named volume group under the/dev directory, which contains a directory named logic

Volume is the soft link file named. This File points to the device node under/dev/mapper.

# Ls-al/dev/xen-volume/

Total 0

Drwx ------ 2 root 60 10-05.

Drwxr-xr-x 14 root 3940 10-05 ..

Lrwxrwxrwx 1 root 31 10-05 14:14 xen-lv->

/Dev/mapper/xen -- volume-xen -- lv

View the attributes of Logic volume:

# Lvdisplay/dev/xen-volume/xen-lv

--- Logical volume ---

LV Name/dev/xen-volume/xen-lv

VG Name xen-volume

Lvuuid mzd2qO-53e6-WHw2-B37n-hqjK-zYha-O3rViE

LV Write Access read/write

LV Status available

# Open 0

LV Size 31.00 GB

Current LE 7936

Segments 2

Allocation inherit

Read ahead sectors 0

Block device 253: 0

4. create a system on logic volume:

# Mkfs. ext3/dev/xen-volume/xen-lv

Mke2fs 1.39 (29-may-2006)

Filesystem label =

OS type: Linux

Block size = 4096 (log = 2)

Fragment size = 4096 (log = 2)

4063232 inodes, 8126464 blocks

406323 blocks (5.00%) reserved for the super user

First data block = 0

Maximum filesystem blocks = 0

248 block groups

32768 blocks per group, 32768 fragments per group

16384 inodes per group

Superblock backups stored on blocks:

32768,983 04, 163840,229 376, 294912,819 200, 884736,160 5632,

2654208,

4096000,796 2624

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.

5. load logic volume to the directory:
# Mount/dev/xen-volume/xen-lv/xen/

View results:

# Df

File System 1 K-block used available % mount point

/Dev/sda7 10153988 8359088 1270784 87%/

/Dev/sda6 101086 15521 80346 17%/boot

Tmpfs 466256 0 466256 0%/dev/shm

/Dev/sda1 18715692 14723668 3992024 79%/windows/c

/Dev/sda5 43005972 42618084 387888 100%/windows/d

/Dev/mapper/xen -- volume-xen -- lv

31995824 180288 30190244 1%/xen

6. add a line to the/etc/fstab file to enable logic volume to automatically load:
/Dev/xen-volume/xen-lv/xen ext3 defaults

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.