Linux LVM在线扩容xfs文件系统(创建大于2T的磁盘分区)

1. 使用parted方式格式化磁盘

1.1 查看磁盘情况:

[root@superman ~]# fdisk -l

Disk /dev/sdd: 2199.0 GB, 2199023255552 bytes, 4294967296 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/sdb: 42.9 GB, 42949672960 bytes, 83886080 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/sdc: 2199.0 GB, 2199023255552 bytes, 4294967296 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/sde: 2199.0 GB, 2199023255552 bytes, 4294967296 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/sdf: 2199.0 GB, 2199023255552 bytes, 4294967296 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/sda: 536.9 GB, 536870912000 bytes, 1048576000 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: 0x0008ce60

  Device Boot      Start        End      Blocks  Id  System

/dev/sda1  *        2048    2099199    1048576  83  Linux

/dev/sda2        2099200  1048567807  523234304  8e  Linux LVM

Disk /dev/mapper/vg_root-lv_root: 64.4 GB, 64424509440 bytes, 125829120 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/vg_root-lv_swap: 68.7 GB, 68719476736 bytes, 134217728 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/vg_root-lv_data: 209.4 GB, 209371267072 bytes, 408928256 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/vg_root-lv_home: 64.4 GB, 64424509440 bytes, 125829120 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/vg_root-oracle: 64.4 GB, 64424509440 bytes, 125829120 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/vg_root-lv_grid: 64.4 GB, 64424509440 bytes, 125829120 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/sdg: 2199.0 GB, 2199023255552 bytes, 4294967296 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@superman ~]#

1.2 使用parted格式化/dev/sdg分区:

[root@superman ~]# parted /dev/sdg

GNU Parted 3.1

Using /dev/sdg

Welcome to GNU Parted! Type 'help' to view a list of commands.

(parted) mklabel gpt                ------将MBR分区形式转为GPT分区形式                                               

(parted) mkpart primary xfs 0 -1    ------设置分区的开始位置和结束位置                                     

Warning: The resulting partition is not properly aligned for best performance.

Ignore/Cancel? Ignore                                                   

(parted) print                      ------查看分区                                                         

Model: VMware Virtual disk (scsi)

Disk /dev/sdg: 2199GB

Sector size (logical/physical): 512B/512B

Partition Table: gpt

Disk Flags:

Number  Start  End    Size    File system  Name    Flags

1      17.4kB  2199GB  2199GB              primary

(parted) toggle 1 lvm              ------使用toggle 更改硬盘类型                                       

(parted) print                      ------查看分区                                     

Model: VMware Virtual disk (scsi)

Disk /dev/sdg: 2199GB

Sector size (logical/physical): 512B/512B

Partition Table: gpt

Disk Flags:

Number  Start  End    Size    File system  Name    Flags

1      17.4kB  2199GB  2199GB              primary  lvm

(parted) quit                                                           

Information: You may need to update /etc/fstab.

[root@superman ~]#

1.3 查看格式化后的分区情况                                                       

[root@superman ~]# fdisk -l

Disk /dev/sdd: 2199.0 GB, 2199023255552 bytes, 4294967296 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/sdb: 42.9 GB, 42949672960 bytes, 83886080 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/sdc: 2199.0 GB, 2199023255552 bytes, 4294967296 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/sde: 2199.0 GB, 2199023255552 bytes, 4294967296 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/sdf: 2199.0 GB, 2199023255552 bytes, 4294967296 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/sda: 536.9 GB, 536870912000 bytes, 1048576000 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: 0x0008ce60

  Device Boot      Start        End      Blocks  Id  System

/dev/sda1  *        2048    2099199    1048576  83  Linux

/dev/sda2        2099200  1048567807  523234304  8e  Linux LVM

Disk /dev/mapper/vg_root-lv_root: 64.4 GB, 64424509440 bytes, 125829120 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/vg_root-lv_swap: 68.7 GB, 68719476736 bytes, 134217728 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/vg_root-lv_data: 209.4 GB, 209371267072 bytes, 408928256 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/vg_root-lv_home: 64.4 GB, 64424509440 bytes, 125829120 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/vg_root-oracle: 64.4 GB, 64424509440 bytes, 125829120 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/vg_root-lv_grid: 64.4 GB, 64424509440 bytes, 125829120 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

WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.

