CentOS伺服器上磁碟舊RAI不能格式化解決方案

來源:互聯網
上載者:User

CentOS伺服器上磁碟舊RAI不能格式化解決方案

伺服器上加了一塊舊硬碟,打算格式化以後放點曆史資料,結果用fdisk 報錯:

/dev/sda1 isapparently in use by the system; will not make a filesystem here!

一般來說,這種情況是該盤已經被系統使用或者掛載到其他地方,使用mount 和df –lh確認,這個盤沒有使用。

在我之前的blog裡有整理過一篇類似的文章:

/dev/sdxx isapparently in use by the system; will not make a filesystem here!解決方案

http://blog.csdn.net/tianlesoftware/article/details/8594958

在這篇文章裡是一個共用裝置掛載到同一個2個不同的節點,但我這裡是一個裝置掛載到一個伺服器,所以情況和我們之前的不一樣。

Google了一下,說是受以前盤上遺留的RAID資訊的影響,系統會根據殘留的資訊自動探索raid,由於系統的自動識別,硬碟被虛擬地組建成了raid(即便沒有真實raid存在),這就提示磁碟正在被使用,硬碟無法格式化。

確認了一下:

[root@web1 ~]# dmraid -s

ERROR: ddf1: wrong # of devices in RAID set"ddf1_4035305a8680b02520202020202020209a33c30a3a354a45" [1/2] on/dev/sda

*** Group superset .ddf1_disks

--> *Inconsistent*Active Subset

name: ddf1_4035305a8680b02520202020202020209a33c30a3a354a45

size: 145051648

stride : 128

type: mirror

status : inconsistent

subsets: 0

devs: 1

spares : 0

[root@web1 mapper]# dmsetup status

ddf1_4035305a8680b02520202020202020209a33c30a3a354a45:0 145051651 linear

釋放對磁碟的使用可以使用如下方法:

1) dmsetup remove_all

[root@web1 mapper]# dmsetup remove_all

# dmsetup remove /dev/mapper/[device]

[root@web1 mapper]# dmsetup status

No devices found

2) 用dmraid來disableactive狀態:dmraid -a no

[root@web1 conf]# dmraid -a no

ERROR: ddf1: wrong # of devices in RAID set"ddf1_4035305a8680b02520202020202020209a33c30a3a354a45" [1/2] on/dev/sda

ERROR: device"ddf1_4035305a8680b02520202020202020209a33c30a3a354a45" could not befound

RAID set"ddf1_4035305a8680b02520202020202020209a33c30a3a354a45" is not active

[root@web1 conf]#

--驗證:

[root@web1 ~]# dmraid -s

ERROR: ddf1: wrong # of devices in RAID set"ddf1_4035305a8680b02520202020202020209a33c30a3a354a45" [1/2] on/dev/sda

*** Group superset .ddf1_disks

--> *Inconsistent*Subset

name: ddf1_4035305a8680b02520202020202020209a33c30a3a354a45

size: 145051648

stride : 128

type: mirror

status : inconsistent

subsets: 0

devs: 1

spares : 0

[root@web1 ~]#

釋放以後我們就可以對磁碟格式化,在進行掛載了。

但這樣在系統重啟之後,還是會識別到磁碟的RAID資訊,依舊不能正常mount。嘗試清除磁碟上RAID的資訊。

--使用dmraid –x:

[root@web1 ~]# dmraid -x

ERROR: ddf1: wrong # of devices in RAID set"ddf1_4035305a8680b02520202020202020209a33c30a3a354a45" [1/2] on/dev/sda

About to delete RAID setddf1_4035305a8680b02520202020202020209a33c30a3a354a45

WARNING: The metadata stored on theraidset(s) will not be accessible after deletion

Do you want to continue ? [y/n] :y

ERROR: Raid set deletion is notsupported in "ddf1" format

[root@web1 ~]#

--使用:dmraid -rE

[root@web1 mapper]# dmraid -rE

Do you really want to erase"ddf1" ondisk metadata on /dev/sda ? [y/n] :y

ERROR: ddf1: seeking device"/dev/sda" to 38070153641984

ERROR: writing metadata to /dev/sda, offset74355768832 sectors, size 0 bytes returned 0

ERROR: erasing ondisk metadata on /dev/sda

[root@web1 mapper]#

都不能成功清除,這樣即使我把mount資訊添加到/etc/fstab裡,在啟動啟動之後,也不能正常mount。所以選擇了一種方法。

在/etc/rc.d/rc.local 檔案中添加了如下資訊:

dmraid -a no

sleep 5

mount /dev/sda1 /backup

這樣就可以自動掛載了。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.