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 ...
随机推荐
- 刚转行1年测试新手:学习Python编程经验实战分享
一.开头说两句 作为一名零基础转行刚一年的测试新手来说,深知自己在技术经验方面落后太多,难免会有急于求成的心态,这也就导致自己在学习新知识时似懂非懂,刚开始学完那会还胸有成竹,一段时间之后却又忘的一干 ...
- 【Azure Developer】使用Java SDK代码创建Azure VM (包含设置NSG,及添加数据磁盘SSD)
在参考Azure官方文档进行VM创建时,发现其中没有包含如何设置NSG的内容,以及如何在创建时就添加数据磁盘的代码(设置磁盘为SSD类型).本文的内容以"使用 Java 创建和管理 Azur ...
- Day11_56_在SortedSet中使用泛型
在SortedSet中使用泛型 import java.util.SortedSet; import java.util.TreeSet; //主类 public class GenericTest0 ...
- JavaScript设计模式(一):单例模式
单例模式的定义与特点 单例(Singleton)模式的定义:指一个类只有一个实例,且该类能自行创建这个实例的一种模式.例如,Windows 中只能打开一个任务管理器,这样可以避免因打开多个任务管理器窗 ...
- 基于MATLAB的手写公式识别(3)
基于MATLAB的手写公式识别 图像的膨胀化,获取边缘(思考是否需要做这种处理,初始参考样本相对简单) %膨胀 imdilate(dilate=膨胀/扩大) clc clear A1=imread(' ...
- 5403. Find the Kth Smallest Sum of a Matrix With Sorted Rows
You are given an m * n matrix, mat, and an integer k, which has its rows sorted in non-decreasing or ...
- Mybatis的简单增删改查
刚开始学习Mybatis可以先看下官方文档,MyBatis是支持定制化SQL.存储过程以及高级映射的优秀的持久层框架.MyBatis避免了几乎所有的JDBC代码和手工设置参数以及抽取结果集.MyBat ...
- 02- web UI测试与UI Check List
UI英文是 user interface .所以UI测试就是用户界面测试. Web UI测试 用户界面测试:user interface testing,UI Testing指软件中的可见外观及其与用 ...
- composer 遇见问题 整理
修改镜像源:改为阿里云镜像 composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ 报错:Con ...
- Win64 驱动内核编程-19.HOOK-SSDT
HOOK SSDT 在 WIN64 上 HOOK SSDT 和 UNHOOK SSDT 在原理上跟 WIN32 没什么不同,甚至说 HOOK 和 UNHOOK 在本质上也没有不同,都是在指定的地址上填 ...