|  | 
 
 
上一篇:纯html5 css3实现的404页面下一篇:谷歌AMP和百度MIP知识科普| 从阿里云购买的一台centos 7系统的服务器,由于磁盘空间不够用了,重新购买了一块100G的硬盘,执行命令 
 查询不到100G的数据盘使用情况,如下图:
 
 
   
 执行“fdisk -l”命令,发现是有一块100G的硬盘的。如果执行命令后,没有发现 /dev/vdb,表示您的实例没有数据盘,无需格式化数据盘,请忽略本文后续内容。如下图:
 
 
   
 创建一个单分区数据盘
 
 依次执行以下命令:
 运行 fdisk /dev/vdb:对数据盘进行分区。
 输入 n 并按回车键:创建一个新分区。
 输入 p 并按回车键:选择主分区。因为创建的是一个单分区数据盘,所以只需要创建主分区。
 
 
 输入分区编号并按回车键。因为这里仅创建一个分区,可以输入 1
 输入第一个可用的扇区编号:按回车键采用默认值(回车即可)
 输入最后一个扇区编号:因为这里仅创建一个分区,所以按回车键采用默认值。(回车即可)
 输入 wq 并按回车键,开始分区。
 
 
 [root@xx~]# fdisk /dev/vdbWelcome 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 0x7b268fc0.
 
 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): 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): wq
 The partition table has been altered!
 
 Calling ioctl() to re-read partition table.
 Syncing disks.
 
   
 查看新的分区:运行命令 fdisk -l。如果出现以下信息,说明已经成功创建了新分区 /dev/vdb1。
 
 
 [root@xx~]# 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: 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 label type: dos
 Disk identifier: 0x7b268fc0
 
 Device Boot      Start         End      Blocks   Id  System
 /dev/vdb1            2048   209715199   104856576   83  Linux
 
 
   
 在新分区上创建一个文件系统:运行命令 mkfs.ext3 /dev/vdb1。
 本示例要创建一个 ext3 文件系统。您也可以根据自己的需要,选择创建其他文件系统,例如,如果需要在 Linux、Windows 和 Mac 系统之间共享文件,您可以使用 mkfs.vfat 创建 VFAT 文件系统。
 创建文件系统所需时间取决于数据盘大小。
 
 
 
   
 (建议)备份 etc/fstab:运行命令 cp /etc/fstab /etc/fstab.bak (可省略)
 
 向 /etc/fstab 写入新分区信息:运行命令 echo /dev/vdb1 /mnt ext3 defaults 0 0 >> /etc/fstab
 
 如果需要把数据盘单独挂载到某个文件夹,比如单独用来存放网页,请将以上命令 /mnt 替换成所需的挂载点路径。
 
 查看 /etc/fstab 中的新分区信息:运行命令 cat /etc/fstab
 
 挂载文件系统:运行命令 mount /dev/vdb1 /mnt。
 (注意:挂载mnt目录,需要先创建该文件夹!)
 
 查看目前磁盘空间和使用情况:运行命令 df -h。如果出现新建文件系统的信息,说明挂载成功,可以使用新的文件系统了。
 挂载操作完成后,不需要重启实例即可开始使用新的文件系统。
 
 
 
   
 (完)
 
 | 
 |