kk Blog —— 通用基础


date [-d @int|str] [+%s|"+%F %T"]
netstat -ltunp
sar -n DEV 1

磁盘 partx,lsblk,blkid,partprobe

https://blog.csdn.net/qq_36462472/article/details/84106868

总结

在使用fdisk命令创建分区后,可以使用partx和partprobe使系统内核加载分区信息,然后使用lsblk或partx -s 设备名 查看修改后的设备分区信息,给分区做上文件系统后,可以使用blkid命令查看设备信息,以及其文件系统等信息。

使用partx -s / partx -l 查看分区信息如果出错,可能是信息未被登记,可使用partx -a 设备名 来添加,再进行查看。

patrx

修改磁盘分区表后,无需重启,用partx命令告诉内核,分区已改动,内核可以读入新的分区表信息

/proc/partitions 记录了系统中所有硬盘及其上面的分区,包括已挂载和未挂载的。

有些硬盘没有记录分区信息,可能是没有分区,也可能是未记录

对于分区完成,但是尚未挂载的硬盘分区,partx告诉内核去做登记,已备挂载。

partx告诉内核去识别,登记某个硬盘上的分区信息。并不是加载,只是识别并记录而已,或者删除某个分区的信息。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
[root@localhost ~]# partx --help

Usage:
 partx [-a|-d|-s|-u] [--nr <n:m> | <partition>] <disk>

Options:
 -a, --add            add specified partitions or all of them
 -d, --delete         delete specified partitions or all of them
 -s, --show           list partitions

 -u, --update         update specified partitions or all of them
 -b, --bytes          print SIZE in bytes rather than in human readable format
 -g, --noheadings     don't print headings for --show
 -n, --nr <n:m>       specify the range of partitions (e.g. --nr 2:4)
 -o, --output <type>  define which output columns to use
 -P, --pairs          use key="value" output format
 -r, --raw            use raw output format
 -t, --type <type>    specify the partition type (dos, bsd, solaris, etc.)
 -v, --verbose        verbose mode

 -h, --help     display this help and exit
 -V, --version  output version information and exit

Available columns (for --show, --raw or --pairs):
         NR  partition number
      START  start of the partition in sectors
        END  end of the partition in sectors
    SECTORS  number of sectors
       SIZE  human readable size
       NAME  partition name
       UUID  partition UUID
       TYPE  partition type hex or uuid
      FLAGS  partition flags
     SCHEME  partition table type (dos, gpt, ...)

For more details see partx(8).
1
2
3
4
partx命令:
	-a 设备: 登记某块盘上的所有分区信息。如果分区信息有记录,则报错。
	-d 设备: 删除内核中关于某磁盘的所有分区的记录。(不是卸载)
	-s 设备 :显示磁盘的分区信息

通过partx工具让内核重读磁盘分区表信息:

1
2
3
4
5
6
7
partx -d /dev/sdb  #因为内核中存在部分未调整磁盘的信息,故先将所有信息清零
partx -a /dev/sdb  #添加调整后的磁盘分区信息
partx -s /dev/sdb  #显示磁盘分区信息

NR   START       END   SECTORS SIZE NAME UUID
 1    2048   2099199   2097152   1G      
 2 2099200 419430399 417331200 199G

lsblk命令

列出所有可用块设备的信息,而且还能显示他们之间的依赖关系,但是它不会列出RAM盘的信息。块设备有硬盘,闪存盘,CD-ROM等等。

lsblk -f 也可以查看 UUID

lsblk和df的区别:

lsblk 查看的是block device,也就是逻辑磁盘的大小

df 查看的是file system,也就是文件系统层的磁盘大小,并且已挂载

1
2
3
4
5
6
7
8
9
[root@localhost ~]# lsblk -f
NAME            FSTYPE      LABEL           UUID                                   MOUNTPOINT
sda                                                                                
├─sda1          xfs                         f19cfd60-9c16-4ef9-bebf-a173e11ff163   /boot
└─sda2          LVM2_member                 ZTRWNx-aK5p-U1by-k0ek-B66L-hIzo-i69WzG 
  ├─centos-root xfs                         1c43a251-c82f-47f2-ac60-5674f8590883   /
  ├─centos-swap swap                        77b30510-cc6c-40e6-a739-57d44fc0f751   [SWAP]
  └─centos-home xfs                         7dcba2d9-4955-4f54-886a-4687969e84dd   /home
sr0             iso9660     VBox_GAs_6.1.16 2020-10-15-14-48-48-14
1
2
3
4
5
6
7
NAME :这是块设备名。
MAJ:MIN :本栏显示主要和次要设备号。
RM :本栏显示设备是否可移动设备。注意,在本例中设备sdb和sr0的RM值等于1,这说明他们是可移动设备。
SIZE :本栏列出设备的容量大小信息。例如298.1G表明该设备大小为298.1GB,而1K表明该设备大小为1KB。
RO :该项表明设备是否为只读。在本案例中,所有设备的RO值为0,表明他们不是只读的。
TYPE :本栏显示块设备是否是磁盘或磁盘上的一个分区。在本例中,sda和sdb是磁盘,而sr0是只读存储(rom)。
MOUNTPOINT :本栏指出设备挂载的挂载点。

