linux磁盘是vda,linux磁盘分区格式化-fdisk命令工具

linux磁盘是vda,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⽂件系统
<4 /dev/vdb1
2.4.格式化完成后续优化配置,取消磁盘⾃检
tune2fs -c -1 /dev/vdb1
3.分区挂载
3.1.挂载磁盘分区到指定⽬录
mkdir -p /datamount /dev/vdb1 /data
3.2.配置开机⾃动挂载分区
可持续发展的基本内涵/etc/fstab 增加⼀⾏
vim /etc/fstab-------------------------------------------------------
/dev/vdb1 /data ext4 defaults 0 0
-------------------------------------------------------
5.实例演⽰:使⽤Ubuntu系统进⾏磁盘分区操作
5.1.查看磁盘分区信息
root@zstest:~# df -h
Filesystem Size Used Avail Use%Mounted on
udev7.9G 0 7.9G 0% /dev
tmpfs1.6G 3.2M 1.6G 1% /run/dev/vda1 50G 5.7G 41G 13% /tmpfs7.9G 0 7.9G 0% /dev/shm
tmpfs5.0M 0 5.0M 0% /run/lock
tmpfs7.9G 0 7.9G 0% /sys/fs/cgroup
tmpfs1.6G 0 1.6G 0% /run/user/0
5.2.列表查看磁盘信息
root@zstest:~# fdisk -l
Disk/dev/vda: 50 GiB, 53687091200 bytes, 104857600sectors
Units: sectors of1 * 512 = 512bytes
Sector size (logical/physical): 512 bytes / 512bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disklabel type: dos沈阳医学院学报
Disk identifier:0xd6804155Device Boot Start End Sectors Size Id Type/dev/vda1 * 2048 104855551 104853504 50G 83Linux
Disk/dev/vdb: 50 GiB, 53687091200 bytes, 104857600sectors
Units: sectors of1 * 512 = 512bytes
Sector size (logical/physical): 512 bytes / 512bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
5.3.对磁盘vdb进⾏分区
root@zstest:~# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.27.1).
Changes will remainin memory only, until you decide to writethem.
Be careful before using thewritecommand.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier0x63c3e6e0.
赫塔米勒Command (mforhelp): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (containerforlogical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-104857599, default 2048):仪礼注疏
Last sector,+sectors or +size{K,M,G,T,P} (2048-104857599, default 104857599):
Created a new partition1 of type 'Linux' and of size 50GiB.
Command (mfor help): wThe partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
5.4.查看分区信息
root@zstest:~# fdisk -l
Disk/dev/vda: 50 GiB, 53687091200 bytes, 104857600sectors
Units: sectors of1 * 512 = 512bytes
Sector size (logical/physical): 512 bytes / 512bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disklabel type: dos
Disk identifier:0xd6804155Device Boot Start End Sectors Size Id Type/dev/vda1 * 2048 104855551 104853504 50G 83Linux
Disk/dev/vdb: 50 GiB, 53687091200 bytes, 104857600sectors
Units: sectors of1 * 512 = 512bytes
Sector size (logical/physical): 512 bytes / 512bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disklabel type: dos
Disk identifier:0x63c3e6e0Device Boot Start End Sectors Size Id Type/dev/vdb1 2048 104857599 104855552 50G 83 Linux
5.5.重新载⼊磁盘分区信息
root@zstest:~# partprobe /dev/vdb
5.6.对指定磁盘分区进⾏格式化,使⽤ext4⽂件系统
root@zstest:~# 4 /dev/vdb1
mke2fs1.42.13 (17-May-2015)
Creating filesystem with13106944 4k blocks and 3276800inodes
Filesystem UUID: 047fb8b0-e6ed-42db-bf5c-2a6d388fc34d
Superblock backups stored on blocks:32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,4096000, 7962624, 11239424Allocating group tables:doneWriting inode tables:doneCreating journal (32768 blocks): doneWriting superblocks and filesystem accounting information:doneThis filesystem will be automatically checked every38mounts or180 days, whichever comes first. Use tune2fs -c or -i to override.
5.7.根据提⽰进⾏操作,取消磁盘⾃检
root@zstest:~# tune2fs -c -1 /dev/vdb1
车流波动理论
tune2fs1.42.13 (17-May-2015)
Setting maximalmount count to -1
5.8.挂载分区到指定⽬录
mkdir -p /datamount /dev/vdb1 /data
5.9.配置开机⾃动挂载分区
vim /etc/fstab-------------------------------------------------------# made by tssc/dev/vdb1 /data ext4 defaults 0 0
-------------------------------------------------------
完毕,呵呵呵呵

本文发布于:2024-09-22 21:34:48,感谢您对本站的认可!

本文链接:https://www.17tex.com/xueshu/398936.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:分区   磁盘   查看   磁盘分区   挂载
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议