【问题标题】:Vagrant disk partition doesn't match Debian filesystem (partition is larger)Vagrant 磁盘分区与 Debian 文件系统不匹配(分区较大)
【发布时间】:2018-05-03 03:47:56
【问题描述】:

我正在尝试使用 debian/stretch64 框(即 Debian 9)重建开发虚拟机。我在 MacOS Sierra 10.12.6 上使用 Vagrant 2.0.2 和 VirtualBox 5.2.6)。

在我的 Vagrantfile 中,我指定了一个 30GB 的磁盘:

config.disksize.size = "30GB"

Virtual Media Manager(VirtualBox 中的文件菜单)将stretch.vdi 的“虚拟大小”(容量)显示为30GB。 VBoxManage showhdinfo "stretch.vdi" 也给了我相同的信息,并表明它是一个 dynamic default(即可调整大小)磁盘,与 .vmdk 不同。

然而,Debian 报告的文件系统要小得多:

/dev/sda1       8.7G  8.7G     0 100% /

(它确实有一些空间,但是在启动时 rsync 一个大型共享文件夹会不断填满它)。

满载之前:

  • 我运行 sudo cfdisk /dev/sda 发现卷报告了 20.1G 可用空间,而 /dev/sda1 上只有 8.7G。
  • 我还使用了apt-get install lvm2,这样我就有了管理卷的工具。

然后我使用fdisk(不是 curses 版本)重新配置分区(即我将它们全部删除,将第一个分区设为 29G,并添加一个扩展的 1G 分区,并将“类型”设置为 Linux 交换)。

虽然我看到消息“重新读取分区表失败。设备或资源忙。”,重启后cfdisk /dev/sda 输出看起来都正确:

    Device          Boot            Start         End     Sectors     Size    Id Type
>>  /dev/sda1                        2048    60819455    60817408      29G    83 Linux
    /dev/sda2                    60819456    62914559     2095104    1023M     5 Extended
    └─/dev/sda5                  60821504    62914559     2093056    1022M    82 Linux swap / Solaris

不过,df 仍然返回:

/dev/sda1       8.7G  8.7G     0 100% /

各种教程都提到了 pvcreatepvresize,但是对于后者,我得到了:

sudo pvresize /dev/sda
  Failed to find physical volume "/dev/sda".
  0 physical volume(s) resized / 0 physical volume(s) not resized

这是我完整的 fdisk -l 输出:

Disk /dev/sda: 30 GiB, 32212254720 bytes, 62914560 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: 0xe133a040

Device     Boot    Start      End  Sectors  Size Id Type
/dev/sda1           2048 60819455 60817408   29G 83 Linux
/dev/sda2       60819456 62914559  2095104 1023M  5 Extended
/dev/sda5       60821504 62914559  2093056 1022M 82 Linux swap / Solaris

我还应该做什么才能让 Debian 看到完整的 29G?

【问题讨论】:

    标签: vagrant debian partitioning


    【解决方案1】:

    简单地修复:

    sudo resize2fs /dev/sda1
    

    现在我有:

    /dev/sda1        29G  8.7G   19G  32% /
    

    我找到了in this answer

    (已投票结束我自己的问题)。

    【讨论】:

      猜你喜欢
      • 2012-11-27
      • 2012-03-24
      • 1970-01-01
      • 1970-01-01
      • 2016-06-04
      • 2020-01-16
      • 2023-03-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多