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下一切是文件形式对应): ...
随机推荐
- Web前台学习总结
前台的技术有很多种,流行的框架也是枚不胜举,在这里我们只讨论html,css,js这些基本的技术,相信大家如果掌握了这些最基本的技术,其他的技术也就会使用了. 下面是一个案例的形式来讲解上述的技术. ...
- 手把手教你学node.js之学习使用外部模块
学习使用外部模块 目标 建立一个 lesson2 项目,在其中编写代码. 当在浏览器中访问 http://localhost:3000/?q=alsotang 时,输出 alsotang 的 md5 ...
- Java之Integer源码
1.为什么Java中1000==1000为false而100==100为true? 这是一个挺有意思的讨论话题. 如果你运行下面的代码 Integer a = 1000, b = 1000; Syst ...
- 002-mybatis主配置文件
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE configuration PUBLIC & ...
- zw版【转发·台湾nvp系列Delphi例程】HALCON MoveRectangle
zw版[转发·台湾nvp系列Delphi例程]HALCON MoveRectangle procedure TForm1.Button1Click(Sender: TObject);var img : ...
- UnicodeDecodeError: 'ascii' codec can't decode byte 0xbb in position 51: ord
1.问题描述:一个在Django框架下使用Python编写的定时更新项目,在Windows系统下测试无误,在Linux系统下测试,报如下错误: ascii codec can't decode byt ...
- nats
NATS is a family of open source products that are tightly integrated but can be deployed independent ...
- mongodb的分片(2)
在上一片博客,详细说明了mongodb的分片搭建的详细过程:分片搭建 在这里会说一些分片的维护与操作! 在集群搭建完,我们使用了sh.status()查看分片之后的数据,如下: #连接的是mongos ...
- vs显示行号
1.工具 2.选项 3.文本编辑器 4.C\C++ 5.常规->显示行号
- JS中innerHTML和innerText,outerHTML和outerText
innerHTML 声明了元素含有的HTML文本,不包括元素本身的开始标记和结束标记 innerHTML是符合W3C标准的属性,而innerText只适用于IE浏览器(现在也适应chrome浏览器 ...