linux-根目錄添加內存


01,添加磁盤到服務器

02, 查看添加的內容

這個是新添加的

03, 創建新分區  

[root@oracle01 ~]# fdisk /dev/sdb   --格式化分析
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x55166394.

Command (m for help): p  ---打印結果

Disk /dev/sdb: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x55166394

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n   --新建分區
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p   主分區
Partition number (1-4, default 1):
First sector (2048-104857599, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599):
Using default value 104857599
Partition 1 of type Linux and of size 50 GiB is set

Command (m for help): t   ---設置格式為LVM格式
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): p

Disk /dev/sdb: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x55166394
 設備 啟動   起點     終點   塊數  Id 系統
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048   104857599    52427776   8e  Linux LVM

Command (m for help): w   ---保存信息
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

完成后重啟下機器最好

04, 創建pV

[root@oracle01 ~]# pvcreate /dev/sdb1   創建pv
  Physical volume "/dev/sdb1" successfully created.

(這個后面的為格式化的盤符標識)
[root@oracle01 ~]# pvdisplay   ---查看pv物理卷和大小
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               centos
  PV Size               <49.00 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              12543
  Free PE               0
  Allocated PE          12543
  PV UUID               VjyFas-6rml-bolo-Jt2V-1Nq9-U5Tm-7W7c1b

  "/dev/sdb1" is a new physical volume of "<50.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb1
  VG Name
  PV Size               <50.00 GiB   出現一個新的就是剛剛船艦
  Allocatable           NO
  PE Size               0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               xeXK3i-0XLh-WEn3-eTG8-bjGJ-Pq47-RVEgZB

05,查看vg

[root@oracle01 ~]# vgdisplay
  --- Volume group ---
  VG Name               centos
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <49.00 GiB
  PE Size               4.00 MiB
  Total PE              12543
  Alloc PE / Size       12543 / <49.00 GiB
  Free  PE / Size       0 / 0
  VG UUID               igaCVK-95JF-h8OF-4S9E-o4ay-u6Zq-RpCN2v

加入vg

[root@oracle01 ~]# vgextend centos /dev/sdb1
            名字為上面VG的name Volume
group "centos" successfully extended
[root@oracle01 ~]# vgdisplay
  --- Volume group ---
  VG Name               centos
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               98.99 GiB
  PE Size               4.00 MiB
  Total PE              25342
  Alloc PE / Size       12543 / <49.00 GiB
  Free  PE / Size       12799 / <50.00 GiB         ---這個就是了
  VG UUID               igaCVK-95JF-h8OF-4S9E-o4ay-u6Zq-RpCN2v

發現已經添加進去了

06,增加根目錄空間

lvresize -L +11G /dev/mapper/centos-root  添加11G進去

 添加所有的話:

lvextend /dev/centos/root /dev/sdb1

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM