linux 硬盘格式化工具 的使用
公司新到了两台服务器,系统都已经装好了,但有个RAID没有挂载使用,所以有了这篇文章。

查看现在的磁盘使用状况
首先 df -Th 先查看一下现在的目录挂载情况,已经文件系统的类型。

[root@xxx ~]# df -Th
Filesystem              Type      Size  Used Avail Use% Mounted on
/dev/mapper/centos-root xfs       1.1T   16G  1.1T   2% /
devtmpfs                devtmpfs   32G     0   32G   0% /dev
tmpfs                   tmpfs      32G     0   32G   0% /dev/shm
tmpfs                   tmpfs      32G  9.1M   32G   1% /run
tmpfs                   tmpfs      32G     0   32G   0% /sys/fs/cgroup
/dev/sda1               xfs       197M  157M   41M  80% /boot
tmpfs                   tmpfs     6.3G     0  6.3G   0% /run/user/0

因为使用了 LVM 所以 单独给 /boot 分配了 200MB,主目录挂载的对象显示为/dev/mapper/centos-root。而且文件系统为 xfs 。

使用 fdisk -l 查看磁盘的使用情况。

[root@xxx~]# fdisk -l

Disk /dev/sda: 1199.2 GB, 1199168290816 bytes, 2342125568 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: 0x00044d27

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      411647      204800   83  Linux
/dev/sda2          411648  2342125567  1170856960   8e  Linux LVM

Disk /dev/sdb: 8000.5 GB, 8000450330624 bytes, 15625879552 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 /dev/mapper/centos-root: 1130.2 GB, 1130239098880 bytes, 2207498240 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 /dev/mapper/centos-swap: 68.7 GB, 68715282432 bytes, 134209536 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

可以看到 第一块磁盘大小为 1.2TB,分了两个区。 第二块磁盘为8TB,还未使用,剩下的是 虚拟磁盘的相关的信息。

格式化硬盘创建分区
使用 fdisk 命令
最初我使用了 fdisk 命令格式化硬盘: fdisk /dev/sdb 然后一系列的交互命令。n > p > 」> 」> 」 > w。

[root@xxx~]# fdisk /dev/sdb 
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.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x867a48ad.

WARNING: The size of this disk is 8.0 TB (8000450330624 bytes).
DOS partition table format can not be used on drives for volumes
larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID 
partition table format (GPT).

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): 
First sector (2048-4294967295, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-4294967294, default 4294967294): 
Using default value 4294967294
Partition 1 of type Linux and of size 2 TiB is set

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

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

然后发现 这一个分区并没有使用全部磁盘空间。只有2TB。 然后才注意到fdisk 是 MBR 分区工具 
他的提示里有如下信息

WARNING: The size of this disk is 8.0 TB (8000450330624 bytes). 
DOS partition table format can not be used on drives for volumes 
larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID 
partition table format (GPT).

使用 parted 命令
所以 改用 parted 重新分区。 
parted /dev/sdb, 依旧是交互模式。 
mklabel gpt > mkpart > primary > xfs > 0 > -1

[root@xxx~]# parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel GPT
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes                                                               
(parted) p                                                                
Model: LSI MR9361-8i (scsi)
Disk /dev/sdb: 8000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start  End  Size  File system  Name  Flags

(parted) mkpart 
Partition name?  []? primary                                              
File system type?  [ext2]? xfs                                            
Start?                                                                    
Start? 0                                                                  
End? -1                                                                   
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? Ignore 
(parted) p                                                                
Model: LSI MR9361-8i (scsi)
Disk /dev/sdb: 8000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name     Flags
 1      17.4kB  8000GB  8000GB               primary
 
其中 创建分区表时 提示会丢失数据,需要输入 yes 确认, 以及分区时 提示未对齐, 选择 ignore 忽略。 
在交互模式中 p /print 会输出硬盘的信息。

格式化文件系统以及挂载。
格式化文件系统
mkfs.xfs /dev/sdb1

挂载
mount /dev/sdb1 /mnt/

