How should I run fsck on a Linux file system
来源:互联网 发布:淘宝 云客服 工资 编辑:程序博客网 时间:2024/04/30 08:56
Scenario / Question:
I need to check file system for errors using fsck. Can I run fsck on a mounted file system ?
Solution / Answer:
Running fsck on a mounted file system can result in data corruption. The two options are:
1) Change the running state of the system to single user mode and unmount the file system
What if you need to run fsck on the root / file system ?
2) Boot the computer into Rescue Mode using the installation CD
1) Single User Mode and umount the file system
Issue command to change run level and umount the /home file system that is mounted on /dev/sda2
# init 1# umount /home
Run fsck:
# fsck /dev/sda2
2) Rescue Mode using installation CD ( to run fsck on root /)
Insert the Installation CD into the drive and reboot your system:
# shutdown -r now
After booting from the Installation CD and presented with the installation command prompt type:
linux rescue nomount
Once you are at the system command prompt you need to run mknod. Because we started Rescue Mode with the “nomount” option, no file systems were initialized and no device files were created. If we try to run fsck on a file system it will fail. We need to use mknod to create the block or character special file.
To use mknod we need to know the Minor and Major numbers of the device.
# ls -l /dev/sda8 0# ls -l /dev/sda28 2
# mknod /dev/sda b 8 0# mknod /dev/sda2 b 8 2
Run fsck and force the check and attempt to automatically repair:
-y — cause the fs-specific fsck to always attempt to fix any detected filesystem corruption automatically.
-f — force a check even if reported in a clean state
-v — Produce verbose output, including all file system-specific commands that are executed.
# fsck -yvf /dev/sda2
LVM Partitions
In order to be able to run fsck on lvm partitions we need to find the pv’s, vg’s, lv’s and activate them.
# lvm pvscan# lvm vgscan# lvm lvchange -ay /dev/VolGroup00/LogVol_home# lvm lvscan# fsck -yfv /dev/VolGroup00/LogVol_home
LUKS Partition
In order to be able to access an encrypted LUKS partition user cryptsetup.
cryptsetup luksOpen <device> <name>
<device> – is the device path
<name> – is the name of the unencrypted mount that can be accessed by /dev/mapper/<name>
# cryptsetup luksOpen /dev/VolGroup00/LogVol_home home# Ener LUKS passphrase for /dev/VolGroup00/LogVol_home# fsck -yvf /dev/mapper/home
- How should I run fsck on a Linux file system
- 【HBase】how many zookeepers should i run?
- How Do I Replace A System File? Try .KDFILES
- How should i build a shared library?
- How to compile and run a simple java file in jenkins on Windows
- how to add a swap file on linux
- How to open a large text file on Linux
- Linux - fsck命令修复文件系统 | Using command fsck to repair file system
- Creating a Root File System for Linux on OMAP35x
- fsck(file system check)
- How to Run a .Jar Java File
- 8 Deadly Commands You Should Never Run on Linux
- How to run OpenMP on Linux?
- How statically linked programs run on Linux
- How do I open an editor on a file outside the workspace?
- How do I open an editor on something that is not a file?
- 关于Ubuntu16.04 UNEXPECTED INCONSISTENCY;RUN fsck wanually,(i,o,without -a or -p options)
- When and how should I use a ThreadLocal variable?
- 学期结束时
- 利用Python写的二分法查找算法及测试
- [Nosql]MongoDb+Spring [undone]java.lang.NoClassDefFoundError: org/springframework/data/mapping/context/MappingContextAware
- 存储过程中使用事务
- C# aspx文件下载
- How should I run fsck on a Linux file system
- 找到牛股有两大精要方法
- C# 控制台 字符串 左右 移动
- 宽字符和UTF8之间的转换
- 正则基础之——非捕获组
- 键盘各键及对应编码
- 多种发动机,手枪的机械原理图 动画图解
- 登陆Oracle10g控制台时显示“Io 异常:Unknown host specified”
- GDB 反向调试(Reverse Debugging)