Disk /dev/sdg: 2199.0 GB, 2199023255552 bytes, 4294967296 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: gpt

Disk identifier: 9C5E039C-2C6C-4585-8EAB-7B2DBA949516

#        Start          End    Size  Type            Name

1          34  4294965343      2T  Linux LVM      primary

[root@superman ~]#

1.4 使系统重读分区表

[root@superman ~]# partprobe

Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only.

[root@superman ~]#

[root@superman ~]# fdisk -l

Disk /dev/sdd: 2199.0 GB, 2199023255552 bytes, 4294967296 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/sdb: 42.9 GB, 42949672960 bytes, 83886080 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/sdc: 2199.0 GB, 2199023255552 bytes, 4294967296 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/sde: 2199.0 GB, 2199023255552 bytes, 4294967296 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/sdf: 2199.0 GB, 2199023255552 bytes, 4294967296 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/sda: 536.9 GB, 536870912000 bytes, 1048576000 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: 0x0008ce60

  Device Boot      Start        End      Blocks  Id  System

/dev/sda1  *        2048    2099199    1048576  83  Linux

/dev/sda2        2099200  1048567807  523234304  8e  Linux LVM

Disk /dev/mapper/vg_root-lv_root: 64.4 GB, 64424509440 bytes, 125829120 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/vg_root-lv_swap: 68.7 GB, 68719476736 bytes, 134217728 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/vg_root-lv_data: 209.4 GB, 209371267072 bytes, 408928256 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/vg_root-lv_home: 64.4 GB, 64424509440 bytes, 125829120 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/vg_root-oracle: 64.4 GB, 64424509440 bytes, 125829120 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/vg_root-lv_grid: 64.4 GB, 64424509440 bytes, 125829120 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

WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.

Disk /dev/sdg: 2199.0 GB, 2199023255552 bytes, 4294967296 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: gpt

Disk identifier: 9C5E039C-2C6C-4585-8EAB-7B2DBA949516

#        Start          End    Size  Type            Name

1          34  4294965343      2T  Linux LVM      primary

[root@superman ~]#

2、创建pv、扩容vg、扩容lv、扩容xfs分区

2.1 查看目前分区情况

[root@superman ~]# df -h

Filesystem                  Size  Used Avail Use% Mounted on

/dev/mapper/vg_root-lv_root  60G  6.2G  54G  11% /

devtmpfs                      63G    0  63G  0% /dev

tmpfs                        63G  640M  63G  1% /dev/shm

tmpfs                        63G  32M  63G  1% /run

tmpfs                        63G    0  63G  0% /sys/fs/cgroup

/dev/sda1                  1014M  179M  836M  18% /boot

/dev/mapper/vg_root-lv_grid  60G  40G  21G  66% /grid

/dev/mapper/vg_root-lv_data  195G  595M  195G  1% /data

/dev/mapper/vg_root-oracle    60G  22G  38G  37% /oracle

/dev/mapper/vg_root-lv_home  60G  16G  45G  27% /home

tmpfs                        13G  12K  13G  1% /run/user/42

tmpfs                        13G    0  13G  0% /run/user/1000

[root@superman ~]#

2.2 查看目前lv情况

[root@superman ~]# lvs

  LV      VG      Attr      LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert

  lv_data vg_root -wi-ao---- 194.99g                                                   

  lv_grid vg_root -wi-ao----  60.00g                                                   

  lv_home vg_root -wi-ao----  60.00g                                                   

  lv_root vg_root -wi-ao----  60.00g                                                   

  lv_swap vg_root -wi-ao----  64.00g                                                   

  oracle  vg_root -wi-ao----  60.00g                                                   

[root@superman ~]#

2.3 查看目前vg情况

[root@superman ~]# vgs

  VG      #PV #LV #SN Attr  VSize  VFree

  vg_root  1  6  0 wz--n- 498.99g    0

[root@superman ~]#

2.4 创建pv

[root@superman ~]# pvcreate /dev/sdg1

  Physical volume "/dev/sdg1" successfully created.

[root@superman ~]#

2.5 扩容vg

[root@superman ~]# vgextend vg_root /dev/sdg1

  Volume group "vg_root" successfully extended

[root@superman ~]#

2.6 查看vg扩容情况

[root@superman ~]# vgs

  VG      #PV #LV #SN Attr  VSize  VFree

  vg_root  2  6  0 wz--n- <2.49t <2.00t

