Linux

Linux Mdadm + LVM 恢復

  • February 11, 2011

我最近用 10.04 重新安裝了我的 Ubuntu 伺服器,並且無法重新啟動包含我所有非關鍵數據的 LVM 分區。/dev/sda, /dev/sdb, /dev/sdc, 和/dev/sdd都組裝成一個 Raid-5 陣列,上面有一個帶有 LG/dev/md0的 VG (我想;我以前可以手動安裝它)。我目前的問題是,我無法讓系統檢測到 VG 並啟動它。不到 20 分鐘前,我還可以正常工作(我在上次啟動時遇到了這個問題,但沒有寫下我在上次啟動系統時實際啟動 VG 所採取的步驟)。media``part1``vgchange -ay media && mount /dev/mapper/media-part1

突襲組裝得很好而且很乾淨,但我無法讓 VG 出現或安裝。pvck /dev/md0顯示:

Device /dev/md0 not found (or ignored by filtering).

我的過濾器/etc/lvm/lvm.conffilter = [ "a/.*/" ]

pvck /dev/md0p1顯示:

Could not find LVM label on /dev/md0p1

pvdisplay產生以下輸出:

 Setting global/locking_type to 1
  Setting global/wait_for_locks to 1
  File-based locking selected.
  Setting global/locking_dir to /var/lock/lvm
  Locking /var/lock/lvm/P_global RB
Scanning for physical volume names
  /dev/ram0: No label detected
  /dev/md0p1: Label for sector 1 found at sector 0 - ignoring
  /dev/md0p1: No label detected
  /dev/ram1: No label detected
  /dev/sda1: Label for sector 1 found at sector 0 - ignoring
  /dev/sda1: No label detected
  /dev/ram2: No label detected
  /dev/ram3: No label detected
  /dev/ram4: No label detected
  /dev/ram5: No label detected
  /dev/ram6: No label detected
  /dev/ram7: No label detected
  /dev/ram8: No label detected
  /dev/ram9: No label detected
  /dev/ram10: No label detected
  /dev/ram11: No label detected
  /dev/ram12: No label detected
  /dev/ram13: No label detected
  /dev/ram14: No label detected
  /dev/ram15: No label detected
  /dev/sdb1: No label detected
  /dev/sde1: No label detected
  /dev/sdf1: No label detected
  /dev/sdg1: No label detected
  /dev/sdh1: No label detected
  /dev/sdi1: No label detected
  /dev/root: No label detected
  /dev/sdj3: No label detected
  /dev/sdj4: No label detected
  /dev/sdj5: No label detected
  /dev/sdj6: No label detected
  Unlocking /var/lock/lvm/P_global

/dev/m0p1是應該儲存 PV 的位置,但它沒有顯示出來。可悲的是,我沒有/etc/lvm/backup以前安裝的目錄。

我很確定數據都在那裡,我只需要知道

a)我如何強制 lvm 在/dev/md0設備中搜尋卷組,以及

b)我如何解決這個問題,以便系統檢測並啟動卷啟動時組(RAID 陣列已在啟動時組裝)。

我不確定我是否完全理解 LVM 在物理設備上的確切位置,所以如果我對我的術語感到困惑,請更正它。(PV 是物理設備,一個 VG 位於一個或多個 PV 之上,一個 VG 中有一個或多個 LV,有點像傳統硬碟中的分區?)

我目前的 lvm.conf(由 提供lvm dumpconf)是:

 devices {
    dir="/dev"
    scan="/dev/disk"
    preferred_names=[]
    filter="a/.*/"
    cache_dir="/etc/lvm/cache"
    cache_file_prefix=""
    write_cache_state=1
    sysfs_scan=1
    md_component_detection=1
    md_chunk_alignment=1
    data_alignment_detection=1
    data_alignment=0
    data_alignment_offset_detection=1
    ignore_suspended_devices=0
  }
  dmeventd {
    mirror_library="libdevmapper-event-lvm2mirror.so"
    snapshot_library="libdevmapper-event-lvm2snapshot.so"
  }
  activation {
    udev_sync=1
    missing_stripe_filler="error"
    reserved_stack=256
    reserved_memory=8192
    process_priority=-18
    mirror_region_size=512
    readahead="auto"
    mirror_log_fault_policy="allocate"
    mirror_device_fault_policy="remove"
  }
  global {
    umask=63
    test=0
    units="h"
    si_unit_consistency=1
    activation=1
    proc="/proc"
    locking_type=1
    wait_for_locks=1
    fallback_to_clustered_locking=1
    fallback_to_local_locking=1
    locking_dir="/var/lock/lvm"
    prioritise_write_locks=1
  }
  shell {
    history_size=100
  }
  backup {
    backup=1
    backup_dir="/etc/lvm/backup"
    archive=1
    archive_dir="/etc/lvm/archive"
    retain_min=10
    retain_days=30
  }
  log {
    verbose=0
    syslog=1
    overwrite=0
    level=0
    indent=1
    command_names=0
    prefix="  "
  }

編輯:似乎 LVM 拒絕掃描 MD 設備。

dandroid@tinuvael:/etc/lvm$ sudo vgcfgrestore --test --verbose media
 Test mode: Metadata will NOT be updated.
 Wiping cache of LVM-capable devices
 Couldn't find device with uuid 'iTmyql-LYQv-N1GD-6aM0-BHco-uHEe-taHhBI'.
 Cannot restore Volume Group media with 1 PVs marked as missing.
 Restore failed.
 Test mode: Wiping internal cache
 Wiping internal VG cache

dandroid@tinuvael:/etc/lvm$ sudo blkid

/dev/md0: UUID="iTmyql-LYQv-N1GD-6aM0-BHco-uHEe-taHhBI" TYPE="LVM2_member" /dev/sdc: UUID="b81c877f-6542-d03b-4e08-ceb6032f5cfe" TYPE="linux_raid_member" /dev/sdd: UUID="b81c877f-6542-d03b-4e08-ceb6032f5cfe" TYPE="linux_raid_member"

types = [ "md", 16 ]我已經修剪了幾行不相關的行,但上面顯示了 raid 陣列已安裝並且具有 LVM 正在搜尋的 UUID,但在添加到我的配置後它仍然繼續忽略該設備。

事實證明,這些驅動器添加了分區表(可能是當我四處亂逛並試圖讓 BIOS 在啟動時引導正確的驅動器時),並且 LVM 絕對拒絕查看包含分區表的設備。使用 清空分區表後fdisk,LVM 檢測到卷組完全正常。

引用自:https://serverfault.com/questions/186951