8.5-7 mkfs、dumpe2fs、resize2fs
8.5 mkfs:创建Linux文件系统
[root@cs6 ~]# ls /sbin/mkfs*
/sbin/mkfs /sbin/mkfs.ext2 /sbin/mkfs.ext4 /sbin/mkfs.xfs
/sbin/mkfs.cramfs /sbin/mkfs.ext3 /sbin/mkfs.ext4dev
通过mkfs 命令创建文件系统(-t参数)的例子
[root@cs6 ~]# mkfs -t ext4 -v /dev/sdb
mke2fs 1.41.12 (17-May-2010)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
fs_types for mke2fs.conf resolution: 'ext4', 'default'
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
65536 inodes, 262144 blocks
13107 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376 Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
通过mkfs.ext4创建文件系统
[root@cs6 ~]# mkfs.ext4 /dev/sdb
mke2fs 1.41.12 (17-May-2010)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
....
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 25 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
8.6 dumpe2fs:导出ext2/ext3/ext4文件系统信息
查看系统的inode信息
[root@cs6 ~]# dumpe2fs /dev/sda1|egrep -i "inode size|inode count"
dumpe2fs 1.41.12 (17-May-2010)
Inode count: 128016 #<==单位;个。
Inode size: 128 #<== /boot 分区默认128字节。 [root@cs6 ~]# dumpe2fs /dev/mapper/vg_cs6-lv_root |egrep -i "inode size|inode count"
dumpe2fs 1.41.12 (17-May-2010)
Inode count: 1738080
Inode size: 256 #<==普通分区默认256字节。 [root@cs6 ~]# df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/mapper/vg_cs6-lv_root
1738080 23534 1714546 2% /
tmpfs 238145 1 238144 1% /dev/shm
/dev/sda1 128016 38 127978 1% /boot [root@cs6 ~]# dumpe2fs /dev/sda1|egrep -i "block size|block count"
dumpe2fs 1.41.12 (17-May-2010)
Block count: 512000 #<==分区的block总量。
Reserved block count: 25600
Block size: 1024 #<==/boot分区默认1024字节即1K
[root@cs6 ~]# dumpe2fs /dev/mapper/vg_cs6-lv_root |egrep -i "block size|block count"
dumpe2fs 1.41.12 (17-May-2010)
Block count: 6948864
Reserved block count: 347443
Block size: 4096 #<==普通分区4K=4096字节。
8.7 resize2fs:调整ext2/ext3/ext4文件系统大小
动态修改分区大小的例子
[root@cs6 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_cs6-lv_root
26G 834M 24G 4% /
tmpfs 931M 0 931M 0% /dev/shm
/dev/sda1 477M 28M 424M 7% /boot
/dev/sdb1 194M 1.8M 182M 1% /mnt/data1
/dev/sdb2 194M 1.8M 182M 1% /mnt/data2
[root@cs6 ~]# touch /mnt/data1/{1..5}.html
[root@cs6 ~]# touch /mnt/data2/{1..5}.html
[root@cs6 ~]# fdisk -l /dev/sdb Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x1bc7d413 Device Boot Start End Blocks Id System
/dev/sdb1 1 26 208813+ 83 Linux
/dev/sdb2 27 52 208845 83 Linux
[root@cs6 ~]# umount /mnt/data1
[root@cs6 ~]# umount /mnt/data2 [root@cs6 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_cs6-lv_root
26G 834M 24G 4% /
tmpfs 931M 0 931M 0% /dev/shm
/dev/sda1 477M 28M 424M 7% /boot
[root@cs6 ~]# fdisk /dev/sdb WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u'). Command (m for help): d
Partition number (1-4): 1 Command (m for help): d
Selected partition 2 Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-130, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-130, default 130): 52 Command (m for help): p Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x1bc7d413 Device Boot Start End Blocks Id System
/dev/sdb1 1 52 417658+ 83 Linux Command (m for help): w
The partition table has been altered! Calling ioctl() to re-read partition table.
Syncing disks.
[root@cs6 ~]# partprobe /dev/sdb
[root@cs6 ~]# mount /dev/sdb1 /mnt/data1
[root@cs6 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_cs6-lv_root
26G 834M 24G 4% /
tmpfs 931M 0 931M 0% /dev/shm
/dev/sda1 477M 28M 424M 7% /boot
/dev/sdb1 194M 1.8M 182M 1% /mnt/data1 [root@cs6 ~]# ls /mnt/data1
1.html 2.html 3.html 4.html 5.html lost+found
[root@cs6 ~]# resize2fs /dev/sdb1 #<==在线调整磁盘大小,
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/sdb1 is mounted on /mnt/data1; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 2
Performing an on-line resize of /dev/sdb1 to 417656 (1k) blocks.
The filesystem on /dev/sdb1 is now 417656 blocks long. [root@cs6 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_cs6-lv_root
26G 834M 24G 4% /
tmpfs 931M 0 931M 0% /dev/shm
/dev/sda1 477M 28M 424M 7% /boot
/dev/sdb1 392M 2.3M 369M 1% /mnt/data1
[root@cs6 ~]# ls /mnt/data1
1.html 2.html 3.html 4.html 5.html lost+found
#<==但是数据还是只有sdb1里的了,sdb2的数据丢失了。此种方法不适合生产场景扩容,比较规范方法是通过LVM逻辑卷管理进行扩容,扩容后也需要resize2fs进行最终实现扩容。
8.5-7 mkfs、dumpe2fs、resize2fs的更多相关文章
- Linux学习--第九天--du、df、fsck、dumpe2fs、mount、NTFS-3G、fdisk、partprobe、/etc/fstab、free、mkswap、swapon
分区类型 主分区:最多只能分四个 扩展分区:只能有一个,如果有了扩展分区,主分区只能有三个.扩展分区不能格式化和存储数据,再划分为逻辑分区才能进行相应操作. 逻辑分区:IDE硬盘,linux最多支持5 ...
- 文件系统常用命令df、du、fsck、dumpe2fs
df 查看文件系统 [root@localhost ~]# df 文件系统 1K-块 已用 可用 已用% 挂载点 /dev/sda5 16558080 1337676 15220404 9% / de ...
- Linux文件系统管理 常见命令df、du、fsck、dumpe2fs
概述 Linux文件系统管理 常见命令df.du.fsck.dumpe2fs. 文件系统查看命令:df 通过 df 命令可以査看已经挂载的文件系统的信息包括设备文件名.文件系统总大小.已经使用的大小. ...
- 一个版本烧录过程中记录:fdisk、mkfs.ext4、make_ext4fs、img2simg、simg2img
关键词:dd.fdisk.mkfs.ext4.make_ext4fs.img2simg.simg2img等等. 一个典型的嵌入式系统是由uboot+kernel+rootfs组成的,其中uboot和k ...
- linux:磁盘的分割、检验、格式化与挂载
新增一颗磁碟: 1.对磁碟进行分割,以建立可用的partition 2.对该分割槽partition进行格式化(format),以建立系统可用的filesystem 3.若要仔细点,可对刚刚建立的fi ...
- 磁盘分区、格式化、挂载[转自vbird]
磁盘分区.格式化.挂载磁盘分区 新增分区 查询分区 删除分区磁盘格式化 mkfs mke2fs磁盘挂载与卸载 mount umount 磁盘的分区.格式化.挂 ...
- Linux学习之CentOS(十二)------磁盘管理之 磁盘的分区、格式化、挂载(转)
磁盘分区.格式化.挂载磁盘分区 新增分区 查询分区 删除分区磁盘格式化 mkfs mke2fs磁盘挂载与卸载 mount umount 磁盘的分区.格式化.挂 ...
- MBR分区操作-增加、扩展、删除
MBR分区操作-增加.扩展.删除 GPT分区参考 http://www.blogjava.net/haha1903/archive/2011/12/21/366942.html l fdisk 显示 ...
- linux硬盘的分区、格式化、挂载以及LVM
linux硬盘的分区.格式化.挂载以及LVM 多块硬盘的组合: 硬盘分两种:ide和scsi. ide硬盘: /dev/hda 第一块IDE硬盘 /dev/hdb 第二块IDE硬盘 ... /de ...
随机推荐
- SpringBoot项目war包部署
服务部署 记录原因 将本地SpringBoot项目通过war包部署到虚拟机中,验证服务器部署. 使用war包是为了方便替换配置文件等. 工具 对象 版本 Spring Boot 2.4.0 VMwar ...
- C语言-字符串函数的实现(一)之strlen
C语言中的字符串函数有如下这些 获取字符串长度 strlen 长度不受限制的字符串函数 strcpy strcat strcmp 长度受限制的字符串函数 strncpy strncat strncmp ...
- 网关Ocelot功能演示完结,久等了~~~
前言 关于网关(Ocelot)的分享,还遗留一些功能没演示呢,接着来聊聊:这次重点针对网关Ocelot使用缓存.集成Polly做服务治理.集成IdentityServer4做认证授权来详细说说:如果对 ...
- 记一次xss漏洞挖掘
博客园在整改中,无法更新文章,难受啊... 记录一次react的xss漏洞发现,比较有意思: 某个站: 直接输入<xxx>,直接把我跳转到了404,猜测可能做了一些验证: 尝试多重编码,发 ...
- 805. Split Array With Same Average
In a given integer array A, we must move every element of A to either list B or list C. (B and C ini ...
- Python 爬虫之Scrapy框架
Scrapy框架架构 Scrapy框架介绍: 写一个爬虫,需要做很多的事情.比如:发送网络请求.数据解析.数据存储.反反爬虫机制(更换ip代理.设置请求头等).异步请求等.这些工作如果每次都要自己从零 ...
- Windows PE 第一章开发环境和基本工具使用
第一章 Windows PE 基本工具 1.1开发语言MASM32 1.1.1设置开发环境 这个不细说了,我在整理Intel汇编的时候详细的说了环境搭建以及细节.地址是:http://blog.csd ...
- 大数据开发-Flink-数据流DataStream和DataSet
Flink主要用来处理数据流,所以从抽象上来看就是对数据流的处理,正如前面大数据开发-Flink-体系结构 && 运行架构提到写Flink程序实际上就是在写DataSource.Tra ...
- 【Azure Developer】使用Microsoft Graph API 如何批量创建用户,用户属性中需要包含自定义字段(如:Store_code,Store_name等)
Microsoft Graph 是 Microsoft 365 中通往数据和智能的网关. 它提供统一的可编程模型,可用于访问 Microsoft 365.Windows 10 和企业移动性 + 安全性 ...
- 关于MDI多文档程序的一些思考
MDI程序的框架 客户窗口是一个预定义的窗口类(MDICLIENT),它是框架窗口的子窗口同时也是各个子文档窗口的父窗口.框架窗口和各个子文档窗口都是自定义的窗口类. MDI程序中的一些要点 窗口中的 ...