[DEBUG] Linux resolve df command is stuck

Error phenomenon:

Input df command and the command is stuck
Can not us cd / command to access /(root) directory
Can not us ls / command to display /(root) directory

Analysis:

There may be some network storage disconnected

Solution:

Step One: Use mount command to check if there is any disconnected network storage here

# mount

(Add: At this moment, we can see at least one remote storage mount to local directory. If we cd to this directory, system command prompt will output target is busy)

Step Two: Use unmount command to unmount this disconnected network storage

# umount -f <nfs storage which is stuck>

Or:

# umount -l <nfs storage which is stuck>

Or:

# umount -f -l <nfs storage which is stuck>

[步骤] Linux journal 日志的永久存储

正文:

步骤一:理解 journal 日志存储机制

默认情况下,journal 的日志存储在 /run/log/journal,而 /run 目录只是一个临时目录。

将 Storage 参数设置为 persistent 后,journal 的日志将存储在 /var/log/journal,/var/log 则是一个永久的目录。

步骤二:将 journal 日志设置为永久存储

2.1 修改 /etc/systemd/journald.conf 文件

# vi /etc/systemd/journald.conf

将部分内容修改如下:

[Journal]
......
Storage=persistent
......

2.2 重启 systemd-journald 服务

# systemctl restart systemd-journald.service

参考文献:

https://linuxconfig.org/introduction-to-the-systemd-journal

[排错] Linux 解决出现 “Read-only file system” 的目录

报错代码

Read-only file system

可尝试的解决方法一:重新挂载此目录

# mount -o remount rw /run

(补充:这里以重新挂载 /run 目录并给此目录添加读和写权限为例)

可尝试的解决方法二:修复出现此问题的分区

可尝试的解决方法二:分析

非正常关机可能造成文件系统受损,系统重启后,受损的分区自动挂载后就会变成只读。此时修复这个分区则可能修复这个问题

可尝试的解决方法二:解决方法

# fsck.ext4 -y /dev/sda1

(补充:这里以修复分区格式为 ext4 的分区 /dev/sda1 为例)

[命令] Linux 命令 gzip (打包、解包、压缩和解压文件或目录,压缩包以 xz 作为后缀)

内容一:gzip 命令简介

1.1 gzip 命令的格式

# gzip <option> <file>

1.2 gunzip 命令的常用选项

1) -c or –stdout, write on standard output, keep original files unchanged
2) -d or –decompress, decompress
3) -f or –force, force overwrite of output file and compress links
4) -h or –help, give this help
5) -k or –keep, keep (don’t delete) input files
6) -l or –list, list compressed file contents
7) -n or –no-name, do not save or restore the original name and timestamp
8) -N or –name, save or restore the original name and timestamp
9) -q or –quiet, suppress all warnings
10) -r or –recursive or –rsyncable, operate recursively on directories
11) -t or –test, test compressed file integrity
12) -1 or –fast, compress faster
13) -9 or –best, compress better

内容二:gzip 命令的使用案例

2.1 案例一:压缩文件

# gzip test.txt

(补充:这里以压缩文件 test.txt 为例)

2.2 案例二:解压文件

# gzip -d test.txt.xz

(补充:这里以解压文件 test.txt.zx 为例)