2016年4月18日 星期一

02_LVM


1.再VM加一個硬碟後,到OS下指令


# echo "- - -" > /sys/class/scsi_host/host0/scan

2.查看硬碟狀況


(假設新增的硬碟為/dev/sdb)

[root@AD-Content1 ~]# fdisk -l

Disk /dev/sda: 45.1 GB, 45097156608 bytes
64 heads, 32 sectors/track, 43008 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00095823

Device Boot Start End Blocks Id System
/dev/sda1 * 2 101 102400 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 102 2149 2097152 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 2150 43008 41839616 8e Linux LVM
Partition 3 does not end on cylinder boundary.

Disk /dev/mapper/VolGroup-LogVol00: 64.3 GB, 64311263232 bytes
255 heads, 63 sectors/track, 7818 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: 0x00000000


Disk /dev/sdb: 21.5 GB, 21474836480 bytes
64 heads, 32 sectors/track, 20480 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xf82ed6f9

3.建立partition

#fdisk /dev/sdb

m---查看有哪些指令
n---新增partition
出現詢問建立方式

Command (m for help): n
Command action <==因為是全新磁碟,因此只會問extended/primary而已,選 "p"
e extended
p primary partition (1-4)
p <==選擇 Primary 分割槽
Partition number (1-4): 1 <==設定為 1 號!
First cylinder (1-5005, default 1): <==直接按下[enter]按鍵決定!
Using default value 1 <==啟始磁柱就選用預設值!
Last cylinder or +size or +sizeM or +sizeK (1-5005, default 5005): <==直接按下[enter]按鍵決定!

p---查看partiton的狀態

t---選擇partiton 檔案ID (LVG選8e)

w---寫入並離開


4.建立PV



  -- raw device 為 /dev/sdb  format過後 會加1 p=1 剛剛的設定
#pvcreate /dev/sdb1 <==把sdb1這個partition轉換成pv

5.查詢VG名稱


   #  -- 查看現有VG,發現有個名叫  VolGroup00

[root@AD-Content1 ~]# vgdisplay
File descriptor 63 (pipe:[1133205204]) leaked on vgdisplay invocation. Parent PID 21722: -bash
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 2
Act PV 2
VG Size 59.89 GiB
PE Size 4.00 MiB
Total PE 15333
Alloc PE / Size 15333 / 59.89 GiB
Free PE / Size 0 / 0
VG UUID Mm60hX-raIB-Ew8H-wHN8-G0Z1-7JGV-1B0ZXI



#vgextend VolGroup00  /dev/sdb1 <==把sdb1這個pv 加入到 VolGroup00



6.擴建LV


#lvdisplay <==  
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol00 <== LV 的全名
VG Name VolGroup00
LV UUID pKnp0w-U365-Bfy1-YX1t-lgTZ-BQPA-M0bOOD
LV Write Access read/write
LV Status available
# open 1
LV Size 30.94 GB
Current LE 990
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0

#vgdisplay 
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 6
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 3
Act PV 3
VG Size 44.81 GB
PE Size 32.00 MB
Total PE 1434
Alloc PE / Size 1115 / 34.84 GB
Free PE / Size 319 / 9.97 GB <== VG還有多少空間
VG UUID iNuEfu-nvif-VyKP-wybl-ydrZ-BT6N-bQ6b07


那個+號很重要
#lvresize -l +319 /dev/VolGroup00/LogVol00 <==把"VolGroup00"這個VG裡還有319的PE空間,增加到"LogVol00" 這個LV
如果出現要你按 y/n要注意,就是你指令下錯了


7.將檔案系統的容量確實增加



這時候df -h 容量還沒增加

                    LV Name
#resize2fs /dev/VolGroup00/LogVol00









沒有留言:

RHEL install EPEL

  https://www.linuxtechi.com/install-epel-repo-on-rhel-system/ EPEL dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest...