我们可以用这个文件做什么:/sys/block/md0/md/fail_last_dev
?
我在手册页中找不到有关它的任何信息md
。在部分中SYSFS INTERFACE
它说:This interface is documented more fully in the file Documentation/md.txt
。但我在那里也找不到fail_last_dev
。它只在代码中。
我们可以用这个文件做什么:/sys/block/md0/md/fail_last_dev
?
我在手册页中找不到有关它的任何信息md
。在部分中SYSFS INTERFACE
它说:This interface is documented more fully in the file Documentation/md.txt
。但我在那里也找不到fail_last_dev
。它只在代码中。
令我惊讶的是,CentOS 7 安装程序允许我创建一个由大约 17 GB 磁盘和 26 GB 磁盘组成的 RAID0 设备。我原以为即使它允许,逻辑大小也会是2 * min(17 GB, 26 GB) ~= 34 GB
. 然而,我确实可以在文件系统级别看到 44 GB 的可用大小:
$ cat /sys/block/md127/md/dev*/size
16955392
26195968
$ df -h |grep md
/dev/md127 44G 1.9G 40G 5% /
与磁盘相等的情况相比,md 子系统的性能表现如何?因为不可能在 2 个磁盘上做一个简单的平衡条带。
我在 Ubuntu 18.04 上运行 4 个 3TB 磁盘的 mdadm RAID 5 阵列,总大小为 9TB。它在 gnome 磁盘实用程序中显示为 9.0 TB RAID-5 阵列,使用量为 799 GB,这意味着我有超过 8T 的数据。
然后我买了一台 NAS 并开始将数据从 RAID 复制到新磁盘。复制在 4 小时后完成,没有错误。复制后,新盘只用了5.2TB。
当我使用 gnome-files 计算 RAID-5 阵列上文件的总数/大小时,它显示可用空间只有 498.9 GB,这意味着我有 9T - 500G = 8.5T 数据?
我终于du
在 RAID 和 nas 磁盘上都使用了。结果显示两者都是4.7T。
为什么会有差异,哪个数字是正确的?
我正在使用 设置两个 RAID 1 阵列mdadm
,它似乎工作正常,但是当我进行检查时,lsblk
我看到以下内容:
sda 8:0 0 5,5T 0 disk
└─md127 9:127 0 5,5T 0 raid1
├─data-crypt-1 253:5 0 5,5T 0 crypt
│ └─myVg-data 253:6 0 5,5T 0 lvm
├─md127p1 259:5 0 182,4G 0 md
└─md127p2 259:6 0 1,2T 0 md
sdb 8:16 0 5,5T 0 disk
└─md127 9:127 0 5,5T 0 raid1
├─data-crypt-1 253:5 0 5,5T 0 crypt
│ └─myVg-data 253:6 0 5,5T 0 lvm
├─md127p1 259:5 0 182,4G 0 md
└─md127p2 259:6 0 1,2T 0 md
sdc 8:32 0 5,5T 0 disk
└─md126 9:126 0 5,5T 0 raid1
sdd 8:48 0 5,5T 0 disk
└─md126 9:126 0 5,5T 0 raid1
这些分区(?)在我md127p1
的md127p2
阵列中是什么?我应该删除它们吗?如果是,如何删除?
它似乎没有干扰阵列,它似乎正在按预期重新同步。但是我担心,例如,如果有人要挂载说md127p1
并向它写一些东西,它会破坏其中的数据data-crypt-1
(跨越整个驱动器)。
编辑:
重新启动和重新组装后问题(如果是问题)仍然存在。
sudo wipefs --no-act /dev/md127
# DEVICE OFFSET TYPE UUID LABEL
# md127 0x0 crypto_LUKS ba3eab9b-db06-4053-9eb8-4e674931148c
dmesg
md126
确实报告和之间的行为略有不同md127
。不知道如何检查“背景重建”。
dmesg | grep "md12[67]"
# [ 3.072445] md/raid1:md127: not clean -- starting background reconstruction
# [ 3.072445] md/raid1:md127: active with 2 out of 2 mirrors
# [ 3.107577] md127: detected capacity change from 0 to 6001039835136
# [ 3.112944] md127: AHDI p1 p2 p3
# [ 4.072578] md/raid1:md126: active with 2 out of 2 mirrors
# [ 4.105528] md126: detected capacity change from 0 to 6001039835136
# [ 175.221344] md127: AHDI p1 p2 p3
# [ 252.627169] md127: AHDI p1 p2 p3
# [ 337.950292] md127: AHDI p1 p2 p3
并udevadm
报告如下:
udevadm info /dev/md127p1
# P: /devices/virtual/block/md127/md127p1
# N: md127p1
# L: 100
# S: disk/by-id/md-name-XYZ:data-array-1-part1
# S: disk/by-id/md-uuid-94gd622:d96sf22:9fb73768:dae5367e-part1
# S: md/XYZ:data-array-1p1
# E: DEVLINKS=/dev/md/XYZ:data-array-1p1 /dev/disk/by-id/md-name-XYZ:data-array-1-part1 /dev/disk/by-id/md-uuid-94gd622:d96sf22:9fb73768:dae5367e-part1
# E: DEVNAME=/dev/md127p1
# E: DEVPATH=/devices/virtual/block/md127/md127p1
# E: DEVTYPE=partition
# E: MAJOR=259
# E: MD_DEVICES=2
# E: MD_DEVICE_ev_sda_DEV=/dev/sda
# E: MD_DEVICE_ev_sda_ROLE=0
# E: MD_DEVICE_ev_sdb_DEV=/dev/sdb
# E: MD_DEVICE_ev_sdb_ROLE=1
# E: MD_DEVNAME=XYZ:data-array-1
# E: MD_LEVEL=raid1
# E: MD_METADATA=1.2
# E: MD_NAME=XYZ:data-array-1
# E: MD_UUID=94gd622:d96sf22:9fb73768:dae5367e
# E: MINOR=5
# E: PARTN=1
# E: SUBSYSTEM=block
# E: SYSTEMD_WANTS=mdmonitor.service
# E: TAGS=:systemd:
# E: USEC_INITIALIZED=337999178
udevadm info /dev/md127p2
# P: /devices/virtual/block/md127/md127p2
# N: md127p2
# L: 100
# S: disk/by-id/md-name-XYZ:data-array-1-part2
# S: disk/by-id/md-uuid-94gd622:d96sf22:9fb73768:dae5367e-part2
# S: md/XYZ:data-array-1p2
# E: DEVLINKS=/dev/disk/by-id/md-name-XYZ:data-array-1-part2 /dev/disk/by-id/md-uuid-94gd622:d96sf22:9fb73768:dae5367e-part2 /dev/md/XYZ:data-array-1p2
# E: DEVNAME=/dev/md127p2
# E: DEVPATH=/devices/virtual/block/md127/md127p2
# E: DEVTYPE=partition
# E: MAJOR=259
# E: MD_DEVICES=2
# E: MD_DEVICE_ev_sda_DEV=/dev/sda
# E: MD_DEVICE_ev_sda_ROLE=0
# E: MD_DEVICE_ev_sdb_DEV=/dev/sdb
# E: MD_DEVICE_ev_sdb_ROLE=1
# E: MD_DEVNAME=XYZ:data-array-1
# E: MD_LEVEL=raid1
# E: MD_METADATA=1.2
# E: MD_NAME=XYZ:data-array-1
# E: MD_UUID=94gd622:d96sf22:9fb73768:dae5367e
# E: MINOR=6
# E: PARTN=2
# E: SUBSYSTEM=block
# E: SYSTEMD_WANTS=mdmonitor.service
# E: TAGS=:systemd:
# E: USEC_INITIALIZED=337999612
hexdump
显示:
sudo hexdump -C -n 512 /dev/md127
# *
# *
# 000001c0 7c e8 03 4d 62 32 d5 66 37 75 6b e9 12 6d 16 cc ||..Mb2.f7uk..m..|
# 000001d0 96 9e 6f 3d 32 e0 e7 fe 7f f4 9c a1 59 03 19 47 |..o=2.......Y..G|
# 000001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
# *
我还注意到我在某些机器上看不到“幽灵”分区,尤其是我的 DietPi 机器上没有显示它们。它们确实显示在我的 Ubuntu 机器上。此外,我注意到两个阵列(md126 和 md127)都是在其中一台 DietPi 机器上创建的。
我一直在研究这种行为的可能原因:
INFO: task md1_raid10:240 blocked for more than 120 seconds.
[123491.284102] Not tainted 4.18.20 #1
[123491.284105] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[123491.284109] md1_raid10 D 0 240 2 0x80000000
[123491.284116] Call Trace:
[123491.284132] ? __schedule+0x421/0x8c0
[123491.284138] ? preempt_count_add+0x67/0xb0
[123491.284144] schedule+0x3c/0x90
[123491.284162] md_super_wait+0x69/0xa0 [md_mod]
[123491.284173] ? remove_wait_queue+0x60/0x60
[123491.284184] md_update_sb.part.61+0x4ad/0x900 [md_mod]
[123491.284197] md_check_recovery+0x310/0x530 [md_mod]
[123491.284205] raid10d+0x64/0x15a0 [raid10]
[123491.284211] ? __schedule+0x429/0x8c0
[123491.284216] ? schedule+0x46/0x90
[123491.284220] ? schedule_timeout+0x1f7/0x370
[123491.284224] ? preempt_count_add+0x67/0xb0
[123491.284229] ? _raw_spin_lock_irqsave+0x25/0x50
[123491.284232] ? preempt_count_add+0x67/0xb0
[123491.284243] ? md_thread+0x120/0x160 [md_mod]
[123491.284252] md_thread+0x120/0x160 [md_mod]
[123491.284258] ? remove_wait_queue+0x60/0x60
[123491.284263] kthread+0xf8/0x130
[123491.284272] ? md_rdev_init+0xc0/0xc0 [md_mod]
[123491.284277] ? kthread_create_worker_on_cpu+0x70/0x70
[123491.284281] ret_from_fork+0x22/0x40
我发现的所有内容,包括 stackexchange 都指向系统负载较重的一些恶劣的服务器条件。在我的情况下,它发生在以 Raid1+0 配置托管 4HHS 的系统中,这是全新的,实际上该系统刚刚在昨天设置并且几乎不包含任何数据。在通过 SMB 客户端列出主目录(仅包含 10 个文件)期间发生挂断。
此系统上的磁盘使用 dm_crypt 加密。没有使用 LVM。
root@stasiek1:/home/lacki# cat /proc/mdstat
Personalities : [raid10] [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4]
md1 : active raid10 sdd3[3] sdb3[1] sda3[0] sdc3[2]
7225882624 blocks super 1.2 512K chunks 2 near-copies [4/4] [UUUU]
bitmap: 1/54 pages [4KB], 65536KB chunk
md0 : active raid10 sdd2[3] sda2[0] sdc2[2] sdb2[1]
585674752 blocks super 1.2 512K chunks 2 near-copies [4/4] [UUUU]
bitmap: 3/5 pages [12KB], 65536KB chunk
unused devices: <none>
root@stasiek1:/home/lacki# mdadm --detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Sat Dec 29 22:59:44 2018
Raid Level : raid10
Array Size : 585674752 (558.54 GiB 599.73 GB)
Used Dev Size : 292837376 (279.27 GiB 299.87 GB)
Raid Devices : 4
Total Devices : 4
Persistence : Superblock is persistent
Intent Bitmap : Internal
Update Time : Tue Jan 29 22:14:24 2019
State : clean
Active Devices : 4
Working Devices : 4
Failed Devices : 0
Spare Devices : 0
Layout : near=2
Chunk Size : 512K
Name : stasiek1:0 (local to host stasiek1)
UUID : d12a1437:ab040229:dbc0f4bf:796a97dd
Events : 768
Number Major Minor RaidDevice State
0 8 2 0 active sync set-A /dev/sda2
1 8 18 1 active sync set-B /dev/sdb2
2 8 34 2 active sync set-A /dev/sdc2
3 8 50 3 active sync set-B /dev/sdd2
root@stasiek1:/home/lacki# mdadm --detail /dev/md1
/dev/md1:
Version : 1.2
Creation Time : Sat Dec 29 23:00:13 2018
Raid Level : raid10
Array Size : 7225882624 (6891.14 GiB 7399.30 GB)
Used Dev Size : 3612941312 (3445.57 GiB 3699.65 GB)
Raid Devices : 4
Total Devices : 4
Persistence : Superblock is persistent
Intent Bitmap : Internal
Update Time : Tue Jan 29 22:13:37 2019
State : clean
Active Devices : 4
Working Devices : 4
Failed Devices : 0
Spare Devices : 0
Layout : near=2
Chunk Size : 512K
Name : stasiek1:1 (local to host stasiek1)
UUID : bdf36256:191923e1:01254e05:8bc447c9
Events : 7357
Number Major Minor RaidDevice State
0 8 3 0 active sync set-A /dev/sda3
1 8 19 1 active sync set-B /dev/sdb3
2 8 35 2 active sync set-A /dev/sdc3
3 8 51 3 active sync set-B /dev/sdd3
系统:内核:4.18。Debian 伸展
我正在尝试从四个磁盘创建 raid 5:
Disk /dev/sdc: 8001.6 GB, 8001563222016 bytes
/dev/sdc1 2048 4294967294 2147482623+ fd Linux raid autodetect
Disk /dev/sdb: 8001.6 GB, 8001563222016 bytes
/dev/sdb1 2048 4294967294 2147482623+ fd Linux raid autodetect
Disk /dev/sdd: 24003.1 GB, 24003062267904 bytes
/dev/sdd1 2048 4294967294 2147482623+ fd Linux raid autodetect
Disk /dev/sde: 8001.6 GB, 8001563222016 bytes
/dev/sde1 2048 4294967294 2147482623+ fd Linux raid autodetect
但是,创建后我只有 6T 空间(我的一个磁盘):
/dev/md0 ext4 6.0T 184M 5.7T 1% /mnt/raid5
这是我创建过程的其他信息:
结果mdadm -E /dev/sd[b-e]1
:
/dev/sdb1:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : 8953b4f1:61212c46:b0a63144:25eb4a7d
Name : node7:0 (local to host node7)
Creation Time : Fri Sep 7 09:16:42 2018
Raid Level : raid5
Raid Devices : 4
Avail Dev Size : 4294703103 (2047.87 GiB 2198.89 GB)
Array Size : 6442053120 (6143.62 GiB 6596.66 GB)
Used Dev Size : 4294702080 (2047.87 GiB 2198.89 GB)
Data Offset : 262144 sectors
Super Offset : 8 sectors
State : clean
Device UUID : 2fcb3346:9ed69eab:64c6f851:0bcc39c4
Update Time : Fri Sep 7 13:17:38 2018
Checksum : c701ff7e - correct
Events : 18
Layout : left-symmetric
Chunk Size : 512K
Device Role : Active device 0
Array State : AAAA ('A' == active, '.' == missing)
/dev/sdc1:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : 8953b4f1:61212c46:b0a63144:25eb4a7d
Name : node7:0 (local to host node7)
Creation Time : Fri Sep 7 09:16:42 2018
Raid Level : raid5
Raid Devices : 4
Avail Dev Size : 4294703103 (2047.87 GiB 2198.89 GB)
Array Size : 6442053120 (6143.62 GiB 6596.66 GB)
Used Dev Size : 4294702080 (2047.87 GiB 2198.89 GB)
Data Offset : 262144 sectors
Super Offset : 8 sectors
State : clean
Device UUID : 6f13c9f0:de2d4c6f:cbac6b87:67bc483e
Update Time : Fri Sep 7 13:17:38 2018
Checksum : e4c675c2 - correct
Events : 18
Layout : left-symmetric
Chunk Size : 512K
Device Role : Active device 1
Array State : AAAA ('A' == active, '.' == missing)
/dev/sdd1:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : 8953b4f1:61212c46:b0a63144:25eb4a7d
Name : node7:0 (local to host node7)
Creation Time : Fri Sep 7 09:16:42 2018
Raid Level : raid5
Raid Devices : 4
Avail Dev Size : 4294703103 (2047.87 GiB 2198.89 GB)
Array Size : 6442053120 (6143.62 GiB 6596.66 GB)
Used Dev Size : 4294702080 (2047.87 GiB 2198.89 GB)
Data Offset : 262144 sectors
Super Offset : 8 sectors
State : clean
Device UUID : 4dab38e6:94c5052b:06d6b6b0:34a41472
Update Time : Fri Sep 7 13:17:38 2018
Checksum : f306b65f - correct
Events : 18
Layout : left-symmetric
Chunk Size : 512K
Device Role : Active device 2
Array State : AAAA ('A' == active, '.' == missing)
/dev/sde1:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : 8953b4f1:61212c46:b0a63144:25eb4a7d
Name : node7:0 (local to host node7)
Creation Time : Fri Sep 7 09:16:42 2018
Raid Level : raid5
Raid Devices : 4
Avail Dev Size : 4294703103 (2047.87 GiB 2198.89 GB)
Array Size : 6442053120 (6143.62 GiB 6596.66 GB)
Used Dev Size : 4294702080 (2047.87 GiB 2198.89 GB)
Data Offset : 262144 sectors
Super Offset : 8 sectors
State : clean
Device UUID : b04d152e:0448fe56:3b22a2d6:b2504d26
Update Time : Fri Sep 7 13:17:38 2018
Checksum : 40ffd3e7 - correct
Events : 18
Layout : left-symmetric
Chunk Size : 512K
Device Role : Active device 3
Array State : AAAA ('A' == active, '.' == missing)
结果mdadm --detail /dev/md0
:
/dev/md0:
Version : 1.2
Creation Time : Fri Sep 7 09:16:42 2018
Raid Level : raid5
Array Size : 6442053120 (6143.62 GiB 6596.66 GB)
Used Dev Size : 2147351040 (2047.87 GiB 2198.89 GB)
Raid Devices : 4
Total Devices : 4
Persistence : Superblock is persistent
Update Time : Fri Sep 7 13:17:38 2018
State : clean
Active Devices : 4
Working Devices : 4
Failed Devices : 0
Spare Devices : 0
Layout : left-symmetric
Chunk Size : 512K
Name : node7:0 (local to host node7)
UUID : 8953b4f1:61212c46:b0a63144:25eb4a7d
Events : 18
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sdb1
1 8 33 1 active sync /dev/sdc1
2 8 49 2 active sync /dev/sdd1
4 8 65 3 active sync /dev/sde1
结果mkfs.ext4 /dev/md0
mke2fs 1.41.9 (22-Aug-2009)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
402628608 inodes, 1610513280 blocks
80525664 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
49149 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848, 512000000, 550731776, 644972544
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information:
done
This filesystem will be automatically checked every 37 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
然后mkdir /mnt/raid5
和mount /dev/md0 /mnt/raid5/
。
我创建了一个 1 磁盘 RAID0 阵列,目的是最终向其添加更多磁盘,该阵列工作正常。我用(大约)创建了它:
$ mdadm --create /dev/md0 --raid-devices=1 --level=0 /dev/sdb -f
然后我添加了另一个磁盘:
$ mdadm --grow /dev/md0 --add /dev/sdc --raid-devices=2
并且,按照手册,mdadm
将阵列转换为 RAID4 并开始重新同步。手册说该阵列稍后将转换回 RAID0。但是,/etc/mdstat
说完全重新同步需要 2-3 天,我想知道是否可以停止阵列,杀死超级块/dev/sdc
,然后执行以下操作:
$ mdadm --create --assume-clean --verbose /dev/md0 --chunk=512 \
--level=0 --raid-devices=2 /dev/sdb /dev/sdc
而不是等待无用的 RAID4 重新同步?
现在,数组状态是:
$ mdadm --detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : XXXXXXXXXXXXXXXX
Raid Level : raid4
Array Size : 11718754304 (11175.88 GiB 12000.00 GB)
Used Dev Size : 11718754304 (11175.88 GiB 12000.00 GB)
Raid Devices : 3
Total Devices : 2
Update Time : XXXXXXXXXXXXXXXX
State : clean, FAILED, reshaping
Active Devices : 1
Working Devices : 2
Failed Devices : 0
Spare Devices : 1
Chunk Size : 512K
sistency Policy : resync
Reshape Status : 2% complete
Delta Devices : 1, (2->3)
...
[root@centos7 ~]# mdadm --stop /dev/md0
[root@centos7 ~]# mdadm -E /dev/sdb
/dev/sdb:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x44
Array UUID : 5978222a:8f2c320c:c7059108:c3d6dc41
Name : centos7:0 (local to host centos7)
Creation Time : Sat Apr 28 05:15:00 2018
Raid Level : raid4
Raid Devices : 3
Avail Dev Size : 23437508608 (11175.88 GiB 12000.00 GB)
Array Size : 23437508608 (22351.75 GiB 24000.01 GB)
Data Offset : 262144 sectors
New Offset : 260096 sectors
Super Offset : 8 sectors
State : clean
Device UUID : 9a75cd7e:bb469dab:2e0db890:69a68f54
Reshape pos'n : 620094464 (591.37 GiB 634.98 GB)
Delta Devices : 1 (2->3)
Update Time : Wed Aug 1 06:12:00 2018
Bad Block Log : 512 entries available at offset 8 sectors
Checksum : d239a780 - correct
Events : 608
Chunk Size : 512K
Device Role : Active device 0
Array State : AA. ('A' == active, '.' == missing, 'R' == replacing)
[root@centos7 ~]# mdadm -E /dev/sdc
/dev/sdc:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x46
Array UUID : 5978222a:8f2c320c:c7059108:c3d6dc41
Name : centos7:0 (local to host centos7)
Creation Time : Sat Apr 28 05:15:00 2018
Raid Level : raid4
Raid Devices : 3
Avail Dev Size : 23437508608 (11175.88 GiB 12000.00 GB)
Array Size : 23437508608 (22351.75 GiB 24000.01 GB)
Data Offset : 262144 sectors
New Offset : 260096 sectors
Super Offset : 8 sectors
Recovery Offset : 620094464 sectors
State : clean
Device UUID : ce6e93f9:729557dc:a1afc6a4:39b954f9
Reshape pos'n : 620094464 (591.37 GiB 634.98 GB)
Delta Devices : 1 (2->3)
Update Time : Wed Aug 1 06:12:00 2018
Bad Block Log : 512 entries available at offset 264 sectors
Checksum : 5b8389b4 - correct
Events : 608
Chunk Size : 512K
Device Role : Active device 1
Array State : AA. ('A' == active, '.' == missing, 'R' == replacing)
我最近安装了 mdadm 并设置了一个涉及 2 500GIO 驱动器的 raid1 配置。
有没有办法在某处备份 RAID 配置,以便我可以使用单个 mdadm 命令重新加载它,以防我必须重新安装我的系统?
假设我的系统安装在某个 ssd 上,出于某种原因我必须重新安装它。问题是,我已经创建了 RAID1(涉及另外两个磁盘).. 是否可以快速恢复此 RAID1 磁盘而无需执行所有创建步骤(擦除磁盘、创建、同步等)。换句话说,是 RAID 丢失还是 mdadm 可以恢复现有磁盘?