[root@superman ~]#

2.7 查看扩容后vg大小情况

[root@superman ~]# vgdisplay

  --- Volume group ---

  VG Name              vg_root

  System ID           

  Format                lvm2

  Metadata Areas        2

  Metadata Sequence No  8

  VG Access            read/write

  VG Status            resizable

  MAX LV                0

  Cur LV                6

  Open LV              6

  Max PV                0

  Cur PV                2

  Act PV                2

  VG Size              <2.49 TiB

  PE Size              4.00 MiB

  Total PE              652029

  Alloc PE / Size      127742 / 498.99 GiB

  Free  PE / Size      524287 / <2.00 TiB

  VG UUID              bV0qQR-Vhfg-ynTF-dbza-qJD1-ao3k-l02WiP


[root@superman ~]#

2.8 扩容lv

[root@superman ~]# lvextend -L +2097148M /dev/mapper/vg_root-lv_data

  Size of logical volume vg_root/lv_data changed from 194.99 GiB (49918 extents) to 2.19 TiB (574205 extents).

  Logical volume vg_root/lv_data successfully resized.

[root@superman ~]#

2.9 查看容量变化,发现文件系统大小没有变化

[root@superman ~]# df -h

Filesystem                  Size  Used Avail Use% Mounted on

/dev/mapper/vg_root-lv_root  60G  6.2G  54G  11% /

devtmpfs                      63G    0  63G  0% /dev

tmpfs                        63G  640M  63G  1% /dev/shm

tmpfs                        63G  32M  63G  1% /run

tmpfs                        63G    0  63G  0% /sys/fs/cgroup

/dev/sda1                  1014M  179M  836M  18% /boot

/dev/mapper/vg_root-lv_grid  60G  40G  21G  66% /grid

/dev/mapper/vg_root-lv_data  195G  595M  195G  1% /data

/dev/mapper/vg_root-oracle    60G  22G  38G  37% /oracle

/dev/mapper/vg_root-lv_home  60G  16G  45G  27% /home

tmpfs                        13G  12K  13G  1% /run/user/42

tmpfs                        13G    0  13G  0% /run/user/1000

[root@superman ~]#

2.10 使用xfs_growfs同步磁盘信息

[root@superman ~]# xfs_growfs /dev/mapper/vg_root-lv_data

meta-data=/dev/mapper/vg_root-lv_data isize=512    agcount=4, agsize=12779008 blks

        =                      sectsz=512  attr=2, projid32bit=1

        =                      crc=1        finobt=0 spinodes=0

data    =                      bsize=4096  blocks=51116032, imaxpct=25

        =                      sunit=0      swidth=0 blks

naming  =version 2              bsize=4096  ascii-ci=0 ftype=1

log      =internal              bsize=4096  blocks=24959, version=2

        =                      sectsz=512  sunit=0 blks, lazy-count=1

realtime =none                  extsz=4096  blocks=0, rtextents=0

data blocks changed from 51116032 to 587985920

[root@superman ~]#

2.11 查看容量变化,发现文件系统已扩容

[root@superman ~]# df -h

Filesystem                  Size  Used Avail Use% Mounted on

/dev/mapper/vg_root-lv_root  60G  6.2G  54G  11% /

devtmpfs                      63G    0  63G  0% /dev

tmpfs                        63G  640M  63G  1% /dev/shm

tmpfs                        63G  32M  63G  1% /run

tmpfs                        63G    0  63G  0% /sys/fs/cgroup

/dev/sda1                  1014M  179M  836M  18% /boot

/dev/mapper/vg_root-lv_grid  60G  40G  21G  66% /grid

/dev/mapper/vg_root-lv_data  2.2T  597M  2.2T  1% /data

/dev/mapper/vg_root-oracle    60G  22G  38G  37% /oracle

/dev/mapper/vg_root-lv_home  60G  16G  45G  27% /home

tmpfs                        13G  12K  13G  1% /run/user/42

tmpfs                        13G    0  13G  0% /run/user/1000

[root@superman ~]#

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,324评论 5 476
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,303评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,192评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,555评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,569评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,566评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,927评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,583评论 0 257
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,827评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,590评论 2 320
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,669评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,365评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,941评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,928评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,159评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,880评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,399评论 2 342