linux系统中对逻辑卷(lvm)的实现

1.分区并转换lvm格式

[root@localhost ~]# fdisk -cu /dev/sdbDevice contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelBuilding a new DOS disklabel with disk identifier 0xd8e8fb90.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): nCommand actione extendedp primary partition (1-4)pPartition number (1-4): 1First sector (2048-4485119, default 2048):Using default value 2048Last sector, +sectors or +size{K,M,G} (2048-4485119, default 4485119): +200MCommand (m for help): nCommand actione extendedp primary partition (1-4)pPartition number (1-4): 2First sector (411648-4485119, default 411648):Using default value 411648Last sector, +sectors or +size{K,M,G} (411648-4485119, default 4485119): +200MCommand (m for help): nCommand actione extendedp primary partition (1-4)pPartition number (1-4): 3First sector (821248-4485119, default 821248):Using default value 821248Last sector, +sectors or +size{K,M,G} (821248-4485119, default 4485119): +200MCommand (m for help): nCommand actione extendedp primary partition (1-4)pSelected partition 4First sector (1230848-4485119, default 1230848):Using default value 1230848Last sector, +sectors or +size{K,M,G} (1230848-4485119, default 4485119): +200MCommand (m for help): pDisk /dev/sdb: 2296 MB, 2296381440 bytes255 heads, 63 sectors/track, 279 cylinders, total 4485120 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0xd8e8fb90Device BootStartEndBlocks Id System/dev/sdb12048411647204800 83 Linux/dev/sdb2411648821247204800 83 Linux/dev/sdb38212481230847204800 83 Linux/dev/sdb412308481640447204800 83 LinuxCommand (m for help): tPartition number (1-4): 1Hex code (type L to list codes): L0 Empty24 NEC DOS81 Minix / old Lin bf Solaris1 FAT1239 Plan 982 Linux swap / So c1 DRDOS/sec (FAT-2 XENIX root3c PartitionMagic 83 Linuxc4 DRDOS/sec (FAT-3 XENIX usr40 Venix 8028684 OS/2 hidden C: c6 DRDOS/sec (FAT-4 FAT16 <32M41 PPC PReP Boot 85 Linux extended c7 Syrinx5 Extended42 SFS86 NTFS volume set da Non-FS data6 FAT164d QNX4.x87 NTFS volume set db CP/M / CTOS / .7 HPFS/NTFS4e QNX4.x 2nd part 88 Linux plaintext de Dell Utility8 AIX4f QNX4.x 3rd part 8e Linux LVMdf BootIt9 AIX bootable 50 OnTrack DM93 Amoebae1 DOS accessa OS/2 Boot Manag 51 OnTrack DM6 Aux 94 Amoeba BBTe3 DOS R/Ob W95 FAT3252 CP/M9f BSD/OSe4 SpeedStorc W95 FAT32 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fse W95 FAT16 (LBA) 54 OnTrackDM6a5 FreeBSDee GPTf W95 Ext’d (LBA) 55 EZ-Drivea6 OpenBSDef EFI (FAT-12/16/10 OPUS56 Golden Bowa7 NeXTSTEPf0 Linux/PA-RISC b11 Hidden FAT12 5c Priam Ediska8 Darwin UFSf1 SpeedStor12 Compaq diagnost 61 SpeedStora9 NetBSDf4 SpeedStor14 Hidden FAT16 <3 63 GNU HURD or Sys ab Darwin bootf2 DOS secondary16 Hidden FAT16 64 Novell Netware af HFS / HFS+fb VMware VMFS17 Hidden HPFS/NTF 65 Novell Netware b7 BSDI fsfc VMware VMKCORE18 AST SmartSleep 70 DiskSecure Mult b8 BSDI swapfd Linux raid auto1b Hidden W95 FAT3 75 PC/IXbb Boot Wizard hid fe LANstep1c Hidden W95 FAT3 80 Old Minixbe Solaris boot ff BBT1e Hidden W95 FAT1Hex code (type L to list codes): 8eChanged system type of partition 1 to 8e (Linux LVM)Command (m for help): tPartition number (1-4): 2Hex code (type L to list codes): 8eChanged system type of partition 2 to 8e (Linux LVM)Command (m for help): tPartition number (1-4): 3Hex code (type L to list codes): 8eChanged system type of partition 3 to 8e (Linux LVM)Command (m for help): tPartition number (1-4): 4Hex code (type L to list codes): 8eChanged system type of partition 4 to 8e (Linux LVM)Command (m for help): pDisk /dev/sdb: 2296 MB, 2296381440 bytes255 heads, 63 sectors/track, 279 cylinders, total 4485120 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0xd8e8fb90Device BootStartEndBlocks Id System/dev/sdb12048411647204800 8e Linux LVM/dev/sdb2411648821247204800 8e Linux LVM/dev/sdb38212481230847204800 8e Linux LVM/dev/sdb412308481640447204800 8e Linux LVMCommand (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.[root@localhost ~]#

