linux7扩根盘/扩swap/加vg等操作

cat /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core) 

分区/物理磁盘/物理卷/卷组/逻辑卷/文件系统之间关系

  • partition>fs
  • partition->vg->lv->fs
  • pv ->vg->lv->fs

原:

目标:扩展/系统大小到100G,扩展swap大小到16G,剩余空间400多G划分给/oracle

思路:

扩根盘:查看vgs剩余/磁盘大小/新分区/创建pv添加到vg/扩展逻辑卷/扩展根系统xfs_growfs

扩swap:查看lvs所属卷/扩逻辑卷/关闭swap/mkswap/激活swap

加挂接点:新分区/建pv/建vg/建lv/建挂接点/加/etc/fstab

如下为操作步骤:

[root@test ~]# 
[root@test ~]# 
[root@test ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  4.0G  2.0G  2.1G  49% /
devtmpfs                  32G  587M   31G   2% /dev
tmpfs                     32G     0   32G   0% /dev/shm
tmpfs                     32G  8.4M   32G   1% /run
tmpfs                     32G     0   32G   0% /sys/fs/cgroup
/dev/vda1                497M  150M  348M  31% /boot
tmpfs                    6.3G     0  6.3G   0% /run/user/0
[root@test ~]# 
[root@test ~]# 
[root@test ~]# vgs
  VG     #PV #LV #SN Attr   VSize VFree 
  centos   1   2   0 wz--n- 4.51g 40.00m
[root@test ~]# lvs
  LV   VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root centos -wi-ao----   3.97g                                                    
  swap centos -wi-ao---- 512.00m                                                    
[root@test ~]# pvs
  PV         VG     Fmt  Attr PSize PFree 
  /dev/vda2  centos lvm2 a--  4.51g 40.00m
[root@test ~]# fdisk -l

Disk /dev/vda: 590.6 GB, 590558003200 bytes, 1153433600 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: 0x00082859

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048     1026047      512000   83  Linux
/dev/vda2         1026048    10485759     4729856   8e  Linux LVM

Disk /dev/mapper/centos-root: 4261 MB, 4261412864 bytes, 8323072 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 /dev/mapper/centos-swap: 536 MB, 536870912 bytes, 1048576 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

[root@test ~]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Sat Feb 24 21:59:55 2018
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root /                       xfs     defaults        0 0
UUID=2172ba19-1b4d-4d60-b8aa-3d02817f9f95 /boot                   xfs     defaults        0 0
/dev/mapper/centos-swap swap                    swap    defaults        0 0
[root@test ~]# 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               4.51 GiB
  PE Size               4.00 MiB
  Total PE              1154
  Alloc PE / Size       1144 / 4.47 GiB
  Free  PE / Size       10 / 40.00 MiB
  VG UUID               QkL0c1-d9GH-Frgg-Ffbi-SiN9-D4pG-KuzhR6
   
[root@test ~]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/centos/swap
  LV Name                swap
  VG Name                centos
  LV UUID                JG3sOZ-9CaL-cPh8-u4G3-R3Q2-WVmg-g0jheg
  LV Write Access        read/write
  LV Creation host, time localhost, 2018-02-24 21:59:52 +0800
  LV Status              available
  # open                 2
  LV Size                512.00 MiB
  Current LE             128
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:1
   
  --- Logical volume ---
  LV Path                /dev/centos/root
  LV Name                root
  VG Name                centos
  LV UUID                a5TL6c-qh22-39xl-sXpd-cIhs-QcHX-zMfBFN
  LV Write Access        read/write
  LV Creation host, time localhost, 2018-02-24 21:59:52 +0800
  LV Status              available
  # open                 1
  LV Size                3.97 GiB
  Current LE             1016
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0
   
[root@test ~]# fdisk /dev/vda
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.


Command (m for help): p

Disk /dev/vda: 590.6 GB, 590558003200 bytes, 1153433600 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: 0x00082859

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048     1026047      512000   83  Linux
/dev/vda2         1026048    10485759     4729856   8e  Linux LVM

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
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   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
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): e
Partition number (3,4, default 3): 
First sector (10485760-1153433599, default 10485760): 
Using default value 10485760
Last sector, +sectors or +size{K,M,G} (10485760-1153433599, default 1153433599): 146G    
Value out of range.
Last sector, +sectors or +size{K,M,G} (10485760-1153433599, default 1153433599): +146g
Unsupported suffix: 'g'.
Supported: 10^N: KB (KiloByte), MB (MegaByte), GB (GigaByte)
            2^N: K  (KibiByte), M  (MebiByte), G  (GibiByte)
