linux磁盘分区格式化-fdisk命令工具
本文主要讲述使用fdisk工具对磁盘进行分区和格式化的方法
首先要明确分区是针对磁盘进行的操做,磁盘分区会创建分区表,类似vda,sda的是磁盘,vda1,sda1的是分区
1.查看磁盘分区状态
1.1. 查看分区挂载情况
df -h
1.2.查看服务器挂载的磁盘
fdisk -l
fdisk -l /dev/vdb
2.磁盘分区
2.1.对vdb磁盘进行分区
fdisk /dev/vdb
进入交互式的分区界面,以下是分区操作步骤
m打印菜单
n新建分区
p选择主分区
e选择扩展分区
1选择分区号
选择初始位置,默认为1
选择结束为止,默认为磁盘结尾
分区创建完成,可以列表查看,保存退出
p打印分区表
w写入分区表保存
q退出
2.2.重新载入磁盘分区信息
无返回就是载入磁盘信息成功,针对磁盘进行操作
partprobe /dev/vdb
注意:
使用fdisk工具只是将分区信息写到磁盘,
在格式化分区值前需要使用partprobe让kernel重新读取分区信息,如果不成功则需要重启系统
2.3.对磁盘分区进行格式化
使用ext4文件系统
mkfs.ext4 /dev/vdb1
2.4.格式化完成后续优化配置,取消磁盘自检
tune2fs -c - /dev/vdb1
3.分区挂载
3.1.挂载磁盘分区到指定目录
mkdir -p /data
mount /dev/vdb1 /data
3.2.配置开机自动挂载分区
/etc/fstab 增加一行
vim /etc/fstab
-------------------------------------------------------
/dev/vdb1 /data ext4 defaults
-------------------------------------------------------
5.实例演示:使用Ubuntu系统进行磁盘分区操作
5.1.查看磁盘分区信息
root@zstest:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev .9G .9G % /dev
tmpfs .6G 3.2M .6G % /run
/dev/vda1 50G .7G 41G % /
tmpfs .9G .9G % /dev/shm
tmpfs 5.0M 5.0M % /run/lock
tmpfs .9G .9G % /sys/fs/cgroup
tmpfs .6G .6G % /run/user/
5.2.列表查看磁盘信息
root@zstest:~# fdisk -l
Disk /dev/vda: GiB, bytes, sectors
Units: sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disklabel type: dos
Disk identifier: 0xd6804155 Device Boot Start End Sectors Size Id Type
/dev/vda1 * 50G Linux Disk /dev/vdb: GiB, bytes, sectors
Units: sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
5.3.对磁盘vdb进行分区
root@zstest:~# fdisk /dev/vdb Welcome to fdisk (util-linux 2.27.).
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.
Created a new DOS disklabel with disk identifier 0x63c3e6e0. Command (m for help): n
Partition type
p primary ( primary, extended, free)
e extended (container for logical partitions)
Select (default p): p
Partition number (-, default ):
First sector (-, default ):
Last sector, +sectors or +size{K,M,G,T,P} (-, default ): Created a new partition of type 'Linux' and of size GiB. Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
5.4.查看分区信息
root@zstest:~# fdisk -l
Disk /dev/vda: GiB, bytes, sectors
Units: sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disklabel type: dos
Disk identifier: 0xd6804155 Device Boot Start End Sectors Size Id Type
/dev/vda1 * 50G Linux Disk /dev/vdb: GiB, bytes, sectors
Units: sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disklabel type: dos
Disk identifier: 0x63c3e6e0 Device Boot Start End Sectors Size Id Type
/dev/vdb1 50G Linux
5.5.重新载入磁盘分区信息
root@zstest:~# partprobe /dev/vdb
5.6.对指定磁盘分区进行格式化,使用ext4文件系统
root@zstest:~# mkfs.ext4 /dev/vdb1
mke2fs 1.42. (-May-)
Creating filesystem with 4k blocks and inodes
Filesystem UUID: 047fb8b0-e6ed-42db-bf5c-2a6d388fc34d
Superblock backups stored on blocks:
, , , , , , , , ,
, , Allocating group tables: done
Writing inode tables: done
Creating journal ( blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every mounts or
days, whichever comes first. Use tune2fs -c or -i to override.
5.7.根据提示进行操作,取消磁盘自检
root@zstest:~# tune2fs -c - /dev/vdb1
tune2fs 1.42. (-May-)
Setting maximal mount count to -
5.8.挂载分区到指定目录
mkdir -p /data
mount /dev/vdb1 /data
5.9.配置开机自动挂载分区
vim /etc/fstab
-------------------------------------------------------
# made by tssc
/dev/vdb1 /data ext4 defaults
-------------------------------------------------------
完毕,呵呵呵呵
linux磁盘分区格式化-fdisk命令工具的更多相关文章
- 【linux磁盘分区--格式化】fdisk,parted,mkfs.ext3
磁盘分区完成后,一般就需要对分区进行格式化 磁盘分区命令主要有两个: fdisk :最大支持不超过2T分区: parted :支持GPT,适用于大容量分区: 分区指令的选择: 在RHEL系统上,用fd ...
- Linux磁盘分区/格式化/挂载(树莓派3挂载硬盘)
[前言] 本文将要讲解的功能为Linux环境下对磁盘进行操作.包括分区.格式化.挂载外接移动存储设备等. 该文的写作背景为本人的树莓派需要外接一个固态硬盘作为存储设备,因此,便开始了一系列的折腾. [ ...
- Linux磁盘分区格式化和扩容
Note:根据各系统上磁盘的类型不同,磁盘命名规则也会不同:例如/dev/xvd,/dev/sd,/dev/vd,/dev/hd 目录 磁盘格式化 MBR格式 GPT分区 磁盘扩容 MBR格式扩容 G ...
- linux硬盘分区和fdisk命令
分区的几个概念 硬盘分区有三种,主分区.扩展分区.逻辑分区.一个硬盘主分区至少有1个,最多4个,扩展分区可以没有,最多1个.且主分区+扩展分区总共不能超过4个.逻辑分区可以有若干个.在windows下 ...
- Linux磁盘分区/格式化/挂载目录
分区及挂载目录 以CentOS7.2为例,一般我们服务端应用部署前需要确认部署机的磁盘空间及挂载目录.操作如下: 如上图,如果操作系统是新装的,未挂盘的话需要先挂载盘.操作如下: fdisk -l # ...
- Linux基础------文件打包解包---tar命令,文件压缩解压---命令gzip,vim编辑器创建和编辑正文件,磁盘分区/格式化,软/硬链接
作业一:1) 将用户信息数据库文件和组信息数据库文件纵向合并为一个文件/1.txt(覆盖) cat /etc/passwd /etc/group > /1.txt2) 将用户信息数据库文件和用户 ...
- Linux磁盘分区(一)之fdisk命令
Linux磁盘分区(一)之fdisk命令转自:https://www.cnblogs.com/machangwei-8/p/10353683.html 一.fdisk 的介绍fdsik 能划分磁盘成为 ...
- Linux fdisk命令参数及用法详解---Linux磁盘分区管理命令fdisk
fdisk 命令 linux磁盘分区管理 用途:观察硬盘之实体使用情形与分割硬盘用. 使用方法: 一.在 console 上输入 fdisk -l /dev/sda ,观察硬盘之实体使用情形. 二.在 ...
- Linux磁盘分区fdisk命令操作(简洁版)
实例(环境为: CentOS Linux release 7.2.1511 (Core), 3.10.0-327.el7.x86_64) 选择要具体操作的第二块磁盘(linux下一切是文件形式对应): ...
随机推荐
- Spark SQL与Hive on Spark的比较
简要介绍了SparkSQL与Hive on Spark的区别与联系 一.关于Spark 简介 在Hadoop的整个生态系统中,Spark和MapReduce在同一个层级,即主要解决分布式计算框架的问题 ...
- CentOS 7 集群使用NTP进行时间同步
NTP时钟同步方式说明NTP在linux下有两种时钟同步方式,分别为直接同步和平滑同步: 直接同步 使用ntpdate命令进行同步,直接进行时间变更.如果服务器上存在一个12点运行的任务,当前服务器时 ...
- java 反射 (一)
原文地址https://www.zhihu.com/question/24304289 首先我们了解一下JVM,什么是JVM,Java的虚拟机,java之所以能跨平台就是因为这个东西,你可以理解成 ...
- 安装完C++builder6.0启动的时候总是出现无法将'C:\Program Files\Borland\CBuilder6\Bin\bcb.$$$'重命名为bcb.dro
:兼容性问题 运行前右键属性“兼容性”-尝试不同的兼容性.比如“windows 8”
- HTML&CSS&Javascript脑图
今天看了极客学院的CSS3部分,加上前几天看过的HTML5部分,现在对HTML和CSS的基础有了系统的认识,正好发现这张图,简直Perfect! 感谢脑图的制作人,虽然不知道是谁,但能把HTML.CS ...
- 已有模板与tp框架的结合 (前台)
已有模板与tp框架的结合 具体步骤 A.复制模板文件到view指定目录 B. 复合css .js.img.静态资源文件到系统指定目录 C. 把静态资源(css,js,img)文件的路径设置为“常量 ...
- 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred) Solution
A. Find a Number Solved By 2017212212083 题意:$找一个最小的n使得n % d == 0 并且 n 的每一位数字加起来之和为s$ 思路: 定义一个二元组$< ...
- jquery实现ajax跨域请求
1.跨域问题: 是因为浏览器的同源策略是对ajax请求进行阻拦了,但是不是所有的请求都给做跨域,像是一般的href属性,a标签什么的都不拦截. 如: 项目一:p1.html <body> ...
- HDU 6315 Naive Operations(线段树+区间维护)多校题解
题意:a数组初始全为0,b数组题目给你,有两种操作: 思路:dls的思路很妙啊,我们可以将a初始化为b,加一操作改为减一,然后我们维护一个最小值,一旦最小值为0,说明至少有一个ai > bi,那 ...
- IDEA上面如何添加创建的文件类型
首先在IDEA --> new 一个文件的时候 以 创建vue文件为例子,来添加vue文件类型文件 选项 edit file templates 添加 这样就OK了 转载需注明出处,谢谢! au ...