You may need to repair some filesystems that have been damaged or corrupted on Ubuntu. Here we explain to you how to correctly repair them.
Command syntax
Unless you know what you are doing, do not try to use the fsck command on mounted filesystems. Otherwise, you will cause severe filesystem damage.
fsck [options] -- [fs-options] [<filesystem> ...]
Check and repair a Linux filesystem.
Options:
- -A: check all filesystems
- -C [<fd>]: display progress bar; file descriptor is for GUIs
- -l: lock the device to guarantee exclusive access
- -M: do not check mounted filesystems
- -N: do not execute, just show what would be done
- -P: check filesystems in parallel, including root
- -R: skip root filesystem; useful only with '-A'
- -r [<fd>]: report statistics for each device checked; file descriptor is for GUIs
- -s: serialize the checking operations
- -T: do not show the title on startup
- -t <type>: specify filesystem types to be checked; <type> is allowed to be a comma-separated list
- -V: explain what is being done
- -?, --help: display this help
- --version: display version
Listing your blocks
To list all the available devices, enter the following commands (which is an abbreviation for list blocks): lsblk.
You will get a list of all the available partitions you have.
For example:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 931.5G 0 disk
├─sda1 8:1 0 930.5G 0 part /mnt/sda1
└─sda2 8:2 0 1G 0 part
nvme0n1 259:0 0 238.5G 0 disk
├─nvme0n1p1 259:1 0 300M 0 part /boot/efi
├─nvme0n1p2 259:2 0 221.1G 0 part /
└─nvme0n1p3 259:3 0 17.1G 0 part [SWAP]
Available devices:
- Two partition under the /dev/sda block, named /dev/sda/sda1
- Three partition under the /dev/nvme0n1 block, named /dev/nvme0n1/nvme0n1p1, /dev/nvme0n1/nvme0n1p2, /dev/nvme0n1/nvme0n1p3
Command usage if your filesystem is not vital
This is the scenario where your filesystem is not one of the core ones your computer needs to work (i.e, any operations related to filesystems your system needs to work must be handled with this process but using one of the other methods described below)
- List all your devices as described above and visualize the filesystem's name you want to repair.
- Unmount the filesystem first with the command: umount /dev/your_partition_name.
- Launch the filesystem repairing process with: fsck /dev/your_partition_name.
Command usage if your filesystem is vital
You will need to boot on another operating system on another media if you need to try to repair sensitive filesystems like the ones used to boot on Ubuntu or any other one your OS needs to run normally.
- Boot on any other Ubuntu installation media (USB, CD)
- List all your devices as described above and visualize the filesystem's name you want to repair.
- If the filesystem is mounted (it shouldn't be), unmount the filesystem first with the command: umount /dev/your_partition_name.
- Launch the filesystem repairing process with: fsck /dev/your_partition_name.
Alternatives
You can also force the fsck command to be run during the next booting process by creating a specific file with the command:
- touch /forcefsc
Ubuntu
- Ubuntu repair file system
- Ubuntu system check and repair
- Ubuntu errors
- How to install tar.gz in Ubuntu: using terminal > Guide
- Ubuntu reset network settings: to default, command line > Guide
- Repair AVI files in VLC: damaged or incomplete > Guide
- Mp3 file repair > Guide
- Illustrator File Damaged And Could Not Be Repaired [solved] > Forum - Office Software
- How to install Flex and Bison Ubuntu
- Execute a script on Ubuntu: at startup, shutdown
- How to boost the maximum volume in Ubuntu
- Clean up configuration residue packages in Ubuntu
- Rename a partition: Ubuntu
- How to disable Ubuntu screen reader
- Ubuntu commands: list, cheat sheet, for beginners
- How to set the fastest Ubuntu download server
- How to mount a DVD in Ubuntu
- How to disable clock in menu bar
- How to install ncurses-devel on Ubuntu
- How to install Ubuntu on Windows 10: dual boot, USB, disk