查看新增磁盘


在服务器上新加一块10G大小的磁盘

[root@centos002 ~]# fdisk -l

....................................................

Disk /dev/sdb: 10.7 GB, 10737418240 bytes

255 heads, 63 sectors/track, 1305 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

创建分区与格式化

#新建分区

[root@centos002 ~]# fdisk /dev/sdb

Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-1305, default 1): 

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305): 

Using default value 1305

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

#格式化分区

[root@centos002 ~]# mkfs.ext4 /dev/sdb1

mke2fs 1.41.12 (17-May-2010)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

655360 inodes, 2620595 blocks

131029 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=2684354560

80 block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks: 

32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: done                            

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 26 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

将新分区更改成支持LVM格式

[root@centos002 ~]# fdisk /dev/sdb

Command (m for help): p

Disk /dev/sdb: 10.7 GB, 10737418240 bytes

255 heads, 63 sectors/track, 1305 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: 0x3ec1c9a6

Device Boot  Start  End   Blocks   Id  System

/dev/sdb1    1   1305   10482381   83  Linux

Command (m for help): t

Selected partition 1

Hex code (type L to list codes): 8e

Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

#查看更改后的分区格式

查看VG

[root@centos002 ~]# vgdisplay

  --- Volume group ---

  VG Name         vg_centos002

  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        19.51 GiB

  PE Size        4.00 MiB

  Total PE        4994

  Alloc PE / Size    4994 / 19.51 GiB

  Free  PE / Size    0 / 0   

  VG UUID    ugeSA9-XCNj-M5XK-Gz4d-DxoR-7TSv-X9Pq6O

创建PV并查看

[root@centos002 ~]# pvcreate /dev/sdb1

  Physical volume "/dev/sdb1" successfully created

[root@centos002 ~]# pvdisplay

  --- Physical volume ---

  PV Name        /dev/sda2

  VG Name        vg_centos002

  PV Size        19.51 GiB / not usable 3.00 MiB

  Allocatable     yes (but full)

  PE Size        4.00 MiB

  Total PE       4994

  Free PE        0

  Allocated PE    4994

  PV UUID  Z7AOVb-LEzI-su15-J5lC-alj8-a94k-1NmRRv

   

  "/dev/sdb1" is a new physical volume of "10.00 GiB"

  --- NEW Physical volume ---

  PV Name       /dev/sdb1

  VG Name               

  PV Size       0.00 GiB

  Allocatable     NO

  PE Size        0   

  Total PE        0

  Free PE        0

  Allocated PE     0

  PV UUID      4N37pw-Q59f-FRZE-glEx-lRWh-BY5O-Zk9JrF

查看LV

[root@centos002 ~]# lvdisplay 

  --- Logical volume ---

  LV Path              /dev/vg_centos002/lv_root

  LV Name              lv_root

  VG Name              vg_centos002

  LV UUID              2G4f2m-gkIR-xXG0-MCfO-jFO2-jYNC-IBKYqL

  LV Write Access        read/write

  LV Creation host, time centos002, 2017-08-21 13:15:29 +0800

  LV Status            available

  # open              1

  LV Size             17.57 GiB

  Current LE           4498

  Segments            1

  Allocation           inherit

  Read ahead sectors      auto

  - currently set to      256

  Block device          253:0

   

  --- Logical volume ---

  LV Path      /dev/vg_centos002/lv_swap

  LV Name      lv_swap

  VG Name      vg_centos002

  LV UUID    ITJYHF-bGpM-z314-lW1B-q8gj-8tgl-8NZ4bM

  LV Write Access    read/write

  LV Creation host, time centos002, 2017-08-21 13:15:34 +0800

  LV Status     available

  # open       1

  LV Size      1.94 GiB

  Current LE    496

  Segments      1

  Allocation    inherit

  Read ahead sectors  auto

  - currently set to  256

  Block device      253:1

扩展卷组VG

[root@centos002 ~]# vgextend vg_centos002 /dev/sdb1

  Volume group "vg_centos002" successfully extended

[root@centos002 ~]# vgdisplay

  --- Volume group ---

  VG Name        vg_centos002

  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          29.50 GiB

  PE Size          4.00 MiB

  Total PE          7552

  Alloc PE / Size    4994 / 19.51 GiB

  Free  PE / Size     2558 / 9.99 GiB

  VG UUID    ugeSA9-XCNj-M5XK-Gz4d-DxoR-7TSv-X9Pq6O

#此时查看磁盘大小并没有增加

[root@centos002 ~]# df -h

Filesystem   Size  Used Avail Use% Mounted on

/dev/mapper/vg_centos002-lv_root

          18G  803M   16G   5% /

tmpfs       238M     0  238M   0% /dev/shm

/dev/sda1     77M   28M  425M   7% /boot

扩展逻辑卷LVM

#扩展LVM分区大小

[root@centos002 ~]# lvextend -L 28G /dev/vg_centos002/lv_root

  Insufficient free space: 2670 extents needed, but only 2558 available

  #报错说明扩容的空间不足,需要调整值

[root@centos002 ~]# lvextend -L 27G /dev/vg_centos002/lv_root

  Size of logical volume vg_centos002/lv_root changed from 17.57 GiB (4498 extents) to 27.00 GiB (6912 extents).

  Logical volume lv_root successfully resized.

重设分区大小

#重设根分区大小

[root@centos002 ~]# resize2fs /dev/vg_centos002/lv_root

resize2fs 1.41.12 (17-May-2010)

Filesystem at /dev/vg_centos002/lv_root is mounted on /; on-line resizing required

old desc_blocks = 2, new_desc_blocks = 2

Performing an on-line resize of /dev/vg_centos002/lv_root to 7077888 (4k) blocks.

The filesystem on /dev/vg_centos002/lv_root is now 7077888 blocks long.




©著作权归作者所有:来自51CTO博客作者mob604756ef35df的原创作品,如需转载,请注明出处,否则将追究法律责任

更多相关文章

  1. Linux企业生产常见问题集合(一)答案
  2. Linux运维必会的100道MySql面试题之(一)
  3. chrome查看网站字符集编码的方法(不需要安装charset)
  4. 分区出现“属性0字节”情况下的文件找回办法
  5. 监控系统项目实施--安装与部署-PG数据库监控配置-libzbxpgsql部
  6. Linux下查看进程线程数的方法
  7. 为Dynamics CRM的Office附件注释定制个无需下载即可在线查看的功
  8. Linux下增加2G的交换分区
  9. 服务器中watchdog挖矿病毒排查方法

随机推荐

  1. 3: Zabbix5.0自动发现磁盘目录监控
  2. 这应该是堪称完美的“Android Framework
  3. telnet登录Linux上报Login incorrect
  4. Java锁机制了解一下
  5. 使用docker compose 安装zookeeper、kafk
  6. 文章目录导航
  7. Android(安卓)-- Vold机制简要分析
  8. Thread源码剖析
  9. ConcurrentHashMap基于JDK1.8源码剖析
  10. 四种常量的解释