歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> 學習Linux >> partproble在RHEL 6下無法更新分區信息

partproble在RHEL 6下無法更新分區信息

日期:2017/3/6 9:33:03   编辑:學習Linux

partproble在RHEL 6下無法更新分區信息


partproble在RHEL 6下無法更新分區信息


在RHEL5.x版本下面,在添加磁盤分區等操作後,一直使用partproble命令使內核重新讀取分區表信息,從而不用重新啟動。但是最近在RHEL 6(Red Hat Enterprise Linux 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:

Raw

# 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 busy
error 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”
image

檢查分區節點信息。

[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

參考資料:

https://access.redhat.com/node/57542

本文永久更新鏈接地址:

http://xxxxxx/Linuxjc/1140996.html TechArticle

Copyright © Linux教程網 All Rights Reserved