Linux 磁碟舊RAID 資訊 導致不能格式化和mount 的解決方法

lygle發表於2013-04-18

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

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


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


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

--&gt *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

--&gt *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


這樣就可以自動掛載了。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28673746/viewspace-758720/,如需轉載,請註明出處,否則將追究法律責任。

相關文章