Linux磁盘扩容LVM

在安装系统的时候我选择的是自动分区,系统就会自动以LVM的方式分区。为了保证系统后期的可用性,建议所有新系统安装都采用LVM。

LVM结构图 
lvm结构图

扩容步骤 
1. 查看磁盘设备 
命令:# fdisk -l 
结果:

Disk /dev/sda: 697.9 GB, 697932185600 bytes
255 heads, 63 sectors/track, 84852 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: 0x00054716

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64       39163   314059776   8e  Linux LVM
  • 找到需要扩展的磁盘设备

2.使用fdisk /dev/sda 对磁盘进行分区 
命令:# fdisk /dev/sda 
结果:

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n
Command action
   e   extended
   p   primary partit

   p
Partition number (1-4): 3
First cylinder (39163-84852, default 39163): 
Using default value 39163
Last cylinder, +cylinders or +size{K,M,G} (39163-84852, default 84852): 
Using default value 84852

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.
  • 依次输入n,p, 3(分区号,根据实际情况配置),enter,enter ,最后按w保存 

之前最大分区号 
之前最大的分区号是2,所以将本分区号设置为3,本人理解。

3.使用fdisk -l查看分区是否创建成功 
命令: fdisk -l 
结果: 
本结果应该是有3个分区才正确,这里不给出结果内容

4.重启机器 
命令:# reboot 
因为只有重启后,才能正式生效。

5.格式化分区

[root@localhost ~]# ls -l /sbin/mkfs.*

-rwxr-xr-x. 1 root root 375240 Aug  7  2017 /sbin/mkfs.btrfs
-rwxr-xr-x. 1 root root  36984 Dec  2 07:28 /sbin/mkfs.cramfs
-rwxr-xr-x. 4 root root  96296 Aug  3  2017 /sbin/mkfs.ext2
-rwxr-xr-x. 4 root root  96296 Aug  3  2017 /sbin/mkfs.ext3
-rwxr-xr-x. 4 root root  96296 Aug  3  2017 /sbin/mkfs.ext4
-rwxr-xr-x. 1 root root  37104 Dec  2 07:28 /sbin/mkfs.minix
-rwxr-xr-x. 1 root root 368464 Aug  4  2017 /sbin/mkfs.xfs

[root@localhost ~]# mkfs.xfs /dev/sdb1

6.挂载分区 mount /dev/sdb1 /data

7.加入自启动 vi /etc/fstab

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值