linux 硬盘格式化工具 的使用相关推荐

  1. 六个方法查看linux硬盘使用状况

    六个方法查看linux硬盘使用状况 来源:考试大 [考试大,有你,也有我!] 2011年1月27日 一.sfdisk -l [root@localhost ~]# sfdisk -l Disk /de ...

  2. linux安装后硬盘变小,Linux硬盘安装步骤

    Linux硬盘安装步骤 网上找了许多用DVD镜像硬盘安装FC5的文章,可是都不系统,为了全中国的广大菜鸟们,兄弟连Linux云计算架构师 抽了很多时间来写这篇详细的安装文章,希望对初次接触LINUX或 ...

  3. Hyper-v3.0里无法压缩虚拟硬盘!虚拟机为Linux,硬盘为VHDX

    Hyper-v3.0里无法压缩虚拟硬盘!虚拟机为Linux,硬盘为VHDX http://www.360doc.com/content/14/0918/12/21412_410407906.shtml ...

  4. VMware 下扩展linux硬盘空间

    linux下扩展硬盘有非常多种方式,在扩展之前.尽量看看自己的空间存在的有哪些盘,然后再进行扩展. 假设是扩展的话,磁盘的符号和已经有的符号一样,比方都是sda的设备,知识分区不同.可能是sda3 s ...

  5. 详细介绍Linux硬盘挂载步骤

    [导读] Linux硬盘挂载是在Linux系统上使用外来硬盘的解决方法,这里将一步步介绍先查看目前机器上有几块硬盘.对要挂载的硬盘创建磁盘分区.对要挂载的分区进行格式化.挂载分区,这里介绍Linux硬 ...

  6. Linux学习笔记之——Linux硬盘分区知识

    搭建Linux环境之前,有必要对Linux的硬盘分区知识有所了解.本文总结Linux的硬盘分区知识. 一.关于硬盘种类.物理几何结构及硬盘容量.分区大小计算       首先了解一下硬盘本身的一些信息 ...

  7. vmware给linux增加空间,vmware增加linux硬盘空间

    vmware增加linux硬盘空间 1.vmware上右键增加一个4GB的SCSI硬盘. 2.到linux下输入fdisk -l,察看磁盘情况. 如果以前有一块硬盘,会多显示一个sdb磁盘. 3.新磁 ...

  8. VMware中linux硬盘空间不足的解决方法

    VMware中linux硬盘空间不足的解决方法 参考文章: (1)VMware中linux硬盘空间不足的解决方法 (2)https://www.cnblogs.com/hbmlml/p/5511369 ...

  9. linux iostat来对linux硬盘IO性能进行了解

    iostat来对linux硬盘IO性能进行了解  via 扶凯 by admin on 2/2/09 以前一直不太会用这个参数.现在认真研究了一下iostat,因为刚好有台重要的服务器压力高,所以放上 ...

最新文章

  1. python怎么安装jieba库-python环境jieba分词的安装
  2. Make It Connected
  3. [Qt] 解决toggled无法触发setVisible
  4. android 多态如何组件化,Android组件化之子模块之间通信方案
  5. php中file对象实例,AJAX_File, FileReader 和 Ajax 文件上传实例分析(php),File FileReader 可以干什么? Ajax - phpStudy...
  6. ijkPlayer 集成
  7. mysql 授权类型_MySQL-02-授权及数据类型
  8. Linux lamp环境验证码无法显示
  9. 高校科研信息管理系统
  10. Oracle用户密码过期策略
  11. 建立民间贷款集资合法化
  12. 词根词缀 按字母划分
  13. vue音乐添加,控制开关
  14. 使用 Node 开发一个多人对战的射击游戏
  15. ` 这个符号叫什么名字?怎么打出来?
  16. 学it需要学历吗_低学历者是否适合学IT?IT行业对学历要求高吗
  17. 百度地图查看导航记录,导航路线,记录驾驶路线
  18. 个人HTML期末大作业~ 个人网页(HTML+CSS)6页面带下拉特效~简单带表格带设计说明 ~学生网页设计作业源码
  19. 异常解决:java.lang.IllegalStateException: Failed to introspect Class
  20. learn more ,study less(一):整体性学习策略

热门文章

  1. Toad 所有 菜单说明(太多)
  2. 如何将多个PDF文件合并为一个PDF,4种工具推荐,适用手机和PC
  3. 海淘手表Invicta8926OB到手~晒图
  4. 物联网云平台应用于水产养殖
  5. 代表 YGG 的 Illuvium 首席游戏大使 —— Zom
  6. WEMOS D1 R1/R2 [ESP8266] + PCA9685 驱动舵机
  7. 文件恢复 文件改名后如何恢复原来名称分享操作步骤
  8. Spring Boot AOP面向切面编程使用(定义切入点、前置通知、后置通知、返回通知、异常通知、环绕通知)
  9. 深入浅出工控机加固的那点事
  10. MySQL默认字符集设置