添加了/dev/vdb
2TB的新磁盘(),其中包含先前1TB磁盘中的现有数据。
我曾经fdisk /dev/vdb
将其唯一的分区扩展/dev/vdb1
到以前的1TB的完整容量2TB。然后我做了:
[root - /]$ fsck -n /dev/vdb1
fsck from util-linux 2.23.2
e2fsck 1.42.9 (28-Dec-2013)
/dev/vdb1: clean, 46859496/65536000 files, 249032462/262143744 blocks
[root - /]$ e2fsck -f /dev/vdb1
e2fsck 1.42.9 (28-Dec-2013)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/vdb1: 46859496/65536000 files (0.4% non-contiguous), 249032462/262143744 blocks
[root - ~]$ resize2fs /dev/vdb1
resize2fs 1.42.9 (28-Dec-2013)
The filesystem is already 262143744 blocks long. Nothing to do!
而且fdisk -l
是这样的:
Disk /dev/vdb: 2147.5 GB, 2147483648000 bytes, 4194304000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x4eb4fbf8
Device Boot Start End Blocks Id System
/dev/vdb1 2048 4194303999 2097150976 83 Linux
但是,当我安装它时:
mount /dev/vdb1 /mnt
这是我从中得到的df -h
:
/dev/vdb1 985G 935G 0 100% /mnt
仍然是前一个分区的大小。
我在这里做错了什么?
冉partprobe
并建议我重新启动:
Error: Error informing the kernel about modifications to partition /dev/vdb1 -- Device or resource busy. This means Linux won't know about any changes you made to /dev/vdb1 until you reboot -- so you shouldn't mount it or use it in any way before rebooting.
Error: Failed to add partition 1 (Device or resource busy)
因此,我重新启动,然后再次运行:
mount /dev/vdb1 /mnt
但是添加的文件系统仍然是:
/dev/vdb1 985G 935G 0 100% /mnt
任何的想法?我应该做的一切fsck
,e2fsck
以及resize2fs
再一次?
真奇怪。重新启动后,我partprobe
再次运行,仍然是此错误:
Error: Error informing the kernel about modifications to partition /dev/vdb1 -- Device or resource busy. This means Linux won't know about any changes you made to /dev/vdb1 until you reboot -- so you shouldn't mount it or use it in any way before rebooting.
Error: Failed to add partition 1 (Device or resource busy)
为什么设备或资源繁忙?重新启动后仍然如此吗?
resize2fs
从内核读取分区大小,类似于读取任何其他文件的大小。fdisk
尝试在写入分区表时更新内核,但是如果磁盘正在使用中,它将失败-例如,如果您已安装了其中一个分区。这就是为什么resize2fs
显示“无事可做”的信息的原因;它没有看到额外的分区空间。
内核在启动过程中读取分区表。因此,您可以简单地重新启动计算机。然后,您可以运行resize2fs
,它将看到额外的分区空间,并扩展文件系统使其适合。
我相信fdisk
在此文档中会记录一个突出的消息,如本文档(否则已过时)中所截屏所示。
这里有一个不太友好但实际上是最新的文档:
https://access.redhat.com/solutions/57542
如何在RHEL6中使用新分区而无需重新启动?
partprobe
通常在RHEL 5中用于通知OS磁盘上的分区表更改。在RHEL 6中,它将仅触发OS更新磁盘上未使用任何分区(例如已安装)的分区。如果正在使用磁盘上的任何分区,则partprobe不会触发OS更新系统中的分区,因为在某些情况下它被认为是不安全的。因此,一般而言,我们建议:
- 在修改磁盘上的分区表之前,先卸载磁盘的所有分区,然后运行
partprobe
以更新系统中的分区。- 如果不可能(例如,已安装的分区是系统分区),请在修改分区表后重新引导系统。重新启动后将重新读取分区信息。如果添加了新分区,但没有修改任何现有分区,请考虑使用partx命令来更新系统分区表。请注意,partx命令不会在系统中的新分区表和现有分区表之间做很多检查,并假设用户知道他们在做什么。因此,如果修改了现有分区或未正确设置分区表,它可能会损坏磁盘上的数据。因此,使用风险自负。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句