partproble在RHEL 6下无法更新分区信息

在RHEL5.x版本下面,在添加磁盘分区等操作后,一直使用partproble命令使内核重新读取分区表信息,从而不用重新启动。但是最近在RHEL 6( Enterprise Server release 6.6 (Santiago))下,使用partprobe出现错误。

[root@localhost ~]# lsof /dev/sda

[root@localhost ~]# partprobe /dev/sda

Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.

 

后面查了一下资料发现,在官方文档How to use a new partition in RHEL6 without reboot中有如下介绍

partprobe was commonly used in RHEL 5 to inform the OS of partition table changes on the disk. In RHEL 6, it will only trigger the OS to update the partitions on a disk that none of its partitions are in use (e.g. mounted). If any partition on a disk is in use, partprobe will not trigger the OS to update partitions in the system because it is considered unsafe in some situations.

更多

本文永久更新链接地址

翻译如下:

partprobe通常在RHEL 5中用来通知的磁盘上的分区表变化或更改。在RHEL 6中,只有当那些磁盘上任何分区都没有在使用的磁盘下(例如,mounted)它才会触发OS去更新磁盘的分区表。如果磁盘上的任何分区正在使用中,partprobe命令不会触发去更新分区表的信息,因为在某些情况下,它被认为是不安全的。

 

1:重启。万能的重启,哈哈,不过,在很多情况下是不现实的,因为重启会中断业务,重启只能是下下策。

2:使用partx命令来解决这个。

[root@localhost ~]# partx -l /dev/sdb

# 1:        63-314568764 (314568702 sectors, 161059 MB)

# 2: 314568765-356514479 ( 41945715 sectors,  21476 MB)

# 3:         0-       -1 (        0 sectors,      0 MB)

# 4:         0-       -1 (        0 sectors,      0 MB)

[root@localhost ~]# 

[root@localhost ~]# partx -v -a /dev/sdb

device /dev/sdb: start 0 size 356515840

gpt: 0 slices

dos: 4 slices

# 1:        63-314568764 (314568702 sectors, 161059 MB)

# 2: 314568765-356514479 ( 41945715 sectors,  21476 MB)

# 3:         0-       -1 (        0 sectors,      0 MB)

# 4:         0-       -1 (        0 sectors,      0 MB)

BLKPG: Device or resource busy

error adding partition 1

BLKPG: Device or resource busy 这个提示信息是正常,表示分区1在分区2添加前已经存在了。

Read disk and try to add all partitions to the system:

# partx -v -a /dev/sdb                                         device /dev/sdb: start 0 size 2097152  gpt: 0 slices  dos: 4 slices  # 1:        63-   505007 (   504945 sectors,    258 MB)  # 2:    505008-  1010015 (   505008 sectors,    258 MB)  # 3:         0-       -1 (        0 sectors,      0 MB)  # 4:         0-       -1 (        0 sectors,      0 MB)  BLKPG: Device or resource busyerror adding partition 1

(These last 2 lines are normal in this case because partition 1 is already added in the system before partition 2 is added)

例如在添加、读取分区表信息后,再执行下面命令,就会发现分区2也报“BLKPG: Device or resource busy error adding partition 2”

检查分区节点信息。

[root@localhost ~]# ls /dev/sdb*

/dev/sdb  /dev/sdb1  /dev/sdb2

[root@localhost ~]# 

 

另外,我在测试中,发现也可以使用下面方法里解决,例如新增的分区是/dev/sdc2/ /dev/sdb2/ /dev/sda4,那么就可以执行如下命令解决

[root@localhost ~]# partx -a /dev/sdc2 /dev/sdc

 

[root@localhost ~]# partx -a /dev/sdb2 /dev/sdb

 

[root@localhost ~]# partx -a /dev/sda4 /dev/sda

 

参考资料:

更多内容请长按二维码关注(更有不定期发红包活动吆^0^):
致儒先生

转载自:https://www.linuxidc.com/Linux/2016-07/133019.htm

声明: 除非转自他站(如有侵权,请联系处理)外,本文采用 BY-NC-SA 协议进行授权 | 智乐兔
转载请注明:转自《partproble在RHEL 6下无法更新分区信息
本文地址:https://www.zhiletu.com/archives-7564.html
关注公众号:智乐兔

赞赏

wechat pay微信赞赏alipay pay支付宝赞赏

上一篇
下一篇

相关文章

在线留言

你必须 登录后 才能留言!

在线客服
在线客服 X

售前: 点击这里给我发消息
售后: 点击这里给我发消息

智乐兔官微