Site icon Learning & Doing

Command untuk fsck di linux

The usage is very easy. Open a terminal and type:

fsck /dev/sda1

This will check the sda1 partition. An important thing to note is that fsck cannot be used on a mounted partition. If you do so, there is a high chance that it will damage the filesystem. To check your Home folder that resides on another partition, say sda2, use the following commands:

umount /home
fsck /dev/sda2

Note: you will need root/superuser permission to run the “fsck” command.

You can also use “fsck” to check external drive, such as your thumb drive or SD card. For example:

umount /dev/sdb1 #thumb drive
sudo fsck /dev/sdb1

If you are not sure of the partition number, you can use the command

sudo fdisk -l

to list out all the partitions in the system.
Advanced Usage

There are a few parameters that you can add to “fsck” to make it more powerful.
Auto repair filesystem when errors are detected

During the filesystem check, if errors are detected, you can get “fsck” to auto repair the filesystem with the -a flag. For example:

fsck -a /dev/sda1

Similarly, using the -y flag can get the job done as well:

fsck -y /dev/sda1

Check all filesystems in one run

If there are several filesystems in your computer, you can get fsck to check all of them at the same time with the -A flag.

fsck -A

What it will do is to grab all the filesystem entries from /etc/fstab and scan them for errors. You can use it together with the -R and -y flag to prevent it from scanning the root filesystem and fix all errors, if there is any.

fsck -AR -y

Exclude check on mounted filesystem

As mentioned earlier, fsck cannot be run on a mounted filesystem. If you are using the -A flag to scan all the filesystems, and some of them are mounted, you might damage those filesystems. A way to overcome this is to use the -M flag to prevent it from checking mounted system.

For example, running the command

fsck -M /dev/sdc1

returns nothing and a return code 0 (which means “no error”). No scan was done at all since all the filesystems are mounted.

SUmber : http://www.maketecheasier.com/check-repair-filesystem-fsck-linux/

Exit mobile version