In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
In this issue, the editor will bring you about how to write linux formatting commands. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
If we buy a new virtual host space or want to change the operation procedure, we will often use disk formatting to clear the previous data. There are many methods of disk formatting. We often use NTFS and linux formatting commands to format the disk. Let's explain the details of the linux formatting command.
Linux format disk command
Linux mkfs
Instruction: mkfs
Permissions: superuser
Usage: mkfs [- V] [- t fstype] [fs-options] filesys [blocks] [- L Lable]
Description: set up a linux file system on a specific partition
Parameters:
Device: hard disk partition to be checked, for example: / dev/sda1
-V: detailed display mode
-t: given the type of file system, the default value of Linux is ext2
-c: check the partition for bad tracks before making the file system
-l bad_blocks_file: add block data with bad tracks to bad_blocks_file
Block: the size of a given block
-L: establish lable
Supplementary note:
Mkfs itself does not perform the work of building a file system, but calls the relevant program to execute it. For example, if you specify ext2 in the "- t" parameter,
Mkfs calls mke2fs to set up the file system. If you omit the specified number of blocks parameter, mkfs will automatically set the appropriate number of blocks.
Example:
Build a msdos file system on / dev/hda5, check for bad tracks, and list the process in detail:
Mkfs-V-t msdos-c / dev/hda5
Mfks-t ext3 / dev/sda6 / / format the sda6 partition into ext3 format
Mkfs-t ext2 / dev/sda7 / / format the sda7 partition into ext2 format
Extended knowledge: examples of using mkfs
[root@localhost beinan] # mkfs-t file system storage device
Note:
The file system here is to be specified, such as ext3; reiserfs; ext2; fat32; msdos, etc.
Devices such as a hard disk partition, floppy disk, CD-ROM drive, etc. ... Before formatting a partition, you need to know how to check the hard disk partition and format it specifically; for example, use fdisk-l to view it; please refer to: "Linux to view disk partitions, file systems, usage commands and related tools". For example, I want to format a partition in a mobile USB drive; the panorama should be:
[root@localhost beinan] # fdisk-l
Disk / dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/ dev/hda1 * 1 765 6144831 7 HPFS/NTFS
/ dev/hda2 766 2805 16386300 c W95 FAT32 (LBA)
/ dev/hda3 2806 9729 55617030 5 Extended
/ dev/hda5 2806 3825 8193118 + 83 Linux
/ dev/hda6 3826 5100 10241406 83 Linux
/ dev/hda7 5101 5198 787153 + 82 Linux swap / Solaris
/ dev/hda8 5199 6657 11719386 83 Linux
/ dev/hda9 6658 7751 8787523 + 83 Linux
/ dev/hda10 7752 9729 15888253 + 83 Linux
Disk / dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Device Boot Start End Blocks Id System
/ dev/sda1 1 25 201568 + 83 Linux
/ dev/sda2 26 125 806400 5 Extended
/ dev/sda5 26 50 201568 + 83 Linux
/ dev/sda6 51 76 200781 83 Linux
We can see that there is a sda device, so we can use fdisk-l / dev/sda to display his partition; for example, if I want to format the / dev/sda6 partition to the ext3 file system, it will be:
[root@localhost beinan] # mkfs-t ext3 / dev/sda6
Mke2fs 1.37 (21-Mar-2005)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
50200 inodes, 200780 blocks
10039 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
25 block groups
8192 blocks per group, 8192 fragments per group
2008 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: note: enter directly from here.
Done
This filesystem will be automatically checked every 26 mounts or
180 days, whichever comes first. Use tune2fs-c or-i to override.
Formatted like this, sda6 is now an ext3 file system; we can load the partition with mount and then use the file system
[root@localhost beinan] # mkdir / mnt/sda6
[root@localhost beinan] # chmod 777 / mnt/sda6
[root@localhost beinan] # mount / dev/sda6 / mnt/sda6
Of course, you can also format partitions into other file systems; for example, we format / dev/sda6 into ext3, ext2, reiserfs, fat32, msdos file systems, with the following command format
[root@localhost beinan] # mkfs-t ext3 / dev/sda6
[root@localhost beinan] # mkfs-t ext2 / dev/sda6
[root@localhost beinan] # mkfs-t reiserfs / dev/sda6
[root@localhost beinan] # mkfs-t fat32 / dev/sda6
[root@localhost beinan] # mkfs-t msdos / dev/sda6
......
2) introduction of mkfs.ext3 mkfs.reiserfs mkfs.ext2 mkfs.msdos mkfs.vfat mke2fs
After we have talked about a mkfs tool, we will introduce mkfs.ext3 mkfs.reiserfs mkfs.ext2 mkdosfs mkfs.msdos mkfs.vfat. In fact, mkfs also invokes this tool when executing commands, which is the main reason why I introduced mkfs first; through the file name, we know what file systems these tools support; these commands provide us with more convenience.
[root@localhost beinan] # mkfs.ext3 / dev/sda6 Note: format the device into an ext3 file system
[root@localhost beinan] # mke2fs-j / dev/sda6 Note: format the device into an ext3 file system
[root@localhost beinan] # mkfs.ext2 / dev/sda6 Note: format the device into an ext2 file system
[root@localhost beinan] # mke2fs / dev/sda6 Note: format the device into an ext2 file system
[root@localhost beinan] # mkfs.reiserfs / dev/sda6 Note: format the device into a reiserfs file system
[root@localhost beinan] # mkfs.vfat / dev/sda6 Note: format the device into a fat32 file system
[root@localhost beinan] # mkfs.msdos / dev/sda6 Note: format the device into a fat16 file system, and the msdos file system is fat16
[root@localhost beinan] # mkdosfs / dev/sda6 Note: format the device into a fat16 file system, the same as mkfs.msdos
......
2) mkswap formats a partition into a swap exchange
[root@localhost beinan] # mkswap / dev/sda6 Note: create this partition as swap swap partition
[root@localhost beinan] # swapon / dev/sda6 Note: load swap partition
[root@localhost beinan] # swapoff / dev/sda6 Note: close the swap partition
Let's look at the swap swap partitions that have been loaded by the system
[root@localhost beinan] # swapon / dev/sda6 Note: load swap partition
[root@localhost beinan] # swapon-s
Filename Type Size Used Priority
/ dev/hda7 partition 787144 0-1
/ dev/sda6 partition 225144 0-3
Why does my system have two swap partitions? Because the experiment I do with the mobile flash drive is mainly for writing tutorials; sda6 is the swap partition I built on the flash drive.
If you allow swap to boot and load, you should change the / etc/fstab file and add a line similar to the following
/ dev/sda6 swap swap defaults 0 0 Note: change the / dev/hda7 in this line to your swap partition line
Or write the command line directly to / etc/rc.d/rc.local
Swapon / dev/sda6
If your hard drive can no longer be partitioned, you can create a swap file
[root@localhost beinan] # dd if=/dev/zero of=/tmp/swap bs=1024 count=524288 Note: create a swap file with a size of 512m in the / tmp directory; you can create a swap file according to the size you need
Read 524288 blocks
524288 blocks were output
[root@localhost beinan] # mkswap / tmp/swap Note: create the / tmp/swap file into a swap exchange area
Setting up swapspace version 1, size = 536866 kB
No label, UUID=d9d8645d-92cb-4d33-b36e-075bb0a2e278
[root@localhost beinan] # swapon / tmp/swap Note: Mount swap
[root@localhost beinan] # swapon-s
Filename Type Size Used Priority
/ dev/hda7 partition 787144 88-1
/ tmp/swap file 524280 0-2
Note: in fact, when we install the system, we have already divided the swap partition; check / etc/fstab, the line that should be swap; if you do not add swap when you install the system, you can add it in this way
This is how the linux formatting command shared by the editor is written. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.