首页 > 系统 > 其他 >

创建含有两个物理分区的逻辑卷(操作步骤)

2014-04-14

一、安装LVM包 [root@desktop61 ] yum -y install system-config-lvm Loaded plugins: product-id, refresh-packagekit, security, subscription-manager Updating certificate-based repositorie

一、安装LVM包
[root@desktop61 /]# yum -y install system-config-lvm
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package system-config-lvm.noarch 0:1.1.12-12.el6 will be installed
--> Finished Dependency Resolution


Dependencies Resolved


================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
system-config-lvm noarch 1.1.12-12.el6 base 464 k


Transaction Summary
================================================================================
Install 1 Package(s)


Total download size: 464 k
Installed size: 3.1 M
Downloading Packages:
system-config-lvm-1.1.12-12.el6.noarch.rpm | 464 kB 00:00
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
Importing GPG key 0xFD431D51:
Userid : Red Hat, Inc. (release key 2) <security@redhat.com>
Package: redhat-release-server-6Server-6.3.0.3.el6.x86_64 (@anaconda-RedHatEnterpriseLinux-201206132210.x86_64/6.3)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
Importing GPG key 0x2FA658E0:
Userid : Red Hat, Inc. (auxiliary key) <security@redhat.com>
Package: redhat-release-server-6Server-6.3.0.3.el6.x86_64 (@anaconda-RedHatEnterpriseLinux-201206132210.x86_64/6.3)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : system-config-lvm-1.1.12-12.el6.noarch 1/1
base/productid | 1.7 kB 00:00
Installed products updated.
Verifying : system-config-lvm-1.1.12-12.el6.noarch 1/1


Installed:
system-config-lvm.noarch 0:1.1.12-12.el6


Complete!
二、删除扩展分区sdb1 sdc1
[root@desktop61 /]# fdisk -cul


Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000471ad


Device Boot Start End Blocks Id System
/dev/sda1 * 2048 526335 262144 83 Linux
/dev/sda2 526336 57870335 28672000 8e Linux LVM
/dev/sda3 57870336 58918911 524288 82 Linux swap / Solaris


Disk /dev/sdb: 21.5 GB, 21474836480 bytes
213 heads, 34 sectors/track, 5791 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x6f5e3a19


Device Boot Start End Blocks Id System
/dev/sdb1 2048 41943039 20970496 5 Extended
/dev/sdb5 4096 20975615 10485760 83 Linux
/dev/sdb6 20977664 41943039 10482688 83 Linux


Disk /dev/sdc: 21.5 GB, 21474836480 bytes
139 heads, 49 sectors/track, 6158 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x740491c5


Device Boot Start End Blocks Id System
/dev/sdc2 2048 20973567 10485760 5 Extended
/dev/sdc5 4096 10489855 5242880 83 Linux
/dev/sdc6 10491904 20973566 5240831+ 83 Linux


Disk /dev/mapper/vol0-root: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders, total 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000




Disk /dev/mapper/vol0-home: 536 MB, 536870912 bytes
255 heads, 63 sectors/track, 65 cylinders, total 1048576 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000




Disk /dev/mapper/vol0-vserver: 6442 MB, 6442450944 bytes
255 heads, 63 sectors/track, 783 cylinders, total 12582912 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0005f35c


Device Boot Start End Blocks Id System
/dev/mapper/vol0-vserverp1 * 2048 526335 262144 83 Linux
/dev/mapper/vol0-vserverp2 526336 9914367 4694016 8e Linux LVM
[root@desktop61 /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vol0-root
7.9G 2.9G 4.6G 39% /
tmpfs 1.9G 272K 1.9G 1% /dev/shm
/dev/sda1 248M 70M 166M 30% /boot
/dev/mapper/vol0-home
504M 17M 462M 4% /home
/dev/sdb5 9.9G 151M 9.2G 2% /tmp/sdb5
/dev/sdb6 9.9G 151M 9.2G 2% /tmp/sdb6
/dev/sdc5 5.0G 138M 4.6G 3% /mnt/sdc5
/dev/sdc6 5.0G 138M 4.6G 3% /mnt/sdc6

[root@desktop61 /]# fdisk -cu /dev/sdb

Command (m for help): d
Partition number (1-6): sdb1
Partition number (1-6): 1

Command (m for help): d
No partition is defined yet!


Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
213 heads, 34 sectors/track, 5791 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x6f5e3a19

Device Boot Start End Blocks Id System

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@desktop61 /]# fdisk -cul /dev/sdb

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x6f5e3a19

Device Boot Start End Blocks Id System

[root@desktop61 /]# fdisk -cul /dev/sdc

Disk /dev/sdc: 21.5 GB, 21474836480 bytes
139 heads, 49 sectors/track, 6158 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x740491c5

Device Boot Start End Blocks Id System
/dev/sdc2 2048 20973567 10485760 5 Extended
/dev/sdc5 4096 10489855 5242880 83 Linux
/dev/sdc6 10491904 20973566 5240831+ 83 Linux
[root@desktop61 /]# fdisk -cu /dev/sdc

Command (m for help): d
Partition number (1-6): 5

