加入收藏 | 设为首页 | 会员中心 | 我要投稿 财气旺网 - 财气网 (https://www.caiqiwang.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

linux分区格式化命令

发布时间:2022-11-09 11:31:33 所属栏目:Linux 来源:
导读:  分区之后,并不能直接使用,需要格式化成特定的文件系统。

  格式化(format)是指对磁盘或磁盘中的分区(partition)进行初始化的一种操作,这种操作通常会导致现有的磁盘或分区中所有的文件被清除。

 
  分区之后,并不能直接使用,需要格式化成特定的文件系统。
 
  格式化(format)是指对磁盘或磁盘中的分区(partition)进行初始化的一种操作,这种操作通常会导致现有的磁盘或分区中所有的文件被清除。
 
  1. mkfs
 
  该命令用来在特定的分区创建linux文件系统,常见的文件系统有ext2,ext3,vfat等,执行mkfs命令其实是在调用:mkfs.ext3 | mkfs.reiserfs |mkfs.ext2| mkdosfs | mkfs.msdos | mkfs.vfat ......
 
  NAME
 
  mkfs - build a Linux filesystem
 
  SYNOPSIS
 
  mkfs [options] [-t type] [fs-options] device [size]
 
  DESCRIPTION
 
  Thismkfsfrontendisdeprecatedinfavour of filesystem specific
 
  mkfs. utils.
 
  mkfs is used to build a Linux filesystem on a device,usuallyahard
 
  diskpartition.Thedevice argument is either the device name (e.g.
 
  /dev/hda1, /dev/sdb2),oraregularfilethatshallcontainthe
 
  filesystem.Thesize argument is the number of blocks to be used for
 
  the filesystem.
 
  In actuality, mkfs is simply a front-endforthevariousfilesystem
 
  builders(mkfs.fstype) available under Linux.The filesystem-specific
 
  builder is searched for via your PATH environment setting only.Please
 
  see the filesystem-specific builder manual pages for further details.
 
  baoli@ubuntu:~$ mkfs -h
 
  Usage:
 
  mkfs [options] [-t ] [fs-options] []
 
  Make a Linux filesystem.
 
  Options:
 
  -t, --type=filesystem type; when unspecified, ext2 is used
 
  fs-optionsparameters for the real filesystem builder
 
  path to the device to be used
 
  number of blocks to be used on the device
 
  -V, --verboseexplain what is being done;
 
  specifying -V more than once will cause a dry-run
 
  -h, --helpdisplay this help
 
  -V, --versiondisplay version
 
  将sda1分区格式化为ext4格式:
 
  mfks -t ext4 /dev/sda61
 
  2. mke2fs
 
  在磁盘分区上创建ext2、ext3、ext4文件系统,默认情况下会创建ext2。
 
  mke2fs命令是专门用于管理ext系列文件系统的一个专门的工具。其还有像mkfs.ext2,mkfs.ext3,mkfs.ext4等衍生的命令linux分区工具,它们的用法mke2fs类似。
 
  NAME
 
  mke2fs - create an ext2/ext3/ext4 filesystem
 
  SYNOPSIS
 
  mke2fs[ -c | -l filename ] [ -b block-size ] [ -C cluster-size ] [ -d
 
  root-directory ] [ -D ] [ -g blocks-per-group ] [ -G number-of-groups ]
 
  [-i bytes-per-inode ] [ -I inode-size ] [ -j ] [ -J journal-options ]
 
  [ -N number-of-inodes ] [ -n ] [ -m reserved-blocks-percentage ][-o
 
  creator-os ] [ -O [^]feature[,...]] [ -q ] [ -r fs-revision-level ] [
 
  -E extended-options ] [ -v ] [ -F ] [ -Lvolume-label][-Mlast-
 
  mounted-directory ] [ -S ] [ -t fs-type ] [ -T usage-type ] [ -U UUID ]
 
  [ -V ] [ -e errors-behavior ] [ -z undo_file ] device [ fs-size ]
 
  mke2fs -O journal_dev [ -b block-size ] [ -L volume-label ] [ -n ] [ -q
 
  ] [ -v ] external-journal [ fs-size ]
 
  DESCRIPTION
 
  mke2fsis used to create an ext2, ext3, or ext4 filesystem, usually in
 
  a disk partition (or file) named by device.
 
  The file system size is specified by fs-size.If fs-size does not have
 
  asuffix,itis interpreted as power-of-two kilobytes, unless the -b
 
  blocksize option is specified, in which case fs-size is interpretedas
 
  thenumberofblocksize blocks.If the fs-size is suffixed by 'k',
 
  'm', 'g', 't' (either upper-case or lower-case), then it is interpreted
 
  inpower-of-twokilobytes,megabytes, gigabytes, terabytes, etc.If
 
  fs-size is omitted, mke2fs will create the filesystembasedonthe
 
  device size.
 
  If mke2fs is run as mkfs.XXX (i.e., mkfs.ext2, mkfs.ext3, or mkfs.ext4)
 
  the option -t XXX is implied; so mkfs.ext3 will createafilesystem
 
  forusewithext3,mkfs.ext4 will create a file system for use with
 
  ext4, and so on.
 
  The defaults of the parameters for the newly created filesystem, if not
 
  overriddenbytheoptionslistedbelow,arecontrolledbythe
 
  /etc/mke2fs.conf configuration file.Seethemke2fs.conf(5)manual
 
  page for more details.
 
  创建ext2fs:
 
  mke2fs /dev/sdb1
 
  3. mkxxfs
 
  mkntfs, the same asmkfs.ntfs
 
  mkdosfs
 
  mkinitramfs
 
  mksquashfs
 
  mkisofs
 
  mkswap
 
  mklost+found
 
  mktemp
 
  4. mkfs.xxx
 
  mkfs.cramfsmkfs.ext3mkfs.fatmkfs.msdosmkfs.vfat
 
  mkfs.bfsmkfs.ext2mkfs.ext4mkfs.minixmkfs.ntfs
 
  4.1 mkfs.ext4
 
  $ mkfs.ext4 -h
 
  mkfs.ext4: invalid option -- 'h'
 
  Usage: mkfs.ext4 [-c|-l filename] [-b block-size] [-C cluster-size]
 
  [-i bytes-per-inode] [-I inode-size] [-J journal-options]
 
  [-G flex-group-size] [-N number-of-inodes] [-d root-directory]
 
  [-m reserved-blocks-percentage] [-o creator-os]
 
  [-g blocks-per-group] [-L volume-label] [-M last-mounted-directory]
 
  [-O feature[,...]] [-r fs-revision] [-E extended-option[,...]]
 
  [-t fs-type] [-T usage-type ] [-U UUID] [-e errors_behavior][-z undo_file]
 
  [-jnqvDFSV] device [blocks-count]
 
  4.2mkfs.vfatmkfs.fat
 
  这个命令是格式化U盘的,vfat是文件系统类型,linux叫vfat, windows下叫FAT32 、 这样格完后,windows linux 默认都都能认识了。
 
  vFAT与FAT向后兼容,但允许文件具有更长的名称, mkfs.vfat并且mkfs.fat是相同的工具。
 
  NAME
 
  mkfs.fat - create an MS-DOS filesystem under Linux
 
  SYNOPSIS
 
  mkfs.fat [OPTIONS] DEVICE [BLOCK-COUNT]
 
  DESCRIPTION
 
  mkfs.fat is used to create an MS-DOS filesystem under Linux on a device
 
  (usually a disk partition).DEVICE is the specialfilecorresponding
 
  to the device (e.g. /dev/sdXX).BLOCK-COUNT is the number of blocks on
 
  the device.If omitted, mkfs.fat automatically determines the filesys‐
 
  tem size.
 
  $ mkfs.vfat --help
 
  mkfs.fat 4.1 (2017-01-24)
 
  Usage: mkfs.fat [-a][-A][-c][-C][-v][-I][-l bad-block-file][-b backup-boot-sector]
 
  [-m boot-msg-file][-n volume-name][-i volume-id]
 
  [-s sectors-per-cluster][-S logical-sector-size][-f number-of-FATs]
 
  [-h hidden-sectors][-F fat-size][-r root-dir-entries][-R reserved-sectors]
 
  [-M FAT-media-byte][-D drive_number]
 
  [--invariant]
 
  [--help]
 
  /dev/name [blocks]
 

(编辑:财气旺网 - 财气网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!