linux擴充套件邏輯卷
阿新 • • 發佈:2019-04-26
1.檢視系統的檔案系統大小
#> df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 18G 4.4G 13G 27% /
tmpfs 931M 76K 931M 1% /dev/shm
/dev/sda1 283M 40M 229M 15% /boot
2.檢視檔案系統
#> fdisk -l Disk /dev/sda: 32.2 GB, 32212254720 bytes 255 heads, 63 sectors/track, 3916 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000e0569 Device Boot Start End Blocks Id System /dev/sda1 * 1 39 307200 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 39 2350 18566144 83 Linux /dev/sda3 2350 2611 2097152 82 Linux swap / Solaris
3.建立物理卷
#> fdisk /dev/sda WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). 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 ##選擇預設分割槽 Selected partition 4 First cylinder (2611-3916, default 2611): Using default value 2611 Last cylinder, +cylinders or +size{K,M,G} (2611-3916, default 3916): +10G ##擴充套件10G Command (m for help): P ##檢視擴充套件後的所有邏輯卷 Disk /dev/sda: 32.2 GB, 32212254720 bytes 255 heads, 63 sectors/track, 3916 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000e0569 Device Boot Start End Blocks Id System /dev/sda1 * 1 39 307200 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 39 2350 18566144 83 Linux /dev/sda3 2350 2611 2097152 82 Linux swap / Solaris /dev/sda4 2611 3916 10483750 83 Linux Command (m for help): t ##修改指定邏輯卷的型別 Partition number (1-4): 4 ##指定要修改的邏輯卷編碼 Hex code (type L to list codes): 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'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 Hex code (type L to list codes): 8e ##選擇指定型別 Changed system type of partition 4 to 8e (Linux LVM) Command (m for help): p ##檢視修改後的型別 Disk /dev/sda: 32.2 GB, 32212254720 bytes 255 heads, 63 sectors/track, 3916 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000e0569 Device Boot Start End Blocks Id System /dev/sda1 * 1 39 307200 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 39 2350 18566144 83 Linux /dev/sda3 2350 2611 2097152 82 Linux swap / Solaris /dev/sda4 2611 3916 10483750 8e Linux LVM Command (m for help): wq ##儲存退出 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.
4.重啟
#> reboot
5.檢視物理卷是否生效
#> cat /proc/partitions
major minor #blocks name
8 0 31457280 sda
8 1 307200 sda1
8 2 18566144 sda2
8 3 2097152 sda3
8 4 10483750 sda4
6.建立pv
#> pvcreate /dev/sda4 Physical volume "/dev/sda4" successfully created #> pvs PV VG Fmt Attr PSize PFree /dev/sda4 lvm2 ---- 10.00g 10.00g #> pvdisplay "/dev/sda4" is a new physical volume of "10.00 GiB" --- NEW Physical volume --- PV Name /dev/sda4 VG Name PV Size 10.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID GheGu7-9leQ-RSZu-0meT-U9j2-9rm4-E7zhze
7.檢視所有vg
#> vgs
8.擴充套件指定vg
#> vgextend /dev/centos/root /dev/sda4
Volume group "myvg" successfully created
9.擴充套件的lv
#> lvextend -L +10G /dev/centos/root
10.是擴充套件的邏輯卷生效
#> resize2fs /dev/centos/root
若報錯請執行
#> xfs_growfs /dev/centos/ro