Centos挂载新硬盘

查看当前磁盘

fdisk -l

新建分区

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

The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.
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.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): e
Partition number (1-4, default 1): 1
First sector (2048-1953525167, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-1953525167, default 1953525167): 
Using default value 1953525167
Partition 1 of type Linux and of size 931.5 GiB is set

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

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

格式化分区

mkfs -t ext4 /dev/sdb

挂载分区

mount /dev/sdb /data1/

然后编辑 /etc/fstab 保存挂载记录,重启后配置依然在,增加下列内容

/dev/sdb /data1/ ext4 defaults 0 0

也可以使用命令 echo "/dev/sdb /data2/ ext4 defaults 0 0" >> /etc/fstab

最后 reboot 验证一下

0%