Command (m for help): d
Partition number (1-5): 6
Value out of range.
Partition number (1-5): 2

Command (m for help): p

Disk /dev/sdc: 21.5 GB, 21474836480 bytes
139 heads, 49 sectors/track, 6158 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x740491c5

Device Boot Start End Blocks Id System

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
三、创建物理分区

[root@desktop61 Desktop]# fdisk -cul /dev/sdb

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
213 heads, 34 sectors/track, 5791 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x6f5e3a19

Device Boot Start End Blocks Id System
/dev/sdb1 2048 41943039 20970496 83 Linux
[root@desktop61 Desktop]# fdisk -cul /dev/sdc

Disk /dev/sdc: 21.5 GB, 21474836480 bytes
213 heads, 34 sectors/track, 5791 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x740491c5

Device Boot Start End Blocks Id System
/dev/sdc1 2048 41943039 20970496 83 Linux
[root@desktop61 Desktop]#
四、指定物理分区的文件系统为逻辑卷
[root@desktop61 Desktop]# fdisk -cul /dev/sdc

Disk /dev/sdc: 21.5 GB, 21474836480 bytes
213 heads, 34 sectors/track, 5791 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x740491c5

Device Boot Start End Blocks Id System
/dev/sdc1 2048 41943039 20970496 83 Linux
[root@desktop61 Desktop]# fdisk -cu /dev/sdc

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@desktop61 Desktop]# fdisk -cu /dev/sdb

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
看一看现在所有的文件系统类型:
[root@desktop61 Desktop]# fdisk -cu /dev/sdb

Command (m for help): l

