文档中心 > 云服务器 ECS

云服务器 ECS Linux 服务器判断磁盘分区格式化

更新时间: 访问次数:1888

问题说明


云服务器 ECS Linux 在挂载磁盘或者分区之前,需要对磁盘获取分区进行格式化。如果没有格式化,进行挂载会报错:

  
  
  1. mount /dev/xvdc /mnt/
  2. mount: you must specify the filesystem type

处理办法


如果磁盘或者分区已经格式化,那么会生成文件系统,否则不会生成文件系统。所以,使用可以查看磁盘或者分区是否有文件系统来判断是否格式化。

比如:

  
  
  1. [root@xxxxx ~]# fdisk -l
  2. Disk /dev/xvda: 21.5 GB, 21474836480 bytes
  3. 255 heads, 63 sectors/track, 2610 cylinders
  4. Units = cylinders of 16065 * 512 = 8225280 bytes
  5. Sector size (logical/physical): 512 bytes / 512 bytes
  6. I/O size (minimum/optimal): 512 bytes / 512 bytes
  7. Disk identifier: 0x00078f9c
  8. Device Boot Start End Blocks Id System
  9. /dev/xvda1 * 1 2611 20970496 83 Linux
  10. Disk /dev/xvdb: 10.7 GB, 10737418240 bytes
  11. 255 heads, 63 sectors/track, 1305 cylinders
  12. Units = cylinders of 16065 * 512 = 8225280 bytes
  13. Sector size (logical/physical): 512 bytes / 512 bytes
  14. I/O size (minimum/optimal): 512 bytes / 512 bytes
  15. Disk identifier: 0x00000000
  16. [root@xxxxx ~]# parted /dev/xvdb
  17. GNU Parted 2.1
  18. Using /dev/xvdb
  19. Welcome to GNU Parted! Type 'help' to view a list of commands.
  20. (parted) p
  21. Error: /dev/xvdb: unrecognised disk label
  22. (parted)

可以看到 /dev/xvdb 这个磁盘没有分区。如果使用 fdisk /dev/xvdb 进行分区,格式化 /dev/xvdb1 后,是可以看到具体的文件系统为 ext3。

  
  
  1. [root@xxxxx ~]# parted /dev/xvdb1
  2. GNU Parted 2.1
  3. Using /dev/xvdb1
  4. Welcome to GNU Parted! Type 'help' to view a list of commands.
  5. (parted) p
  6. Model: Unknown (unknown)
  7. Disk /dev/xvdb1: 5379MB
  8. Sector size (logical/physical): 512B/512B
  9. Partition Table: loop
  10. Number Start End Size File system Flags
  11. 1 0.00B 5379MB 5379MB ext3

 

如果问题还未能解决,您可以到阿里云社区进行免费咨询,或联系云市场商家寻求帮助。

 

FAQ

关于此文档暂时还没有FAQ
返回
顶部