Contenu connexe
Similaire à Linux lv ms step by step (20)
Linux lv ms step by step
- 1. LVMs STEP BY STEP
[root@localhost ~]# fdisk /dev/sda
WARNING:DOS-compatible mode isdeprecated.It'sstronglyrecommendedto
switchoff the mode (command'c') andchange displayunitsto
sectors(command'u').
Command (m for help):n
Firstcylinder(1633-2610, default1633):
Usingdefaultvalue 1633
Last cylinder,+cylindersor+size{K,M,G} (1633-2610, default2610): +50M
Command (m for help):w
The partitiontable hasbeenaltered!
Callingioctl() tore-readpartitiontable.
WARNING:Re-readingthe partitiontable failedwitherror16: Device orresource busy.
The kernel still usesthe oldtable.The new table will be usedat
the nextrebootor afteryourun partprobe(8) orkpartx(8)
Syncingdisks.
[root@localhost ~]# fdisk /dev/sda
WARNING:DOS-compatible mode isdeprecated.It'sstronglyrecommendedto
switchoff the mode (command'c') andchange displayunitsto
sectors(command'u').
Command(mfor help):p
Disk/dev/sda:21.5 GB, 21474836480 bytes
255 heads,63 sectors/track,2610 cylinders
Units= cylindersof 16065 * 512 = 8225280 bytes
Sectorsize (logical/physical):512 bytes/ 512 bytes
- 2. I/Osize (minimum/optimal):512 bytes/512 bytes
Diskidentifier:0x00043f93
Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition1 doesnotendon cylinderboundary.
/dev/sda2 26 1301 10240000 83 Linux
/dev/sda3 1301 1562 2097152 82 Linux swap/ Solaris
/dev/sda4 1562 2610 8421849 5 Extended
/dev/sda5 1562 1626 517837+ 83 Linux
/dev/sda6 1627 1632 48163+ 83 Linux
/dev/sda7 1633 1639 56196 83 Linux
Command(mfor help):t
Partitionnumber(1-7):7
Hex code (type L to listcodes):L (Listof Hex codes)
0 Empty 24 NECDOS 81 Minix / oldLin bf Solaris
1 FAT12 39 Plan9 82 Linux swap/ Soc1 DRDOS/sec(FAT-
2 XENIXroot 3c PartitionMagic 83 Linux c4 DRDOS/sec(FAT-
3 XENIXusr 40 Venix 80286 84 OS/2 hiddenC: c6 DRDOS/sec(FAT-
4 FAT16 <32M 41 PPCPRePBoot 85 Linux extended c7 Syrinx
5 Extended 42 SFS 86 NTFS volume setda Non-FSdata
6 FAT16 4d QNX4.x 87 NTFSvolume setdb CP/M/ CTOS/ .
7 HPFS/NTFS 4e QNX4.x 2nd part 88 Linux plaintextde Dell Utility
8 AIX 4f QNX4.x 3rd part 8e LinuxLVM df BootIt
9 AIX bootable 50 OnTrack DM 93 Amoeba e1 DOS access
a OS/2 Boot Manag 51 OnTrack DM6 Aux 94 AmoebaBBT e3 DOS R/O
- 3. b W95 FAT32 52 CP/M 9f BSD/OS e4 SpeedStor
c W95 FAT32 (LBA) 53 OnTrack DM6 Aux a0 IBMThinkpadhi eb BeOSfs
e W95 FAT16 (LBA) 54 OnTrackDM6 a5 FreeBSD ee GPT
f W95 Ext'd(LBA) 55 EZ-Drive a6 OpenBSD ef EFI (FAT-12/16/
10 OPUS 56 GoldenBow a7 NeXTSTEP f0 Linux/PA-RISCb
11 HiddenFAT12 5c PriamEdisk a8 DarwinUFS f1 SpeedStor
12 Compaqdiagnost61 SpeedStor a9 NetBSD f4 SpeedStor
14 HiddenFAT16<3 63 GNU HURD or Sys ab Darwinboot f2 DOSsecondary
16 HiddenFAT16 64 Novell Netware af HFS/ HFS+ fb VMware VMFS
17 HiddenHPFS/NTF65 Novell Netware b7 BSDI fs fc VMware VMKCORE
18 ASTSmartSleep 70 DiskSecure Multb8 BSDI swap fd Linux raidauto
1b HiddenW95 FAT3 75 PC/IX bb Boot Wizardhidfe LANstep
1c HiddenW95 FAT3 80 Old Minix be Solarisboot ff BBT
1e HiddenW95 FAT1
Hex code (type L to list codes):8e
Changedsystemtype of partition7to 8e (Linux LVM)
Command(mfor help):w
The partitiontable hasbeenaltered!
Callingioctl() tore-readpartitiontable.
WARNING:Re-readingthe partitiontable failedwitherror16: Device orresource busy.
The kernel still usesthe oldtable.The new table will be usedat
the nextrebootor afteryourun partprobe(8) orkpartx(8)
Syncingdisks.
[root@localhost ~]# partx -a /dev/sda
BLKPG: Device orresource busy
- 4. error addingpartition1
BLKPG: Device orresource busy
error addingpartition2
BLKPG: Device orresource busy
error addingpartition3
BLKPG: Device orresource busy
error addingpartition4
BLKPG: Device orresource busy
error addingpartition5
BLKPG: Device orresource busy
error addingpartition6
BLKPG: Device orresource busy
error addingpartition7
[root@localhost ~]# cat /proc/partitions
majorminor #blocks name
8 0 20971520 sda
8 1 204800 sda1
8 2 10240000 sda2
8 3 2097152 sda3
8 4 1 sda4
8 5 517837 sda5
8 6 48163 sda6
8 7 56196 sda7
[root@localhost ~]# pvcreate /dev/sda7
Physical volume"/dev/sda7"successfullycreated
- 5. [root@localhost ~]# vgcreate /dev/sda7
Please enteraphysical volume path
Run`vgcreate --help'formore information.
[root@localhost ~]# vgcreate /dev/sda
Please enteraphysical volume path
Run`vgcreate --help'formore information.
[root@localhost ~]# vgcreate Aoc /dev/sda
Device /dev/sdanotfound(orignoredbyfiltering).
Unable toadd physical volume '/dev/sda'tovolume group'Aoc'.
[root@localhost ~]# vgcreate aoc /dev/sda
Device /dev/sdanotfound(orignoredbyfiltering).
Unable toadd physical volume '/dev/sda'tovolume group'aoc'.
[root@localhost ~]# vgcreate vg1 /dev/sda
Device /dev/sdanotfound(orignoredbyfiltering).
Unable toadd physical volume '/dev/sda'tovolume group'vg1'.
[root@localhost ~]# vgdisplay
Novolume groupsfound
[root@localhost ~]# vgcreate aoc /dev/sda7
Volume group"aoc"successfullycreated
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name aoc
SystemID
Format lvm2
MetadataAreas 1
- 6. MetadataSequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
OpenLV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 52.00 MiB
PE Size 4.00 MiB
Total PE 13
AllocPE/ Size 0 / 0
Free PE / Size 13 / 52.00 MiB
VG UUID WiiSuj-VtRD-3zES-YFse-yLwN-3YS9-vnCB2k
[root@localhost ~]# blkid/dev/sda7
/dev/sda7:UUID="3h4r7d-1JO1-kmi5-RWwW-0hJ8-cNQw-oe7BS4"TYPE="LVM2_member"
[root@localhost ~]# lvcreate -L 25M -nAoc1 aoc
Roundingupsize tofull physical extent28.00 MiB
Logical volume "Aoc1"created
[root@localhost ~]# lvs
LV VG Attr LSize OriginSnap% Move Log Copy% Convert
Aoc1 aoc -wi-a- 28.00m
[root@localhost ~]# mkfs.ext4 /dev/aoc/Aoc1
mke2fs1.41.12 (17-May-2010)
- 7. Filesystemlabel=
OS type:Linux
Blocksize=1024 (log=0)
Fragmentsize=1024 (log=0)
Stride=0blocks,Stripe width=0blocks
7168 inodes,28672 blocks
1433 blocks(5.00%) reservedforthe superuser
Firstdata block=1
Maximumfilesystemblocks=29360128
4 blockgroups
8192 blockspergroup,8192 fragmentspergroup
1792 inodespergroup
Superblockbackupsstoredonblocks:
8193, 24577
Writinginode tables:done
Creatingjournal (1024 blocks):done
Writingsuperblocksandfilesystemaccountinginformation:done
Thisfilesystemwill be automaticallycheckedevery25 mountsor
180 days,whichevercomesfirst. Use tune2fs -cor -i to override.
[root@localhost ~]# lvs
LV VG Attr LSize OriginSnap% Move Log Copy% Convert
Aoc1 aoc -wi-a- 28.00m
[root@localhost ~]# df -hT
Filesystem Type Size Used Avail Use% Mountedon
/dev/sda2 ext4 9.7G 2.3G 6.9G 25% /
- 8. tmpfs tmpfs 504M 260K 504M 1% /dev/shm
/dev/sda1 ext4 194M 24M 161M 13% /boot
/dev/sda5 ext4 490M 11M 455M 3% /usr/olx
/dev/sr0 iso9660 2.8G 2.8G 0 100% /media/RHEL_6.0i386 Disc 1
[root@localhost ~]# df -h
Filesystem Size UsedAvail Use%Mountedon
/dev/sda2 9.7G 2.3G 6.9G 25% /
tmpfs 504M 260K 504M 1% /dev/shm
/dev/sda1 194M 24M 161M 13% /boot
/dev/sda5 490M 11M 455M 3% /usr/olx
/dev/sr0 2.8G 2.8G 0 100% /media/RHEL_6.0 i386 Disc1
[root@localhost ~]# fdisk -l
Disk/dev/sda:21.5 GB, 21474836480 bytes
255 heads,63 sectors/track,2610 cylinders
Units= cylindersof 16065 * 512 = 8225280 bytes
Sectorsize (logical/physical):512 bytes/ 512 bytes
I/Osize (minimum/optimal):512 bytes/512 bytes
Diskidentifier:0x00043f93
Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition1 doesnotendon cylinderboundary.
/dev/sda2 26 1301 10240000 83 Linux
/dev/sda3 1301 1562 2097152 82 Linux swap/ Solaris
/dev/sda4 1562 2610 8421849 5 Extended
/dev/sda5 1562 1626 517837+ 83 Linux
- 9. /dev/sda6 1627 1632 48163+ 83 Linux
/dev/sda7 1633 1639 56196 8e Linux LVM
Disk/dev/dm-0:29 MB, 29360128 bytes
255 heads,63 sectors/track,3 cylinders
Units= cylindersof 16065 * 512 = 8225280 bytes
Sectorsize (logical/physical):512 bytes/ 512 bytes
I/Osize (minimum/optimal):512 bytes/512 bytes
Diskidentifier:0x00000000
Disk/dev/dm-0doesn'tcontainavalidpartitiontable
[root@localhost ~]# mkdir AOC
[root@localhost ~]# mount /dev/aoc/Aoc1 AOC
[root@localhost ~]# df -h
Filesystem Size UsedAvail Use%Mountedon
/dev/sda2 9.7G 2.3G 6.9G 25% /
tmpfs 504M 260K 504M 1% /dev/shm
/dev/sda1 194M 24M 161M 13% /boot
/dev/sda5 490M 11M 455M 3% /usr/olx
/dev/sr0 2.8G 2.8G 0 100% /media/RHEL_6.0 i386 Disc1
/dev/mapper/aoc-Aoc1 28M 1.4M 25M 6% /root/AOC
[root@localhost ~]# lvs
LV VG Attr LSize OriginSnap% Move Log Copy% Convert
Aoc1 aoc -wi-ao28.00m
[root@localhost ~]# lvextend -L10M /dev/aoc/Aoc1
Roundingupsize tofull physical extent12.00 MiB
Newsize given(3extents) notlargerthanexistingsize (7extents)
- 10. Run`lvextend --help'formore information.
[root@localhost ~]# lvextend -L5M /dev/aoc/Aoc1
Roundingupsize tofull physical extent8.00MiB
Newsize given(2extents) notlargerthanexistingsize (7extents)
Run`lvextend --help'formore information.
[root@localhost ~]# lvextend -L2M /dev/aoc/Aoc1
Roundingupsize tofull physical extent4.00MiB
Newsize given(1extents) notlargerthanexistingsize (7extents)
Run`lvextend --help'formore information.
[root@localhost~]# lvextend -L15M /dev/aoc/Aoc1
Roundingupsize tofull physical extent16.00 MiB
Newsize given(4extents) notlargerthanexistingsize (7extents)
Run`lvextend --help'formore information.
[root@localhost ~]# lvextend -L15M /dev/aoc/Aoc1clear
Logical volume Aoc1clearnotfoundinvolume groupaoc
[root@localhost ~]# clear
[root@localhost ~]# fdisk /dev/sda
WARNING:DOS-compatible mode isdeprecated.It'sstronglyrecommendedto
switchoff the mode (command'c') andchange displayunitsto
sectors(command'u').
Command(mfor help):n
Firstcylinder(1640-2610, default1640):
Usingdefaultvalue 1640
Last cylinder,+cylindersor+size{K,M,G} (1640-2610, default2610): +500M
- 11. Command(mfor help):w
The partitiontable hasbeenaltered!
Callingioctl() tore-readpartitiontable.
WARNING:Re-readingthe partitiontable failedwitherror16: Device orresource busy.
The kernel still usesthe oldtable.The new table will be usedat
the nextrebootor afteryourun partprobe(8) orkpartx(8)
Syncingdisks.
[root@localhost ~]# fdisk /dev/sda
WARNING:DOS-compatible mode isdeprecated.It'sstrongly recommendedto
switchoff the mode (command'c') andchange displayunitsto
sectors(command'u').
Command(mfor help):p
Disk/dev/sda:21.5 GB, 21474836480 bytes
255 heads,63 sectors/track,2610 cylinders
Units= cylindersof 16065 * 512 = 8225280 bytes
Sectorsize (logical/physical):512 bytes/ 512 bytes
I/Osize (minimum/optimal):512 bytes/512 bytes
Diskidentifier:0x00043f93
Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition1 doesnotendon cylinderboundary.
/dev/sda2 26 1301 10240000 83 Linux
/dev/sda3 1301 1562 2097152 82 Linux swap/ Solaris
/dev/sda4 1562 2610 8421849 5 Extended
/dev/sda5 1562 1626 517837+ 83 Linux
- 12. /dev/sda6 1627 1632 48163+ 83 Linux
/dev/sda7 1633 1639 56196 8e Linux LVM
/dev/sda8 1640 1704 522081 83 Linux
Command (m for help):t
Partition number(1-8): 8
Hex code (type L to list codes):8e
Changedsystemtype of partition8to 8e (Linux LVM)
Command (m for help):w
The partitiontable hasbeenaltered!
Callingioctl() tore-readpartitiontable.
WARNING:Re-readingthe partitiontable failedwitherror16: Device orresource busy.
The kernel still usesthe oldtable.The new table will be usedat
the nextrebootor afteryourun partprobe(8) orkpartx(8)
Syncingdisks.
[root@localhost ~]# partx -a /dev/sda
BLKPG: Device orresource busy
error addingpartition1
BLKPG: Device orresource busy
error addingpartition2
BLKPG: Device orresource busy
error addingpartition3
BLKPG: Device orresource busy
error addingpartition4
BLKPG: Device orresource busy
error addingpartition5
- 13. BLKPG: Device orresource busy
error addingpartition6
BLKPG: Device orresource busy
error addingpartition7
[root@localhost ~]# pvcreate /dev/sda8
Physical volume"/dev/sda8"successfullycreated
[root@localhost ~]# vgcreate VG1 /dev/sda8
Volume group"VG1"successfullycreated
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name VG1
SystemID
Format lvm2
MetadataAreas 1
MetadataSequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
OpenLV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 508.00 MiB
PE Size 4.00 MiB
- 14. Total PE 127
AllocPE/ Size 0 / 0
Free PE / Size 127 / 508.00 MiB
VG UUID 5BaD8w-YikM-He7J-3q3P-LdP1-snoO-SflLpS
--- Volume group ---
VG Name aoc
SystemID
Format lvm2
MetadataAreas 1
MetadataSequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
OpenLV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size 52.00 MiB
PE Size 4.00 MiB
Total PE 13
AllocPE/ Size 7 / 28.00 MiB
Free PE / Size 6 / 24.00 MiB
VG UUID WiiSuj-VtRD-3zES-YFse-yLwN-3YS9-vnCB2k
[root@localhost ~]# lvcreate -L +100M -n LV1 VG1
- 15. Logical volume "LV1"created
[root@localhost ~]# mkfs.ext4 /dev/VG1/LV1
mke2fs1.41.12 (17-May-2010)
Filesystemlabel=
OS type:Linux
Blocksize=1024 (log=0)
Fragmentsize=1024 (log=0)
Stride=0blocks,Stripe width=0blocks
25688 inodes,102400 blocks
5120 blocks(5.00%) reservedforthe superuser
Firstdata block=1
Maximumfilesystemblocks=67371008
13 blockgroups
8192 blockspergroup,8192 fragmentspergroup
1976 inodespergroup
Superblockbackupsstoredonblocks:
8193, 24577, 40961, 57345, 73729
Writinginode tables:done
Creatingjournal (4096 blocks):done
Writingsuperblocksandfilesystemaccountinginformation:done
Thisfilesystemwill be automaticallycheckedevery20 mountsor
180 days,whichevercomesfirst. Use tune2fs -cor -i to override.
[root@localhost ~]# ls
acer Aoc Desktop Downloads install.log.syslog Music Public Templates vinod
anaconda-ks.cfg AOC Documents install.log jeson Pictures sudhaa Videos
- 16. [root@localhost ~]# mount /dev/VG1/LV1 jeson/
[root@localhost ~]# df -h
Filesystem Size UsedAvail Use%Mountedon
/dev/sda2 9.7G 2.3G 6.9G 25% /
tmpfs 504M 260K 504M 1% /dev/shm
/dev/sda1 194M 24M 161M 13% /boot
/dev/sda5 490M 11M 455M 3% /usr/olx
/dev/sr0 2.8G 2.8G 0 100% /media/RHEL_6.0 i386 Disc1
/dev/mapper/aoc-Aoc1 28M 1.4M 25M 6% /root/AOC
/dev/mapper/VG1-LV1 97M 5.6M 87M 7% /root/jeson
[root@localhost~]#lvextend -L+50M /dev/VG1/LV1
Roundingupsize tofull physical extent52.00 MiB
Extendinglogical volumeLV1to152.00 MiB
Logical volume LV1successfullyresized
[root@localhost~]#df -hT
Filesystem Type Size Used Avail Use% Mountedon
/dev/sda2 ext4 9.7G 2.3G 6.9G 25% /
tmpfs tmpfs 504M 260K 504M 1% /dev/shm
/dev/sda1 ext4 194M 24M 161M 13% /boot
/dev/sda5 ext4 490M 11M 455M 3% /usr/olx
/dev/sr0 iso9660 2.8G 2.8G 0 100% /media/RHEL_6.0i386 Disc 1
/dev/mapper/aoc-Aoc1
ext4 28M 1.4M 25M 6% /root/AOC
/dev/mapper/VG1-LV1
ext4 97M 5.6M 87M 7% /root/jeson
- 17. [root@localhost ~]# resize2fs/dev/VG1/LV1
resize2fs1.41.12 (17-May-2010)
Filesystemat/dev/VG1/LV1ismountedon/root/jeson;on-line resizingrequired
olddesc_blocks= 1, new_desc_blocks=1
Performinganon-lineresizeof /dev/VG1/LV1to155648 (1k) blocks.
The filesystemon/dev/VG1/LV1isnow155648 blockslong.
[root@localhost ~]# df -hT
Filesystem Type Size Used Avail Use% Mountedon
/dev/sda2 ext4 9.7G 2.3G 6.9G 25% /
tmpfs tmpfs 504M 260K 504M 1% /dev/shm
/dev/sda1 ext4 194M 24M 161M 13% /boot
/dev/sda5 ext4 490M 11M 455M 3% /usr/olx
/dev/sr0 iso9660 2.8G 2.8G 0 100% /media/RHEL_6.0i386 Disc 1
/dev/mapper/aoc-Aoc1
ext4 28M 1.4M 25M 6% /root/AOC
/dev/mapper/VG1-LV1
ext4 148M 5.6M 135M 4% /root/jeson
LVM REMOVE
[root@localhost ~]# lvs
LV VG Attr LSize OriginSnap% Move Log Copy% Convert
LV1 VG1 -wi-a- 152.00m
Aoc1 aoc -wi-a- 28.00m
[root@localhost ~]# lvremove /dev/aoc
Do youreallywantto remove active logical volume Aoc1?[y/n]:y
- 18. Logical volume "Aoc1"successfullyremoved
[root@localhost ~]# lvs
LV VG Attr LSize OriginSnap% Move Log Copy% Convert
LV1 VG1 -wi-a- 152.00m
[root@localhost ~]# vgremove aoc
Volume group"aoc"successfullyremoved
[root@localhost ~]# vgs
VG #PV #LV #SN Attr VSize VFree
VG1 1 1 0 wz--n- 508.00m 356.00m
[root@localhost ~]# pvremove /dev/sda7
Labelson physical volume "/dev/sda7"successfullywiped