0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
1 FAT12 39 Plan 9 82 Linux swap / So c1 DRDOS/sec (FAT-
2 XENIX root 3c PartitionMagic 83 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 40 Venix 80286 84 OS/2 hidden C: c6 DRDOS/sec (FAT-
4 FAT16 <32M 41 PPC PReP Boot 85 Linux extended c7 Syrinx
5 Extended 42 SFS 86 NTFS volume set da Non-FS data
6 FAT16 4d QNX4.x 87 NTFS volume set db CP/M / CTOS / .
7 HPFS/NTFS 4e QNX4.x 2nd part 88 Linux plaintext de Dell Utility
8 AIX 4f QNX4.x 3rd part 8e Linux LVM df BootIt
9 AIX bootable 50 OnTrack DM 93 Amoeba e1 DOS access
a OS/2 Boot Manag 51 OnTrack DM6 Aux 94 Amoeba BBT e3 DOS R/O
b W95 FAT32 52 CP/M 9f BSD/OS e4 SpeedStor
c W95 FAT32 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fs
e W95 FAT16 (LBA) 54 OnTrackDM6 a5 FreeBSD ee GPT
f W95 Ext&#39;d (LBA) 55 EZ-Drive a6 OpenBSD ef EFI (FAT-12/16/
10 OPUS 56 Golden Bow a7 NeXTSTEP f0 Linux/PA-RISC b
11 Hidden FAT12 5c Priam Edisk a8 Darwin UFS f1 SpeedStor
12 Compaq diagnost 61 SpeedStor a9 NetBSD f4 SpeedStor
14 Hidden FAT16 <3 63 GNU HURD or Sys ab Darwin boot f2 DOS secondary
16 Hidden FAT16 64 Novell Netware af HFS / HFS+ fb VMware VMFS
17 Hidden HPFS/NTF 65 Novell Netware b7 BSDI fs fc VMware VMKCORE
18 AST SmartSleep 70 DiskSecure Mult b8 BSDI swap fd Linux raid auto
1b Hidden W95 FAT3 75 PC/IX bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 80 Old Minix be Solaris boot ff BBT
1e Hidden W95 FAT1

Command (m for help): q

五、创建物理卷
[root@desktop61 Desktop]# pvcreate /dev/sdb1 /dev/sdc1
Writing physical volume data to disk "/dev/sdb1"
Physical volume "/dev/sdb1" successfully created
Writing physical volume data to disk "/dev/sdc1"
Physical volume "/dev/sdc1" successfully created
[root@desktop61 Desktop]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name vol0
PV Size 27.34 GiB / not usable 32.00 MiB
Allocatable yes
PE Size 32.00 MiB
Total PE 874
Free PE 410
Allocated PE 464
PV UUID vHvm6g-JICC-V0pf-51JL-nhZt-4S6t-bj6tFT

"/dev/sdb1" is a new physical volume of "20.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdb1
VG Name
PV Size 20.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID lXoJRr-Nczo-ueRE-u1Cf-8NNj-3yrz-ghjs7O

"/dev/sdc1" is a new physical volume of "20.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdc1
VG Name
PV Size 20.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 7tes3N-bxgo-U559-1XUj-pOaD-Ag9S-zEQrpR


六、创建卷组
[root@desktop61 Desktop]# vgcreate testvg /dev/sdb1 /dev/sdc1
Volume group "testvg" successfully created
[root@desktop61 Desktop]# vgdisplay
--- Volume group ---
VG Name testvg
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 39.99 GiB
PE Size 4.00 MiB
Total PE 10238
Alloc PE / Size 0 / 0
Free PE / Size 10238 / 39.99 GiB
VG UUID rjSYSa-k5gY-hbfv-9HTs-5gAM-P1VG-ls3FJn

--- Volume group ---
VG Name vol0
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size 27.31 GiB
PE Size 32.00 MiB
Total PE 874
Alloc PE / Size 464 / 14.50 GiB
Free PE / Size 410 / 12.81 GiB
VG UUID ADouyf-IgCq-zS55-gejn-DBS8-p6Bb-VrdJOL
七、创建逻辑卷
[root@desktop61 Desktop]# lvcreate -L 20G -n test-lv1 testvg
Logical volume "test-lv1" created
[root@desktop61 Desktop]# lvdisplay
--- Logical volume ---
LV Path /dev/testvg/test-lv1
LV Name test-lv1
VG Name testvg
LV UUID f5b1oN-rIb7-GRbO-xPsp-Iwjf-5m0t-KMPu2a
LV Write Access read/write
LV Creation host, time desktop61.example.com, 2014-04-13 11:43:31 +0800
LV Status available
# open 0
LV Size 20.00 GiB
Current LE 5120
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:3

--- Logical volume ---
LV Path /dev/vol0/root
LV Name root
VG Name vol0
LV UUID C3CZi7-Cc6G-ZuPP-Fajm-NQha-MALa-uu60KW
LV Write Access read/write
LV Creation host, time desktop61.example.com, 2014-04-11 00:49:15 +0800
LV Status available
# open 1
LV Size 8.00 GiB
Current LE 256
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0

--- Logical volume ---
LV Path /dev/vol0/home
LV Name home
VG Name vol0
LV UUID EtK0Mn-V8zP-d8tS-Ea57-12a2-H4IJ-KooSTc
LV Write Access read/write
LV Creation host, time desktop61.example.com, 2014-04-11 00:49:17 +0800
LV Status available
# open 1
LV Size 512.00 MiB
Current LE 16
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1

--- Logical volume ---
LV Path /dev/vol0/vserver
LV Name vserver
VG Name vol0
LV UUID PcKVc0-ehnd-Bjao-fmER-jUS5-bPKw-4dRg5e
LV Write Access read/write
LV Creation host, time desktop61.example.com, 2014-04-10 16:55:48 +0800
LV Status available
# open 1
LV Size 6.00 GiB
Current LE 192
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
把、查询逻辑卷相关文件
[root@desktop61 Desktop]# cd /dev
[root@desktop61 dev]# ls -a testvg
. .. test-lv1
[root@desktop61 dev]# ll -a testvg
total 0
drwxr-xr-x. 2 root root 60 Apr 13 11:43 .
drwxr-xr-x. 20 root root 4080 Apr 13 11:43 ..
lrwxrwxrwx. 1 root root 7 Apr 13 11:43 test-lv1 -> ../dm-3
[root@desktop61 dev]# cd testvg/
[root@desktop61 testvg]# ll -a test-lv1
lrwxrwxrwx. 1 root root 7 Apr 13 11:43 test-lv1 -> ../dm-3
[root@desktop61 testvg]# cd ..
[root@desktop61 dev]# cd mapper/
[root@desktop61 mapper]# ll -a testvg-test--lv1
lrwxrwxrwx. 1 root root 7 Apr 13 11:43 testvg-test--lv1 -> ../dm-3
九、格式化逻辑卷
[root@desktop61 mapper]# mkfs.ext4 /dev/testvg/test-lv1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1310720 inodes, 5242880 blocks
262144 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
160 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000


Writing inode tables: done
Creating journal (32768 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.
十、手工挂载逻辑卷
[root@desktop61 mapper]# blkid /dev/testvg/test-lv1
/dev/testvg/test-lv1: UUID="dfa6e086-e5be-4856-9e8d-9565d52b82e6" TYPE="ext4"
[root@desktop61 mapper]# vim /etc/fstab
#
# /etc/fstab
# Created by anaconda on Fri Apr 11 00:49:26 2014
#
# Accessible filesystems, by reference, are maintained under &#39;/dev/disk&#39;
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/vol0-root / ext4 defaults 1 1
UUID=9353a628-e49f-4675-abf4-b0fe76b38fbc /boot ext4 defaults 1 2
/dev/mapper/vol0-home /home ext4 defaults 1 2
UUID=f3d4a81c-f2d6-48d8-be1a-35647cd74615 swap swap defaults 0 0
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
UUID=dfa6e086-e5be-4856-9e8d-9565d52b82e6 /mnt/test-lv1 ext4 defaults 0 0 ---------------------->插入并保存退出
十一、创建挂载目录
[root@desktop61 mapper]# cd /mnt/
[root@desktop61 mnt]# mkdir test-lv1
[root@desktop61 mnt]# mount -a
[root@desktop61 mnt]# mount
/dev/mapper/vol0-root on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
/dev/mapper/vol0-home on /home type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
gvfs-fuse-daemon on /root/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev)
/dev/mapper/testvg-test--lv1 on /mnt/test-lv1 type ext4 (rw)
[root@desktop61 mnt]#
相关文章
最新文章
热点推荐