Last sector, +sectors or +size{K,M,G} (10485760-1153433599, default 1153433599): 50g
Value out of range.
Last sector, +sectors or +size{K,M,G} (10485760-1153433599, default 1153433599): 
Using default value 1153433599
Partition 3 of type Extended and of size 545 GiB is set

Command (m for help): P

Disk /dev/vda: 590.6 GB, 590558003200 bytes, 1153433600 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: 0x00082859

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048     1026047      512000   83  Linux
/dev/vda2         1026048    10485759     4729856   8e  Linux LVM
/dev/vda3        10485760  1153433599   571473920    5  Extended

Command (m for help): Q

[root@test ~]# fdisk /dev/vda
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.


Command (m for help): p

Disk /dev/vda: 590.6 GB, 590558003200 bytes, 1153433600 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: 0x00082859

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048     1026047      512000   83  Linux
/dev/vda2         1026048    10485759     4729856   8e  Linux LVM

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
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   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  
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): p
Partition number (3,4, default 3): 
First sector (10485760-1153433599, default 10485760): 
Using default value 10485760
Last sector, +sectors or +size{K,M,G} (10485760-1153433599, default 1153433599): 146G
Value out of range.
Last sector, +sectors or +size{K,M,G} (10485760-1153433599, default 1153433599): 230000000
Partition 3 of type Linux and of size 104.7 GiB is set

Command (m for help): p

Disk /dev/vda: 590.6 GB, 590558003200 bytes, 1153433600 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: 0x00082859

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048     1026047      512000   83  Linux
/dev/vda2         1026048    10485759     4729856   8e  Linux LVM
/dev/vda3        10485760   230000000   109757120+  83  Linux

Command (m for help): w
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.
[root@test ~]# fdisk /dev/vda
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.


Command (m for help): p

Disk /dev/vda: 590.6 GB, 590558003200 bytes, 1153433600 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: 0x00082859

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048     1026047      512000   83  Linux
/dev/vda2         1026048    10485759     4729856   8e  Linux LVM
/dev/vda3        10485760   230000000   109757120+  83  Linux

Command (m for help): 
Command (m for help): q

[root@test ~]# vgs       
  VG     #PV #LV #SN Attr   VSize VFree 
  centos   1   2   0 wz--n- 4.51g 40.00m
[root@test ~]# vgextend centos /dev/vda3
  Device /dev/vda3 not found (or ignored by filtering).
  Unable to add physical volume '/dev/vda3' to volume group 'centos'.
[root@test ~]# parted probe
Error: Could not stat device probe - No such file or directory.
Retry/Cancel? Cancel                                                      
[root@test ~]# 
[root@test ~]# 
[root@test ~]# reboot

---swap---

[root@test ~]# LANG=C
[root@test ~]# fdisk -l

Disk /dev/vda: 590.6 GB, 590558003200 bytes, 1153433600 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: 0x00082859

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048     1026047      512000   83  Linux
/dev/vda2         1026048    10485759     4729856   8e  Linux LVM
/dev/vda3        10485760   230000000   109757120+  83  Linux

Disk /dev/mapper/centos-root: 4261 MB, 4261412864 bytes, 8323072 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 /dev/mapper/centos-swap: 536 MB, 536870912 bytes, 1048576 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

[root@test ~]# vgextend centos /dev/vda3
  Physical volume "/dev/vda3" successfully created
  Volume group "centos" successfully extended
