如何在 Ubuntu Server 16.04 上调整 RAID 分区的大小

mam*_*udi 4 raid ubuntu partition raid1 ubuntu-16.04

最近我们在服务器上配置了一个 Ubuntu 16.04。我们有两个 256 GB 的 SSD。过了一会儿,我们发现我们的主 RAID 分区只有 20GB,而其他分区有 200GB 以上。

这是fdisk -l打印出来的:

Disk /dev/sda: 238.5 GiB, 256060514304 bytes, 500118192 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
Disklabel type: dos
Disk identifier: 0x807adac1

Device     Boot    Start       End   Sectors   Size Id Type
/dev/sda1  *        2048    614399    612352   299M fd Linux raid autodetect
/dev/sda2         614400   1662975   1048576   512M 82 Linux swap / Solaris
/dev/sda3        1662976  43606015  41943040    20G fd Linux raid autodetect
/dev/sda4       43606016 500117503 456511488 217.7G fd Linux raid autodetect


Disk /dev/sdb: 238.5 GiB, 256060514304 bytes, 500118192 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
Disklabel type: dos
Disk identifier: 0x9a57a62a

Device     Boot    Start       End   Sectors   Size Id Type
/dev/sdb1  *        2048    614399    612352   299M fd Linux raid autodetect
/dev/sdb2         614400   1662975   1048576   512M 82 Linux swap / Solaris
/dev/sdb3        1662976  43606015  41943040    20G fd Linux raid autodetect
/dev/sdb4       43606016 500117503 456511488 217.7G fd Linux raid autodetect


Disk /dev/md0: 298.7 MiB, 313196544 bytes, 611712 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 /dev/md2: 217.6 GiB, 233599664128 bytes, 456249344 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 /dev/md1: 20 GiB, 21458059264 bytes, 41910272 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
Run Code Online (Sandbox Code Playgroud)

问题是每次我们想在我们的主分区 /dev/md1 上安装或运行新的东西时,我们的空间都用完了。

问题是,我们怎样才能摆脱这种情况呢?有没有办法在/dev/md2旁边使用,/dev/md1这样我们就不会遇到空间不足的磁盘问题,甚至缩小/dev/md2和增长/dev/md1

我们遵循了很多教程,但没有调整大小/dev/md1

Ter*_*nen 6

在您的情况下避免空间问题的推荐方法是将现有目录移动到 中的文件系统/dev/md2,并使用符号链接指向新目录。

调整 MD 设备的大小是一个更复杂的过程:

  1. 复制所有内容/dev/md2到另一个地方
  2. 删除/dev/md2设备和分区/dev/sda4以及/dev/sdb4哪些是 RAID 成员。
  3. 增加的大小/dev/sda3/dev/sdb3分区你想要的大小。
  4. 使用mdadm --grow增加的大小/dev/md1相匹配底层分区的大小。
  5. 重新创建/dev/sda4/dev/sdb4分区并在它们之上创建 RAID 阵列。
  6. 将数据复制回分区。

之所以要做这一切,是因为MD设备是由磁盘分区组成的,而分区是硬盘中的单个区域。因此,您必须释放分区后的空间才能增加它。

如果使用逻辑卷管理器 (LVM),增加文件系统的大小会更容易。