blkid命令

显示关于可用块设备的信息,他可以识别一个块设备内容的类别(如文件系统,交换区)以及从内容的元数据(如卷标或UUID字段)中获取属性(如tokens和键值对)。它主要有两类作用:用指定的键值对搜索一个设备,或是显示一个或多个设备的键值对。

不添加任何参数直接运行blkid将会输出所有可用的设备,他们的通用唯一识别码(UUID),文件系统类型以及卷标(如果有设置过)

1
2
3
4
5
6
7
[root@localhost ~]# blkid
/dev/sr0: UUID="2020-10-15-14-48-48-14" LABEL="VBox_GAs_6.1.16" TYPE="iso9660" 
/dev/sda1: UUID="f19cfd60-9c16-4ef9-bebf-a173e11ff163" TYPE="xfs" 
/dev/sda2: UUID="ZTRWNx-aK5p-U1by-k0ek-B66L-hIzo-i69WzG" TYPE="LVM2_member" 
/dev/mapper/centos-root: UUID="1c43a251-c82f-47f2-ac60-5674f8590883" TYPE="xfs" 
/dev/mapper/centos-swap: UUID="77b30510-cc6c-40e6-a739-57d44fc0f751" TYPE="swap" 
/dev/mapper/centos-home: UUID="7dcba2d9-4955-4f54-886a-4687969e84dd" TYPE="xfs"

partprobe

通知系统分区表的变化

使用fdisk或其他命令创建一个新的分区,然后使用partprobe命令重新读取分区表。这个命令执行完毕后不会输出任何返回信息。

resuce 模式中mount fail

https://www.dell.com/support/kbdoc/zh-cn/000181978/appsync-service-plan-failed-in-mount-copy-phase

症状

Error in Host OS message log file:

1
2
3
4
kernel: XFS (dm-32): Superblock has unknown read-only compatible features (0x4) enabled.
kernel: XFS (dm-32): Attempted to mount read-only compatible filesystem read-write.
kernel: XFS (dm-32): Filesystem can only be safely mounted read only.
kernel: XFS (dm-32): SB validate failed with error -22.

From Host OS dmesg log file:

1
2
3
4
[ 8.529818] XFS (dm-7): Mounting V5 Filesystem
[ 8.530257] XFS (dm-8): Mounting V5 Filesystem
[ 8.557572] XFS (dm-7): Ending clean mount
[ 9.253626] XFS (dm-8): Ending clean mount

Events logs:

1
2
3
Mount copy MILE_000002,<AppSync Host>,Error occurred during the execution of service plan <Service Plan name>
Mount copy HST_000065,<AppSync Host>,Failed to discover fc and iscsi adapter information on host <Mount Host>
Mount copy UNIX_000009,<Mount Host>,Rescan command failed on the host.

Mount Host logs:

1
2
3
acputil.py[647]:execute() Info:Running command: mount -t xfs -o nouuid,rw,relatime,attr2,inode64,noquota <FS>

host.py[4121]:mount() Error caught during mount: : ['mount: wrong fs type, bad option, bad superblock on <FS>,', ' missing codepage or helper program, or other error', '', ' In some cases useful info is found in syslog - try', ' dmesg | tail or so.'] 

原因

RHEL bug triggered by unsupported configuration of not matching the source and mount hosts OS version.

解决方案

In this case, user was on Higher Source Host version (RHEL 8) and in lower Mount host version (RHEL 7.9). User made a new mount host matching to Source host and Service Plan ran fine.

其他信息

After doing some google search, it seem to be an issue with XFS v5 filesystem. Some of the important points are:

a) XFS filesystem is using XFS v5 (as per the dmesg logs) and contains features not supported by the RHEL7 kernel.

b) As per RHEL https://access.redhat.com/solutions/4582401, we need to create the filesystem without the reflink feature to use a XFS filesystem in both RHEL 7 and RHEL 8. Customer is on RHEL 7.9. mkfs.xfs -m reflink=0 /dev/sdN

To avoid the error, “-m reflink=0” is needed which disables the incompatible copy-on-right reflink support.

Source:- https://www.humblec.com/ceph-csi-xfs-superblock-has-unknown-read-only-or-wrong-fs-type-bad-on-dev-rbd4-missing-codepage-or/

c) mkfs.xfs (starting with version 3.2.4 of xfsprogs) recently defaulted to version 5 superblock, with lots of new enhancements like metadata CRC checksums. Version 5 superblock requires a 3.16 kernel or better. This error is typical, you’re trying to mount the volume on a kernel which doesn’t support v5 superblocks, i. e. with a version prior to 3.16.

Be careful, when using recent versions of xfsprogs with older kernels. You’ll have to use these options to create a v4 filesystem: mkfs.xfs -m crc=0,finobt=0 /your/device