How to create a file system in linux

Source: Internet
Author: User
Article Title: how to create a file system in linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Fdisk usage: used for hard disk partitioning

Mkfs usage: create a file system on a hard disk partition

Mkfs [-V] [-t fstype] [fs-options] filesys [blocks] Create a Linux File System

Mkfs is used to build a Linux File System on a device, usually in a hard disk partition. Filesys is the device name (such as partition/dev/hda1,/dev/sdb2 ). Blocks is the number of blocks used in the file system. mkfs returns 0 and 1, indicating success/failure. In fact, mkfs provides front-ends for a large number of different commands, such as mkfs. ext2 and mkfs. ext3.mkfs. msdos.

Etc. mkfs retrieves a series of directories, such as/sbin,/sbin/fs,/sbin/fs. d,/etc/fs,/etc (the specific directory is defined during compilation, but at least/sbin and/sbin/fs are included ), finally, it is found in the directory defined in the PATH environment variable.

Option description:

-V: displays the mkfs version information. This option can only be used to test other commands.

-T fstype: Specifies the file system, not specified. ext2 file system is used by default.

When the fs-options special File System option is used, it is omitted to read the special file system. The following items are not guaranteed to support all file systems.

-C check whether there are bad blocks before creating a File System

-L filename reads bad track information from the file

-V: displays the mkfs version.

Mkfs-t ext3/dev/hda1 create an ext3 File System in/dev/hda1

Mkfs-t ext3-v-c/dev/hda1 is the same as above, but more information is provided to scan Bad blocks.

Mkfs. ext3-c/dev/hda1 same as above

Mkfs. ext3-c-L mypartition/dev/hda1 same as above and add partition labels

2. Create a Virtual File System

Virtual File System (VFS) is a software layer in the Linux kernel that provides File System interfaces for user space programs, it also provides an abstract function in the kernel, allowing different file systems to coexist. All file systems depend not only on VFS, but also on VFS.

To support various actual file systems, VFS defines the basic and conceptual interfaces and data structures supported by all file systems; at the same time, the actual file system also provides the abstract interface and data structure expected by VFS, and maintains its own concepts, such as files and directories, in a form consistent with the definition of VFS. In other words, to be supported by Linux, an actual file system must provide an interface that complies with the VFS standard to work with VFS. The actual file system hides the specific implementation details under the unified interface and data structure, so in the VFS layer and other parts of the kernel, all file systems are the same.

The Virtual File System resides in an existing file system. It can be formatted as the desired file system type, changed the storage location, or used on other computers, it is useful when creating live CD or running a dedicated virtual operating system.

[Root @ huanxiangwu ~] # Dd if =/dev/zero of = virtual_disk count = 2048000 create 1 GB blank Disk Image File

2048000 + 0 records in

2048000 + 0 records out

1048576000 bytes (1.0 GB) copied, 37.5379 seconds, 27.9 MB/s

[Root @ huanxiangwu ~] # Du-sh virtual_disk check the size of the Virtual File System

1001 M virtual_disk

[Root @ huanxiangwu ~] # Mkfs-t ext3 virtual_disk create a file system

Mke2fs 1.39 (29-may-2006)

Virtual_disk is not a block special device.

Proceed anyway? (Y, n) y

Filesystem label =

OS type: Linux

Block size = 4096 (log = 2)

Fragment size = 4096 (log = 2)

128000 inodes, 256000 blocks

12800 blocks (5.00%) reserved for the super user

First data block = 0

Maximum filesystem blocks = 264241152

8 block groups

32768 blocks per group, 32768 fragments per group

16000 inodes per group

Superblock backups stored on blocks:

32768,983 04, 163840,229 376

Writing inode tables: done

Creating journal (4096 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 28 mounts or

180 days, whichever comes first. Use tune2fs-c or-I to override.

[Root @ huanxiangwu ~] # Mkdir/mnt/image Create a mount point

[Root @ huanxiangwu ~] # Mount-o loop virtual_disk/mnt/image/mount the Virtual File System

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.