[root@test ~]# vgs
  VG     #PV #LV #SN Attr   VSize   VFree  
  centos   2   2   0 wz--n- 109.18g 104.71g
[root@test ~]# lvs
  LV   VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root centos -wi-ao----   3.97g                                                    
  swap centos -wi-ao---- 512.00m                                                    
[root@test ~]# pvs
  PV         VG     Fmt  Attr PSize   PFree  
  /dev/vda2  centos lvm2 a--    4.51g  40.00m
  /dev/vda3  centos lvm2 a--  104.67g 104.67g
[root@test ~]# free -g
              total        used        free      shared  buff/cache   available
Mem:             62           0          62           0           0          62
Swap:             0           0           0
[root@test ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:          64266         452       63652           8         162       63626
Swap:           511           0         511
[root@test ~]# lvextend -L +15872M /dev/mapper/centos-swap
  Size of logical volume centos/swap changed from 512.00 MiB (128 extents) to 16.00 GiB (4096 extents).
  Logical volume swap successfully resized.
[root@test ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:          64266         451       63651           8         163       63626
Swap:           511           0         511
[root@test ~]# reboot
PolicyKit daemon disconnected from the bus.
We are no longer a registered authentication agent.

----扩/----

[root@test ~]# 
[root@test ~]# 
[root@test ~]# 
[root@test ~]# LANG=C
[root@test ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  4.0G  2.0G  2.1G  49% /
devtmpfs                  32G     0   32G   0% /dev
tmpfs                     32G     0   32G   0% /dev/shm
tmpfs                     32G  8.4M   32G   1% /run
tmpfs                     32G     0   32G   0% /sys/fs/cgroup
/dev/vda1                497M  150M  348M  31% /boot
tmpfs                    6.3G     0  6.3G   0% /run/user/0
[root@test ~]# free -g
              total        used        free      shared  buff/cache   available
Mem:             62           0          62           0           0          62
Swap:             0           0           0
[root@test ~]# vgs
  VG     #PV #LV #SN Attr   VSize   VFree 
  centos   2   2   0 wz--n- 109.18g 89.21g
[root@test ~]# lvs
  LV   VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root centos -wi-ao----  3.97g                                                    
  swap centos -wi-ao---- 16.00g                                                    
[root@test ~]# vgdisplay|grep PE                 
  PE Size               4.00 MiB
  Total PE              27949
  Alloc PE / Size       5112 / 19.97 GiB
  Free  PE / Size       22837 / 89.21 GiB
[root@test ~]# lvextend -l +22837 /dev/mapper/centos-root
  Size of logical volume centos/root changed from 3.97 GiB (1016 extents) to 93.18 GiB (23853 extents).
  Logical volume root successfully resized.
[root@test ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  4.0G  2.0G  2.1G  49% /
devtmpfs                  32G     0   32G   0% /dev
tmpfs                     32G     0   32G   0% /dev/shm
tmpfs                     32G  8.4M   32G   1% /run
tmpfs                     32G     0   32G   0% /sys/fs/cgroup
/dev/vda1                497M  150M  348M  31% /boot
tmpfs                    6.3G     0  6.3G   0% /run/user/0
[root@test ~]# resize2fs /dev/mapper/centos-root
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/mapper/centos-root
Couldn't find valid filesystem superblock.
[root@test ~]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=256    agcount=4, agsize=260096 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=1040384, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 1040384 to 24425472
[root@test ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   94G  2.0G   92G   3% /
devtmpfs                  32G     0   32G   0% /dev
tmpfs                     32G     0   32G   0% /dev/shm
tmpfs                     32G  8.4M   32G   1% /run
tmpfs                     32G     0   32G   0% /sys/fs/cgroup
/dev/vda1                497M  150M  348M  31% /boot
tmpfs                    6.3G     0  6.3G   0% /run/user/0
[root@test ~]# free -g
              total        used        free      shared  buff/cache   available
Mem:             62           0          62           0           0          62
Swap:             0           0           0
[root@test ~]# xfs_growfs /dev/mapper/centos-swap
xfs_growfs: /dev/mapper/centos-swap is not a mounted XFS filesystem
[root@test ~]# swapon /dev/mapper/centos-swap
swapon: /dev/mapper/centos-swap: swapon failed: Device or resource busy
[root@test ~]# swapoff /dev/mapper/centos-swap
[root@test ~]# swapon /dev/mapper/centos-swap
[root@test ~]# free -g
              total        used        free      shared  buff/cache   available
Mem:             62           0          62           0           0          62
Swap:             0           0           0
[root@test ~]# lvs
  LV   VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root centos -wi-ao---- 93.18g                                                    
  swap centos -wi-ao---- 16.00g                                                    
[root@test ~]# ll /dev/centos/
total 0
lrwxrwxrwx. 1 root root 7 Jun 18 09:46 root -> ../dm-0
lrwxrwxrwx. 1 root root 7 Jun 18 09:50 swap -> ../dm-1
[root@test ~]# free -g
              total        used        free      shared  buff/cache   available
Mem:             62           0          62           0           0          62
Swap:             0           0           0
[root@test ~]# lvs
  LV   VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root centos -wi-ao---- 93.18g                                                    
  swap centos -wi-ao---- 16.00g                                                    
[root@test ~]# mkswap /dev/centos/swap
mkswap: error: /dev/centos/swap is mounted; will not make swapspace
[root@test ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   94G  2.0G   92G   3% /
devtmpfs                  32G     0   32G   0% /dev
tmpfs                     32G     0   32G   0% /dev/shm
tmpfs                     32G  8.4M   32G   1% /run
tmpfs                     32G     0   32G   0% /sys/fs/cgroup
/dev/vda1                497M  150M  348M  31% /boot
tmpfs                    6.3G     0  6.3G   0% /run/user/0
[root@test ~]# swapon /dev/centos/swap
swapon: /dev/centos/swap: swapon failed: Device or resource busy
[root@test ~]# swapoff /dev/centos/swap
[root@test ~]# mkswap /dev/centos/swap
mkswap: /dev/centos/swap: warning: wiping old swap signature.
Setting up swapspace version 1, size = 16777212 KiB
no label, UUID=aceb3740-5498-4f98-80f6-15d20a40f629
[root@test ~]# swapon /dev/centos/swap
[root@test ~]# free -g
              total        used        free      shared  buff/cache   available
Mem:             62           0          62           0           0          62
Swap:            15           0          15
[root@test ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   94G  2.0G   92G   3% /
devtmpfs                  32G     0   32G   0% /dev
tmpfs                     32G     0   32G   0% /dev/shm
tmpfs                     32G  8.4M   32G   1% /run
tmpfs                     32G     0   32G   0% /sys/fs/cgroup
/dev/vda1                497M  150M  348M  31% /boot
tmpfs                    6.3G     0  6.3G   0% /run/user/0
[root@test ~]# pwd
/root
[root@test ~]# fdisk /dev/vda
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.


Command (m for help): p

Disk /dev/vda: 590.6 GB, 590558003200 bytes, 1153433600 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: 0x00082859

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048     1026047      512000   83  Linux
/dev/vda2         1026048    10485759     4729856   8e  Linux LVM
/dev/vda3        10485760   230000000   109757120+  83  Linux

Command (m for help): n
Partition type:
   p   primary (3 primary, 0 extended, 1 free)
   e   extended
Select (default e): e
Selected partition 4
First sector (230000001-1153433599, default 230000640): 
Using default value 230000640
Last sector, +sectors or +size{K,M,G} (230000640-1153433599, default 1153433599): 
Using default value 1153433599
Partition 4 of type Extended and of size 440.3 GiB is set

Command (m for help): p  

Disk /dev/vda: 590.6 GB, 590558003200 bytes, 1153433600 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: 0x00082859

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048     1026047      512000   83  Linux
/dev/vda2         1026048    10485759     4729856   8e  Linux LVM
/dev/vda3        10485760   230000000   109757120+  83  Linux
/dev/vda4       230000640  1153433599   461716480    5  Extended

Command (m for help): w
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.
[root@test ~]# fdisk -l      

Disk /dev/vda: 590.6 GB, 590558003200 bytes, 1153433600 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: 0x00082859

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048     1026047      512000   83  Linux
/dev/vda2         1026048    10485759     4729856   8e  Linux LVM
/dev/vda3        10485760   230000000   109757120+  83  Linux
/dev/vda4       230000640  1153433599   461716480    5  Extended

Disk /dev/mapper/centos-root: 100.0 GB, 100046733312 bytes, 195403776 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 /dev/mapper/centos-swap: 17.2 GB, 17179869184 bytes, 33554432 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

[root@test ~]# pvcreate /dev/vda4
  Device /dev/vda4 not found (or ignored by filtering).
[root@test ~]# reboot
PolicyKit daemon disconnected from the bus.
We are no longer a registered authentication agent.

---加/oracle-------

[root@test ~]# LANG=C
[root@test ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   94G  2.0G   92G   3% /
devtmpfs                  32G     0   32G   0% /dev
tmpfs                     32G     0   32G   0% /dev/shm
tmpfs                     32G  8.4M   32G   1% /run
tmpfs                     32G     0   32G   0% /sys/fs/cgroup
/dev/vda1                497M  150M  348M  31% /boot
tmpfs                    6.3G     0  6.3G   0% /run/user/0
[root@test ~]# pvcreate /dev/vda4
  Device /dev/vda4 not found (or ignored by filtering).
[root@test ~]# fdisk -l

Disk /dev/vda: 590.6 GB, 590558003200 bytes, 1153433600 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: 0x00082859

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048     1026047      512000   83  Linux
/dev/vda2         1026048    10485759     4729856   8e  Linux LVM
/dev/vda3        10485760   230000000   109757120+  83  Linux
/dev/vda4       230000640  1153433599   461716480    5  Extended

Disk /dev/mapper/centos-root: 100.0 GB, 100046733312 bytes, 195403776 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 /dev/mapper/centos-swap: 17.2 GB, 17179869184 bytes, 33554432 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
[root@test ~]# fdisk -l

Disk /dev/vda: 590.6 GB, 590558003200 bytes, 1153433600 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: 0x00082859

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048     1026047      512000   83  Linux
/dev/vda2         1026048    10485759     4729856   8e  Linux LVM
/dev/vda3        10485760   230000000   109757120+  83  Linux
/dev/vda4       230000640  1153433599   461716480    5  Extended

Disk /dev/mapper/centos-root: 100.0 GB, 100046733312 bytes, 195403776 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 /dev/mapper/centos-swap: 17.2 GB, 17179869184 bytes, 33554432 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

[root@test ~]# fdisk /dev/vda
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.


Command (m for help): p

Disk /dev/vda: 590.6 GB, 590558003200 bytes, 1153433600 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: 0x00082859

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048     1026047      512000   83  Linux
/dev/vda2         1026048    10485759     4729856   8e  Linux LVM
/dev/vda3        10485760   230000000   109757120+  83  Linux
/dev/vda4       230000640  1153433599   461716480    5  Extended

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
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   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
All primary partitions are in use
Adding logical partition 5
First sector (230002688-1153433599, default 230002688): 
Using default value 230002688
Last sector, +sectors or +size{K,M,G} (230002688-1153433599, default 1153433599): 
Using default value 1153433599
Partition 5 of type Linux and of size 440.3 GiB is set

Command (m for help): p

Disk /dev/vda: 590.6 GB, 590558003200 bytes, 1153433600 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: 0x00082859

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048     1026047      512000   83  Linux
/dev/vda2         1026048    10485759     4729856   8e  Linux LVM
/dev/vda3        10485760   230000000   109757120+  83  Linux
/dev/vda4       230000640  1153433599   461716480    5  Extended
/dev/vda5       230002688  1153433599   461715456   83  Linux

Command (m for help): d                                                                                   
Partition number (1-5, default 5): 5
Partition 5 is deleted

Command (m for help): d
Partition number (1-4, default 4): 4
Partition 4 is deleted

Command (m for help): p

Disk /dev/vda: 590.6 GB, 590558003200 bytes, 1153433600 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: 0x00082859

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048     1026047      512000   83  Linux
/dev/vda2         1026048    10485759     4729856   8e  Linux LVM
/dev/vda3        10485760   230000000   109757120+  83  Linux

Command (m for help): n
Partition type:
   p   primary (3 primary, 0 extended, 1 free)
   e   extended
Select (default e): p
Selected partition 4
First sector (230000001-1153433599, default 230000640): 
Using default value 230000640
Last sector, +sectors or +size{K,M,G} (230000640-1153433599, default 1153433599): 
Using default value 1153433599
Partition 4 of type Linux and of size 440.3 GiB is set

Command (m for help): p

Disk /dev/vda: 590.6 GB, 590558003200 bytes, 1153433600 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: 0x00082859

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048     1026047      512000   83  Linux
/dev/vda2         1026048    10485759     4729856   8e  Linux LVM
/dev/vda3        10485760   230000000   109757120+  83  Linux
/dev/vda4       230000640  1153433599   461716480   83  Linux

Command (m for help): w
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.
[root@test ~]# 
[root@test ~]# 
[root@test ~]# 
[root@test ~]# fdisk -l

Disk /dev/vda: 590.6 GB, 590558003200 bytes, 1153433600 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: 0x00082859

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048     1026047      512000   83  Linux
/dev/vda2         1026048    10485759     4729856   8e  Linux LVM
/dev/vda3        10485760   230000000   109757120+  83  Linux
/dev/vda4       230000640  1153433599   461716480   83  Linux

Disk /dev/mapper/centos-root: 100.0 GB, 100046733312 bytes, 195403776 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 /dev/mapper/centos-swap: 17.2 GB, 17179869184 bytes, 33554432 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

[root@test ~]# pvcreate /dev/vda4
  Device /dev/vda4 not found (or ignored by filtering).
[root@test ~]# reboot
PolicyKit daemon disconnected from the bus.
We are no longer a registered authentication agent.


[root@test ~]# 
[root@test ~]# df -h
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   94G  2.0G   92G    3% /
devtmpfs                  32G     0   32G    0% /dev
tmpfs                     32G     0   32G    0% /dev/shm
tmpfs                     32G  8.4M   32G    1% /run
tmpfs                     32G     0   32G    0% /sys/fs/cgroup
/dev/vda1                497M  150M  348M   31% /boot
tmpfs                    6.3G     0  6.3G    0% /run/user/0
[root@test ~]# 
[root@test ~]# 
[root@test ~]# fdisk -l

磁盘 /dev/vda:590.6 GB, 590558003200 字节,1153433600 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x00082859

   设备 Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048     1026047      512000   83  Linux
/dev/vda2         1026048    10485759     4729856   8e  Linux LVM
/dev/vda3        10485760   230000000   109757120+  83  Linux
/dev/vda4       230000640  1153433599   461716480   83  Linux

磁盘 /dev/mapper/centos-root:100.0 GB, 100046733312 字节,195403776 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节


磁盘 /dev/mapper/centos-swap:17.2 GB, 17179869184 字节,33554432 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节

[root@test ~]# pvcreate /dev/vda4
WARNING: dos signature detected on /dev/vda4 at offset 510. Wipe it? [y/n]: y
  Wiping dos signature on /dev/vda4.
  Physical volume "/dev/vda4" successfully created
[root@test ~]# pvs
  PV         VG     Fmt  Attr PSize   PFree  
  /dev/vda2  centos lvm2 a--    4.51g      0 
  /dev/vda3  centos lvm2 a--  104.67g      0 
  /dev/vda4         lvm2 ---  440.33g 440.33g
[root@test ~]# vgcreate oravg /dev/vda4
  Volume group "oravg" successfully created
[root@test ~]# vgs
  VG     #PV #LV #SN Attr   VSize   VFree  
  centos   2   2   0 wz--n- 109.18g      0 
  oravg    1   0   0 wz--n- 440.32g 440.32g
[root@test ~]# vgdisplay oravg|grep PE
  PE Size               4.00 MiB
  Total PE              112723
  Alloc PE / Size       0 / 0   
  Free  PE / Size       112723 / 440.32 GiB
[root@test ~]# lvcreate -l 112723 oravg -n oralv
  Logical volume "oralv" created.
[root@test ~]# lvs
  LV    VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root  centos -wi-ao----  93.18g                                                    
  swap  centos -wi-ao----  16.00g                                                    
  oralv oravg  -wi-a----- 440.32g                                                    
[root@test ~]# pwd
/root
[root@test ~]# cd /dev/oravg
[root@test oravg]# ll
总用量 0
lrwxrwxrwx. 1 root root 7 6月  18 10:06 oralv -> ../dm-2
[root@test oravg]# lvdisplay oravg
  --- Logical volume ---
  LV Path                /dev/oravg/oralv
  LV Name                oralv
  VG Name                oravg
  LV UUID                jIv3FV-IQ18-giEu-hcUT-ZOAk-56ON-mRq29f
  LV Write Access        read/write
  LV Creation host, time test, 2020-06-18 10:06:20 +0800
  LV Status              available
  # open                 0
  LV Size                440.32 GiB
  Current LE             112723
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:2
   
[root@test oravg]# mkfs.xfs /dev/oravg/oralv
meta-data=/dev/oravg/oralv       isize=256    agcount=4, agsize=28857088 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=115428352, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=56361, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@test oravg]# pwd
/dev/oravg
[root@test oravg]# mkdir /oracle
[root@test oravg]# mount /dev/oravg/oralv /oracle
[root@test oravg]# df -h
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   94G  2.0G   92G    3% /
devtmpfs                  32G     0   32G    0% /dev
tmpfs                     32G     0   32G    0% /dev/shm
tmpfs                     32G  8.4M   32G    1% /run
tmpfs                     32G     0   32G    0% /sys/fs/cgroup
/dev/vda1                497M  150M  348M   31% /boot
tmpfs                    6.3G     0  6.3G    0% /run/user/0
/dev/mapper/oravg-oralv  441G   33M  441G    1% /oracle
[root@test oravg]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Sat Feb 24 21:59:55 2018
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root /                       xfs     defaults        0 0
UUID=2172ba19-1b4d-4d60-b8aa-3d02817f9f95 /boot                   xfs     defaults        0 0
/dev/mapper/centos-swap swap                    swap    defaults        0 0

[root@test oravg]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Sat Feb 24 21:59:55 2018
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root /                       xfs     defaults        0 0
UUID=2172ba19-1b4d-4d60-b8aa-3d02817f9f95 /boot                   xfs     defaults        0 0
/dev/mapper/centos-swap swap                    swap    defaults        0 0
/dev/mapper/oravg-oralv /oracle                       xfs     defaults        0 2
[root@test oravg]# date
2020年 06月 18日 星期四 10:09:51 CST
[root@test oravg]# df -h
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   94G  2.0G   92G    3% /
devtmpfs                  32G     0   32G    0% /dev
tmpfs                     32G     0   32G    0% /dev/shm
tmpfs                     32G  8.4M   32G    1% /run
tmpfs                     32G     0   32G    0% /sys/fs/cgroup
/dev/vda1                497M  150M  348M   31% /boot
tmpfs                    6.3G     0  6.3G    0% /run/user/0
/dev/mapper/oravg-oralv  441G   33M  441G    1% /oracle
[root@test oravg]# free -g
              total        used        free      shared  buff/cache   available
Mem:             62           0          62           0           0          62
Swap:            15           0          15
[root@test oravg]# reboot
 

可参考:

https://www.cnblogs.com/nf01/articles/9849833.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值