In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to use the FSCK command in Linux, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
FSCK is an important Linux/Unix tool that detects and fixes errors in the file system. It is similar to the "chkdsk" tool in the Windows operating system, but it is prepared for Linux, MacOS, and FreeBSD operating systems.
FSCK is called File System Consistency Check. Most of the time, it runs when the system starts, but it can also be started manually by the superuser if necessary.
It can operate in three modes.
Check for errors and it is up to the user to decide what to do when errors are found
Check for errors and fix them automatically
Check for errors but only show errors when they are found and do not fix them.
Syntax of FSCK
The syntax for manually executing FSCK is
$fsck options drives
The options supported by fsck are
-p automatic repair (do not ask)
-n No changes are made to the file system
-y answer "yes" to all questions
-c check all bad blocks and add them to the list of bad blocks
-f force a check even if the file system is marked as clean
-v output details
-b superblock uses alternative super blocks
-B blocksize specifies the block size of the super block
-j external_journal specifies the location of the external log
-l bad_blocks_file is added to the specified list of bad blocks (file)
-L bad_blocks_file specifies the list of bad blocks (file)
We can specify these options at will depending on what we want to do. Let's look at some examples.
Case of Fsck command
Note: please finish reading this paragraph before you begin to discuss the case. We should not use fsck to check the mounted disk, which is likely to cause sexual damage to the disk. So before we start using fsck, we need to unmount the disk using the following command
$umount drivename
Like this.
$umount / dev/sdb1
You can view the partition number with the following command
$fdisk-l
In addition, when you run fsck, you may make an error and return some error codes. Here is a list of some common errors and their meanings
0-No error
1-fixed some file system errors
2-the system needs to be restarted
4-File system error not fixed
8-Operation error
16-usage or syntax error
32-fsck cancelled by user
128-shared library error
Now let's look at some examples of fsck commands.
Error checking on a single partition
Run the following command at the terminal to check a single partition
$umount / dev/sdb1 $fsck / dev/sdb1 checks for file system errors and automatically fixes them
Use option-a to check for consistency and automatically fix these errors. You can also replace the-an option with-y.
$fsck-a / dev/sdb1 checks for file system errors but does not fix them
If we only want to know what errors are on the file system and do not want to fix them, we can use the option-n
$fsck-n / dev/sdb1 checks all partitions for errors
The-An option checks for file system errors on all partitions at once
$fsck-A
To disable checking of the root file system, you can use the option-R
$fsck-AR only checks partitions of the specified file system type
Using the option-t and the file system type, you can have fsck check only partitions of the specified file system type, such as "ext4"
$fsck-t ext4 / dev/sdb1
Or
$fsck-t-An ext4 does consistency checking only on unmounted disks
To ensure that fsck operates only on unmounted disks, you can use the option-M
The above $fsck-AM is all the contents of this article entitled "how to use FSCK commands in Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, 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.