linux格式化磁盘
直接格式化为ext4格式 直接使用
[root@scrm ~]# cd /data/
[root@scrm data]# ll
total 4
drwx--x--- 13 root root 4096 Apr 9 15:09 docker
[root@scrm data]#
[root@scrm data]#
[root@scrm data]# mkdir data
[root@scrm data]#
[root@scrm data]#
[root@scrm data]# ll
total 8
drwxr-xr-x 2 root root 4096 Aug 16 09:50 data
drwx--x--- 13 root root 4096 Apr 9 15:09 docker
[root@scrm data]#
[root@scrm data]# fdisk -l
Disk /dev/vda: 42.9 GB, 42949672960 bytes, 83886080 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: 0x000bb9c1
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 83886046 41941999+ 83 Linux
Disk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 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
[root@scrm data]#
[root@scrm data]#
[root@scrm data]# fdisk /dev/vdb
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 0xe1bdbf34.
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-209715199, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199):
Using default value 209715199
Partition 1 of type Linux and of size 100 GiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@scrm data]#
[root@scrm data]#
[root@scrm data]# mkfs.ext4 /dev/vdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
6553600 inodes, 26214144 blocks
1310707 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2174746624
800 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
[root@scrm data]#
[root@scrm data]#
[root@scrm data]# mount /dev/vdb1 /data/data
[root@scrm data]#
[root@scrm data]#
[root@scrm data]# vim /etc/fstab
[root@scrm data]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Mon Sep 14 07:14:22 2020
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=9f2d3e15-a78a-4f3d-8385-0165b4b67864 / ext4 defaults 1 1
/dev/vdb1 /data/data ext4 defaults 0 0
[root@scrm data]#
[root@scrm data]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 7.7G 0 7.7G 0% /dev
tmpfs tmpfs 7.7G 0 7.7G 0% /dev/shm
tmpfs tmpfs 7.7G 600K 7.7G 1% /run
tmpfs tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup
/dev/vda1 ext4 40G 26G 12G 69% /
overlay overlay 40G 26G 12G 69% /data/docker/overlay2/97a111ee00dbfa1191417191babb12d443dc65bc23fadda2dc94fb9b89f1dd4b/merged
shm tmpfs 64M 0 64M 0% /data/docker/containers/b2192203d39c58a061f95b5765eabc5df69bf9c43f129529f952265b0d7ad754/mounts/shm
tmpfs tmpfs 1.6G 0 1.6G 0% /run/user/1000
/dev/vdb1 ext4 99G 61M 94G 1% /data/data
[root@scrm data]#
以下为常见几种文件系统EXT3,EXT4和XFS的区别:
- EXT3
(1)最多只能支持32TB的文件系统和2TB的文件,实际只能容纳2TB的文件系统和16GB的文件
(2)Ext3目前只支持32000个子目录
(3)Ext3文件系统使用32位空间记录块数量和i-节点数量
(4)当数据写入到Ext3文件系统中时,Ext3的数据块分配器每次只能分配一个4KB的块 - EXT4
EXT4是Linux系统下的日志文件系统,是EXT3文件系统的后继版本。
(1)Ext4的文件系统容量达到1EB,而文件容量则达到16TB
(2)理论上支持无限数量的子目录
(3)Ext4文件系统使用64位空间记录块数量和i-节点数量
(4)Ext4的多块分配器支持一次调用分配多个数据块 - XFS
(1)根据所记录的日志在很短的时间内迅速恢复磁盘文件内容
(2)采用优化算法,日志记录对整体文件操作影响非常小
(3) 是一个全64-bit的文件系统,它可以支持上百万T字节的存储空间
(4)能以接近裸设备I/O的性能存储数据
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~