An old hard disk is attached to the server. if you want to format the historical data and save it, use fdisk to report the following error:
An old hard disk is attached to the server. if you want to format the historical data and save it, use fdisk to report the following error:
/Dev/sda1 isapparently in use by the system; will not make a filesystem here!
In general, this is because the disk has been used by the system or mounted to another place. use mount and df-lh to confirm that the disk is not used.
I have compiled a similar article in my previous blog:
/Dev/sdxx isapparently in use by the system; will not make a filesystem here! Solution
Http://blog.csdn.net/tianlesoftware/article/details/8594958
In this article, a shared device is mounted to the same two different nodes, but here I am mounting a device to a server, so the situation is different from what we did before.
Google said that it was affected by the RAID information left on the previous disk. The system will automatically discover raid based on the residual information. due to the automatic identification of the system, the hard disk is virtualized into a raid (even if there is no real raid), which indicates that the disk is in use and cannot be formatted.
Confirm:
[Root @ web1 ~] # Dmraid-s
ERROR: ddf1: wrong # of devices in RAID set "ddf1_40da-5a8680b02520202020202020209a33c30a354a45" [1/2] on/dev/sda
* ** Group superset. ddf1_disks
--> * Inconsistent * Active Subset
Name: ddf0000403475a8680b02520202020202020209a33c30a3a354a45
Size: 145051648
Stride: 128
Type: mirror
Status: inconsistent
Subsets: 0
Devs: 1
Spares: 0
[Root @ web1 mapper] # dmsetup status
Ddf0000404255a8680b025202020202020209a33c30a354a45: 0 145051651 linear
You can use the following method to release a disk:
1) dmsetup remove_all
[Root @ web1 mapper] # dmsetup remove_all
# Dmsetup remove/dev/mapper/[device]
[Root @ web1 mapper] # dmsetup status
No devices found
2) use dmraid to disableactive: dmraid-a no
[Root @ web1 conf] # dmraid-a no
ERROR: ddf1: wrong # of devices in RAID set "ddf1_40da-5a8680b02520202020202020209a33c30a354a45" [1/2] on/dev/sda
ERROR: device "ddf0000403475a8680b02520202020202020209a33c30a3a354a45" cocould not befound
RAID set "ddf1_40da-5a8680b02520202020202020209a33c30a3a354a45" is not active
[Root @ web1 conf] #
-- Verification:
[Root @ web1 ~] # Dmraid-s
ERROR: ddf1: wrong # of devices in RAID set "ddf1_40da-5a8680b02520202020202020209a33c30a354a45" [1/2] on/dev/sda
* ** Group superset. ddf1_disks
--> * Inconsistent * Subset
Name: ddf0000403475a8680b02520202020202020209a33c30a3a354a45
Size: 145051648
Stride: 128
Type: mirror
Status: inconsistent
Subsets: 0
Devs: 1
Spares: 0
[Root @ web1 ~] #
After the disk is released, the disk can be formatted and mounted.
However, after the system is restarted, the disk RAID information will still be identified and the disk cannot be mounted normally. Try to clear the RAID information on the disk.
-- Use dmraid-x:
[Root @ web1 ~] # Dmraid-x
ERROR: ddf1: wrong # of devices in RAID set "ddf1_40da-5a8680b02520202020202020209a33c30a354a45" [1/2] on/dev/sda
About to delete RAID setddf0000403475a8680b025202020202020209a33c30a354a45
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 ~] #
-- Use: 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] #
Cannot be cleared successfully, so that even if I add the mount information to/etc/fstab, the mount will not work after the startup. So we chose a method.
The following information is added to the/etc/rc. d/rc. local file:
Dmraid-a no
Sleep 5
Mount/dev/sda1/backup
In this way, automatic mounting is enabled.
Bytes ---------------------------------------------------------------------------------------
All rights reserved. reprinted articles are allowed, but source addresses must be indicated by links. Otherwise, the documents will be held legally responsible!
Skype: tianlesoftware
QQ: tianlesoftware@gmail.com
Email: tianlesoftware@gmail.com
Blog: http://blog.csdn.net/tianlesoftware
Weaver: http://weibo.com/tianlesoftware
Twitter: http://twitter.com/tianlesoftware
Facebook: http://www.facebook.com/tianlesoftware
Linkedin: http://cn.linkedin.com/in/tianlesoftware