2.将分区转换为pv物理卷,将pv加入到一个vg组中,从vg划出lv逻辑卷

[root@localhost ~]# pvcreate /dev/sdb{1,2,3,4}–将分区转换为物理卷Physical volume “/dev/sdb1” successfully createdPhysical volume “/dev/sdb2” successfully createdPhysical volume “/dev/sdb3” successfully createdPhysical volume “/dev/sdb4” successfully created[root@localhost ~]# pvscan –查看物理卷PV /dev/sda2 VG VolGrouplvm2 [7.51 GiB / 0 free]PV /dev/sdb1lvm2 [200.00 MiB]PV /dev/sdb2lvm2 [200.00 MiB]PV /dev/sdb3lvm2 [200.00 MiB]PV /dev/sdb4lvm2 [200.00 MiB]Total: 5 [8.29 GiB] / in use: 1 [7.51 GiB] / in no VG: 4 [800.00 MiB][root@localhost ~]# vgcreate vg0 /dev/sdb{1,2,3} –将物理卷1,2,3加入到卷组Volume group “vg0” successfully created[root@localhost ~]# vgscan–查看卷组Reading all physical volumes. This may take a while…Found volume group “vg0” using metadata type lvm2Found volume group “VolGroup” using metadata type lvm2[root@localhost ~]# lvcreate -n test -L 150M vg0–从卷组中分出pv逻辑卷Rounding up size to full physical extent 152.00 MiBLogical volume “test” created[root@localhost ~]# lvcreate -n test1 -L 150M vg0Rounding up size to full physical extent 152.00 MiBLogical volume “test1” created[root@localhost ~]# lvscanACTIVE’/dev/vg0/test’ [152.00 MiB] inheritACTIVE’/dev/vg0/test1′ [152.00 MiB] inheritACTIVE’/dev/VolGroup/lv_root’ [6.51 GiB] inheritACTIVE’/dev/VolGroup/lv_swap’ [1.00 GiB] inherit[root@localhost ~]# mkfs.ext4 /dev/vg0/test–格式化物理卷mke2fs 1.41.12 (17-May-2010)Filesystem label=OS type: LinuxBlock size=1024 (log=0)Fragment size=1024 (log=0)Stride=0 blocks, Stripe width=0 blocks38912 inodes, 155648 blocks7782 blocks (5.00%) reserved for the super userFirst data block=1Maximum filesystem blocks=6737100819 block groups8192 blocks per group, 8192 fragments per group2048 inodes per groupSuperblock backups stored on blocks:8193, 24577, 40961, 57345, 73729Writing inode tables: doneCreating journal (4096 blocks): doneWriting superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 26 mounts or180 days, whichever comes first. Use tune2fs -c or -i to override.[root@localhost ~]# mount /dev/vg0/test /mnt/sdb –挂载[root@localhost ~]# mkdir /mnt/sdb/12–可以使用了[root@localhost ~]# ll /mnt/sdb/total 14drwxr-xr-x. 2 root root 1024 Jan 9 15:24 12drwx——. 2 root root 12288 Jan 9 15:23 lost+found[root@localhost ~]#学做任何事得按部就班,急不得

linux系统中对逻辑卷(lvm)的实现

相关文章:

你感兴趣的文章:

标签云: