磁盘挂载与扩容

普通挂载磁盘扩容

  1. 查看当前磁盘情况 df -Thl

    [root@iz5bg05ape183r0ipx22lrz ~]# df -Thl
    Filesystem Type Size Used Avail Use% Mounted on
    /dev/vda1 ext4 40G 16G 22G 42% /
    devtmpfs devtmpfs 3.9G 0 3.9G 0% /dev
    tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm
    tmpfs tmpfs 3.9G 580K 3.9G 1% /run
    tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
    tmpfs tmpfs 783M 0 783M 0% /run/user/1001
    tmpfs tmpfs 783M 0 783M 0% /run/user/0
  2. fdisk -l

vda的文件系统时Linux (Id:83)而不是Linux LVM(Id: 8e)

[root@iz5bg05ape183r0ipx22lrz ~]# 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: 0x0008d73a

Device Boot Start End Blocks Id System
/dev/vda1 * 2048 83884031 41940992 83 Linux

Disk /dev/vdb: 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: 0x6372be6d

Device Boot Start End Blocks Id System
/dev/vdb1 2048 1048575999 524286976 83 Linux
[root@iz5bg05ape183r0ipx22lrz ~]#
  1. 挂载磁盘

fdisk /dev/vdb1
{n, p, size, type, w}
mkfs.ext4 /dev/vdb1
mount /dev/vdb1 /data

  1. 验证挂载
[root@iz5bg05ape183r0ipx22lrz data]# df -Thl
Filesystem Type Size Used Avail Use% Mounted on
/dev/vda1 ext4 40G 16G 22G 42% /
devtmpfs devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs tmpfs 3.9G 584K 3.9G 1% /run
tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
tmpfs tmpfs 783M 0 783M 0% /run/user/1001
tmpfs tmpfs 783M 0 783M 0% /run/user/0
/dev/vdb1 ext4 493G 73M 467G 1% /data
  1. 开机自动挂载
[root@iz5bg05ape183r0ipx22lrz data]# blkid
/dev/vda1: UUID="eb448abb-3012-4d8d-bcde-94434d586a31" TYPE="ext4"
/dev/vdb1: UUID="a5a8e148-8c6e-49c0-be74-dc1e61fc170f" TYPE="ext4"

vim /etc/fstab
UUID=a5a8e148-8c6e-49c0-be74-dc1e61fc170f /data ext4 defaults 0 0

要挂载的分区设备号 挂载点 文件系统类型 挂载选项 是否备份 是否检测

fdisk单次分区不能超过2T, 超过2T需要使用parted


[root@iz5bg05ape183r0ipx22lrz ~]# part
parted partprobe partx
[root@iz5bg05ape183r0ipx22lrz ~]# parted /dev/vdc
GNU Parted 3.1
Using /dev/vdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Model: Virtio Block Device (virtblk)
Disk /dev/vdc: 3221GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number Start End Size Type File system Flags

(parted) mklabel gpt
Warning: The existing disk label on /dev/vdc will be destroyed and all data on this disk will be
lost. Do you want to continue?
Yes/No? yes
(parted) mkpart
Partition name? []? vdc1
File system type? [ext2]? ext4
Start? 0
End? 3221GB
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? ignore
(parted) p
Model: Virtio Block Device (virtblk)
Disk /dev/vdc: 3221GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
1 17.4kB 3221GB 3221GB vdc1

(parted) quit
Information: You may need to update /etc/fstab.

[root@iz5bg05ape183r0ipx22lrz ~]#

格式化 vdc1 (上述parted操作也会格式化vdc1)
mkfs.ext4 /dev/vdc1

推荐文章(由hexo文章推荐插件驱动)