mirror of
https://github.com/minio/minio.git
synced 2025-11-09 21:49:46 -05:00
handle fresh setup with mixed drives (#10273)
fresh drive setups when one of the drive is a root drive, we should ignore such a root drive and not proceed to format. This PR handles this properly by marking the disks which are root disk and they are taken offline.
This commit is contained in:
@@ -31,18 +31,32 @@ func IsRootDisk(diskPath string) (bool, error) {
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
rootInfo, err := os.Stat("/etc/hosts")
|
||||
rootHostsInfo, err := os.Stat("/etc/hosts")
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
rootInfo, err := os.Stat("/")
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
diskStat, diskStatOK := diskInfo.Sys().(*syscall.Stat_t)
|
||||
rootHostsStat, rootHostsStatOK := rootHostsInfo.Sys().(*syscall.Stat_t)
|
||||
rootStat, rootStatOK := rootInfo.Sys().(*syscall.Stat_t)
|
||||
if diskStatOK && rootStatOK {
|
||||
if diskStat.Dev == rootStat.Dev {
|
||||
if diskStatOK && rootHostsStatOK {
|
||||
if diskStat.Dev == rootHostsStat.Dev {
|
||||
// Indicate if the disk path is on root disk. This is used to indicate the healing
|
||||
// process not to format the drive and end up healing it.
|
||||
rootDisk = true
|
||||
}
|
||||
}
|
||||
if !rootDisk {
|
||||
if diskStatOK && rootStatOK {
|
||||
if diskStat.Dev == rootStat.Dev {
|
||||
// Indicate if the disk path is on root disk. This is used to indicate the healing
|
||||
// process not to format the drive and end up healing it.
|
||||
rootDisk = true
|
||||
}
|
||||
}
|
||||
}
|
||||
return rootDisk, nil
|
||||
}
|
||||
|
||||
@@ -270,6 +270,7 @@ type ServerProperties struct {
|
||||
// Disk holds Disk information
|
||||
type Disk struct {
|
||||
Endpoint string `json:"endpoint,omitempty"`
|
||||
RootDisk bool `json:"rootDisk,omitempty"`
|
||||
DrivePath string `json:"path,omitempty"`
|
||||
State string `json:"state,omitempty"`
|
||||
UUID string `json:"uuid,omitempty"`
|
||||
|
||||
Reference in New Issue
Block a user