Try   HackMD

LVM

Server disk 的擴充是在 linux operation 常見的使用者需求。 會需要 System engineer 協助在phy or vm 加上lvm

linux常見操作指令 :

$ lsblk : 可以查看 disk 狀況

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

$fdisk :磁碟管理工具,可以引導操作

如果 disk 沒有顯示,請先掃描

$ ls /sys/class/scsi_host

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →
$ echo "- - -" > /sys/class/scsi_host/host[數字]/scan

以上圖為例:

sdd 為一個未被使用的硬碟,先做 pv , extend 到 vg, 在 extend lv $pvcreate /dev/sdd 

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

$vgs 查看 vgs狀況

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

$ vgextend vg01 /dev/sdd à 把新空間加到 vg01,vgs 就可以看到有 free 空間

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

$ lvextensd -l +100%free /dev/vg01/lv01

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

$ xfs_growfs /data/

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

最後可以用 df -h 或是 lsblk查看

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

如果今天是一個全新的 lvm 要使用?

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

步驟差異:

$ pvcreate /dev/sdd

$ vgcreate PGdata /dev/sdb

$vgdisplay -v PGdata

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

還沒 lvcreate前 free PE 204799

$ lvcreate -l 204799 -n PGdata_lv /dev/PGdata

$ mkfs.xfs /dev/PGdata/PGdata_lv

把空間 mount 到 /data

透過編寫/etc/fstab

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

$ mount -a   

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →