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下一切是文件形式对应): ...
随机推荐
- WebDriver API 实例详解(四)
三十一.使用页面的文字内容识别和处理新弹出的浏览器窗口 被测试网页的HTML源码: <html> <head> <meta charset="UTF-8&quo ...
- Scrapy:学习笔记(1)——XPath
Scrapy:学习笔记(1)——XPath 1.快速开始 XPath是一种可以快速在HTML文档中选择并抽取元素.属性和文本的方法. 在Chrome,打开开发者工具,可以使用$x工具函数来使用XPat ...
- 常用DOS命令总结
本文主要参考:http://www.jb51.net/article/12360.htm http://blog.csdn.net/kofterry/article/details/5183110 常 ...
- C#——文件上传(一般处理程序ashx)
Framework版本:.Net Framework 4 1.FileInfo实体 using System; using System.Collections.Generic; using Syst ...
- Golang 中的指针 - Pointer
http://www.cnblogs.com/jasonxuli/p/6802289.html Go 的原生数据类型可以分为基本类型和高级类型,基本类型主要包含 string, bool, int ...
- 配置zbar识别二维码(转载)
原文地址:http://blog.csdn.net/dcrmg/article/details/52108258 二维码解码器Zbar+VS2012开发环境配置 Zbar条码解码器是一个开源的二维码 ...
- RocEDU.阅读.写作《苏菲的世界》书摘(七)
* 康德认为"事物本身"和"我眼中的事物"是不一样的.这点很重要.我们永远无法确知事物"本来"的面貌.我们所知道的只是我们眼中"看 ...
- ubuntu18.04下搭建深度学习环境anaconda2+ cuda9.0+cudnn7.0.5+tensorflow1.7【原创】【学习笔记】
PC:ubuntu18.04.i5.七彩虹GTX1060显卡.固态硬盘.机械硬盘 作者:庄泽彬(欢迎转载,请注明作者) 说明:记录在ubuntu18.04环境下搭建深度学习的环境,之前安装了cuda9 ...
- 【日志】修改redis日志路径
redis默认不记录log文件,需要在Redis.conf文件,找到loglevel notice,在其后的logfile "",双引号中,写redis的路径"/redi ...
- nginx第三方模块安装方法
nginx第三方模块安装方法 ./configure --prefix=/你的安装目录 --add-module=/第三方模块目录 比如echo模块. 没安装前,使用测试. location /tes ...