mke2fs command line tool and its examples

  • About mke2fs: To create an ext2/ext3/ext4 filesystem
  • It comes from “e2fsprogs-1.41.12” package.
  • Configuration Files:
  • Path: /sbin/mke2fs

Examples:

1. To create a file system on a device 

$ mke2fs /dev/sda2

2. To specify the block size in bytes

$ mke2fs -b 1024 /dev/sda2

3. To check the device for bad blocks

$ mke2fs -c /dev/sda2

 4. To set extended options for file system

$ mke2fs -E stride=stride-size
$ mke2fs -E stripe-width=stripe-width
$ mke2fs -E resize=max-online-resize
$ mke2fs -E lazy_itable_init[= <0 to disable, 1 to enable>]
$ mke2fs -E test_fs

5. To Specify the size of fragments in bytes

$ mke2fs -f fragment-size

6. To force mke2fs to create file system

$ mke2fs -F /dev/sda2

 7. To specify  the number of blocks in a block group.

$ mke2fs -g blocks-per-group

 8. To specify the number of block groups that will be packed together to create a larger virtual block group

$ mke2fs -G number-of-groups

9. To specify the bytes/inode ratio

$ mke2fs -i bytes-per-inode

10. To specify the size of each inode in bytes

$ mke2fs -I inode-size

11. To create the ext3 journal using options specified on the command-line

$ mke2fs -J size=journal-size
$ mke2fs -J device=external-journal 

12. To keep, do not attempt to discard blocks at mkfs time

$ mke2fs -K

13. To read the bad blocks list from filename

$ mke2fs -l filename

14. To set the volume label for the filesystem to new-volume-label

$ mke2fs -L new-volume-label

15. To specify the percentage of the filesystem blocks reserved for the super-user

$ mke2fs -m reserved-blocks-percentage

16. To set the last mounted directory for the filesystem

$ mke2fs -M last-mounted-directory

17. To not actually create a filesystem, but display what it would do if it were to create a filesystem.

$ mke2fs -n

18. To overrides the default calculation of the number of inodes that should be reserved for the filesystem

$ mke2fs -N number-of-inodes

19. To overrides the default value of the “creator operating system” field of the filesystem

$ mke2fs -o creator-os

20. To create  a filesystem with the given features

$ mke2fs -O uninit_bg

21. To quit execution

$ mke2fs -O dir_index
$ mke2fs -O extent
$ mke2fs -O filetype
$ mke2fs -O flex_bg
$ mke2fs -O has_journal
$ mke2fs -O journal_dev
$ mke2fs -O large_file
$ mke2fs -O resize_inode
$ mke2fs -O sparse_super
$ mke2fs -q

22. To set the filesystem revision for the new filesystem

$ mke2fs -r revision

 23. To write superblock and group descriptors only

$ mke2fs -S 

24. To specify  the filesystem type 

$ mke2fs -t fs-type

25. To specify how the filesystem is going to be used

$ mke2fs -T usage-type[,…]

26. To create the filesystem with the specified UUID

$ mke2fs -U UUID

27. For verbose execution

$ mke2fs -v

28. To print the version info

$ mke2fs -V

                    

Related Commands: mke2fs.conf, badblocks, dumpe2fs, e2fsck, tune2fs 

Leave a Reply

Your email address will not be published. Required fields are marked *