多块盘制作lvm

1 创建lvm

1.1 查看磁盘信息

# fdisk -l

Disk /dev/vda: 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 label type: dos
Disk identifier: 0x000bec39

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    83886046    41941999+  83  Linux

Disk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 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/vdc: 107.4 GB, 107374182400 bytes, 209715200 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/vdd: 107.4 GB, 107374182400 bytes, 209715200 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/vde: 107.4 GB, 107374182400 bytes, 209715200 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/vdf: 107.4 GB, 107374182400 bytes, 209715200 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

1.2 磁盘分区

# fdisk /dev/vdb
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 0x3508325a.

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): 1
First sector (2048-209715199, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): 
Using default value 209715199
Partition 1 of type Linux and of size 100 GiB is set
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): w
The partition table has been altered!

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

1.3 创建pv

# pvcreate /dev/vdb1
  WARNING: Failed to connect to lvmetad. Falling back to device scanning.
  Physical volume "/dev/vdb1" successfully created.
# pvdisplay
  WARNING: Failed to connect to lvmetad. Falling back to device scanning.
  "/dev/vdb1" is a new physical volume of "<100.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/vdb1
  VG Name               
  PV Size               <100.00 GiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               EyU8pt-wnxd-BdXA-vZYw-puO6-QeRK-UDVcCV

1.4 创建vg

# vgcreate data_ob1 /dev/vdb1
  WARNING: Failed to connect to lvmetad. Falling back to device scanning.
  Volume group "data_ob1" successfully created

1.5 创建逻辑卷

# lvcreate -l 100%free -n binlog data_ob1
  WARNING: Failed to connect to lvmetad. Falling back to device scanning.
  Logical volume "binlog" created.

1.6 格式化

# mkfs.ext4 /dev/data_ob1/binlog
mke2fs 1.43.5 (04-Aug-2017)
Creating filesystem with 26213376 4k blocks and 6553600 inodes
Filesystem UUID: 4eb2b962-9bf8-4f20-a030-0964f677c91f
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (131072 blocks): done
Writing superblocks and filesystem accounting information: done   

1.7 挂载

# echo "/dev/mapper/data_ob1-binlog /home ext4 defaults 0 0" > /etc/fstab 
# mount -a

1.8 验证

# df -h
Filesystem                   Size  Used Avail Use% Mounted on
devtmpfs                      62G     0   62G   0% /dev
tmpfs                         62G     0   62G   0% /dev/shm
tmpfs                         62G  620K   62G   1% /run
tmpfs                         62G     0   62G   0% /sys/fs/cgroup
/dev/vda1                     40G  2.8G   35G   8% /
tmpfs                         13G     0   13G   0% /run/user/0
/dev/mapper/data_ob1-binlog   98G   61M   93G   1% /home

2 lvm扩容

2.1 扩容vg

# vgextend data_ob1 /dev/vdc
  WARNING: Failed to connect to lvmetad. Falling back to device scanning.
  Physical volume "/dev/vdc" successfully created.
  Volume group "data_ob1" successfully extended

2.2 逻辑卷扩容

# lvextend /dev/data_ob1/binlog /dev/vdc
  WARNING: Failed to connect to lvmetad. Falling back to device scanning.
  Size of logical volume data_ob1/binlog changed from <100.00 GiB (25599 extents) to 199.99 GiB (51198 extents).
  Logical volume data_ob1/binlog successfully resized.

2.3 文件系统扩容

# resize2fs /dev/data_ob1/binlog
resize2fs 1.43.5 (04-Aug-2017)
Filesystem at /dev/data_ob1/binlog is mounted on /home; on-line resizing required
old_desc_blocks = 13, new_desc_blocks = 25
The filesystem on /dev/data_ob1/binlog is now 52426752 (4k) blocks long.

2.4 验证

# df -h
Filesystem                   Size  Used Avail Use% Mounted on
devtmpfs                      62G     0   62G   0% /dev
tmpfs                         62G     0   62G   0% /dev/shm
tmpfs                         62G  620K   62G   1% /run
tmpfs                         62G     0   62G   0% /sys/fs/cgroup
/dev/vda1                     40G  2.8G   35G   8% /
tmpfs                         13G     0   13G   0% /run/user/0
/dev/mapper/data_ob1-binlog  197G   60M  188G   1% /home

猜你喜欢

转载自blog.csdn.net/ygq13572549874/article/details/130829678