Linux-Gast (in VirtualBox) verwendet nicht den gesamten Speicherplatz der dynamischen VDI-Festplatte

624
TedGrassman

Ich habe ein Problem mit meiner virtuellen Festplatte in VirtualBox, einem Linux-CentOS-Guest. Ich verwende keine Schnappschüsse.

Es war anfangs eine 8-GB-Platte, die ich mithilfe des VBoxManage modifyhdBefehls innerhalb des Host auf 16 GB erweitert habe . Ich habe dann ein GParted liveBild verwendet, um die Größe der Partition innerhalb des Gasts zu ändern. Der Datenträger und die VM haben den Host geändert (jedoch dieselbe Version von VirtualBox).

Jetzt habe ich meine Festplatte voll und habe keinen Platz mehr.

Betrachten GParted: /boot (/dev/sda1)hat eine Größe von 1 GB und / (/dev/sda2)hat eine Größe von 15 GB: GParted live

Aber schau nach df:

[ted@localhost ~]$ df -Th Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/cl-root xfs 6,0G 5,9G 106M 99% / devtmpfs devtmpfs 986M 0 986M 0% /dev tmpfs tmpfs 1001M 100K 1001M 1% /dev/shm tmpfs tmpfs 1001M 8,8M 992M 1% /run tmpfs tmpfs 1001M 0 1001M 0% /sys/fs/cgroup tmpfs tmpfs 1001M 32K 1001M 1% /tmp /dev/sda1 xfs 1014M 235M 780M 24% /boot tmpfs tmpfs 201M 8,0K 201M 1% /run/user/1000 

Die Größe der Wurzel ist 6 GB, bestätigt von fdisk -l. Die Größe der Festplatte beträgt jedoch 16 + GB:

[ted@localhost ~]$ sudo fdisk -l  Disk /dev/sda: 17.2 GB, 17179869184 bytes, 33554432 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: 0x000140ff  Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 33554431 15727616 8e Linux LVM  Disk /dev/mapper/cl-root: 6442 MB, 6442450944 bytes, 12582912 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/mapper/cl-swap: 1069 MB, 1069547520 bytes, 2088960 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 

Nur um das zu klären, sind tmpfs-Partitionen im RAM eingebaut, oder? Es gibt keine Möglichkeit, dass diese Dateien Speicherplatz verwenden, oder?

Ich habe auch viel Platz auf der Host-Festplatte.

Ich habe diesen Beitrag gesehen. Linux VirtualBox Guest muss alle virtuellen Laufwerke verfügbar machen (keine Momentaufnahmen), aber meine Situation scheint etwas anders zu sein, da ich die Partition verkleinert habe und der Speicherplatz in pvdisplay:

[tnodet@localhost ~]$ sudo pvdisplay --- Physical volume --- PV Name /dev/sda2 VG Name cl PV Size 15,00 GiB / not usable 2,00 MiB Allocatable yes  PE Size 4,00 MiB Total PE 3839 Free PE 2048 Allocated PE 1791 PV UUID rrG0JE-i1MB-IeA0-Ce5c-dpj7-Fwm2-RMjyYb 

Auf einem Windows 10-Host:

D:\Profiles\ted\VirtualBox VMs\CentOS-CKAN>VBoxManage showhdinfo CentOS-CKAN.vdi UUID: 76d3524e-803c-4d1e-816d-5bc705e26aac Parent UUID: base State: locked write Type: writethrough Location: d:\Profiles\ted\VirtualBox VMs\CentOS-CKAN\CentOS-CKAN.vdi Storage format: VDI Format variant: dynamic default Capacity: 16384 MBytes Size on disk: 6413 MBytes Encryption: disabled In use by VMs: CentOS-CKAN (UUID: 1e96120c-17a3-4892-8d98-dd88eed429db) 

Ich bin verloren und ziemlich verwirrt, ich kann nicht einmal herausfinden, ob das Problem vom Windows-Host / der VirtualBox oder vom Linux-Gast stammt.

Irgendwelche Ideen? Danke im Voraus!


Andere Befehle:

[ted@localhost ~]$ ll /dev/disk/by-id total 0 lrwxrwxrwx. 1 root root 9 20 sept. 12:16 ata-VBOX_CD-ROM_VB2-01700376 -> ../../sr0 lrwxrwxrwx. 1 root root 9 20 sept. 12:16 ata-VBOX_HARDDISK_VB76d3524e-ac6ae205 -> ../../sda lrwxrwxrwx. 1 root root 10 20 sept. 12:16 ata-VBOX_HARDDISK_VB76d3524e-ac6ae205-part1 -> ../../sda1 lrwxrwxrwx. 1 root root 10 20 sept. 12:16 ata-VBOX_HARDDISK_VB76d3524e-ac6ae205-part2 -> ../../sda2 lrwxrwxrwx. 1 root root 10 20 sept. 12:16 dm-name-cl-root -> ../../dm-0 lrwxrwxrwx. 1 root root 10 20 sept. 12:16 dm-name-cl-swap -> ../../dm-1 lrwxrwxrwx. 1 root root 10 20 sept. 12:16 dm-uuid-LVM-AFXgxjJZSLDRCWckAVMMKzthSc5hNl6cbrtdWs4fPXZIoe1O6Wy0qh2xoreIY8tw -> ../../dm-1 lrwxrwxrwx. 1 root root 10 20 sept. 12:16 dm-uuid-LVM-AFXgxjJZSLDRCWckAVMMKzthSc5hNl6cmYPaZX60S5aAvfejEltFs2vMPmIlRkuV -> ../../dm-0 lrwxrwxrwx. 1 root root 10 20 sept. 12:16 lvm-pv-uuid-rrG0JE-i1MB-IeA0-Ce5c-dpj7-Fwm2-RMjyYb -> ../../sda2 
1

1 Antwort auf die Frage

1
TedGrassman

Ich habe es herausgefunden; Es hatte mit logischen Volumina zu tun, mit denen ich mich nicht sehr wohl fühle.

Wie Sie sich vorstellen können fdisk -l, wurde die physische Partition sda2in zwei logische Volumes unterteilt /dev/cl/rootund/dev/cl/swap in eine Volume-Gruppe gruppiert cl:

[root@localhost ted]# vgscan Reading volume groups from cache. Found volume group "cl" using metadata type lvm2  [root@localhost ted]# lvscan ACTIVE '/dev/cl/root' [6,00 GiB] inherit ACTIVE '/dev/cl/swap' [1020,00 MiB] inherit 
  1. Also habe ich zuerst das logische Swap-Volume entfernt ( 5.3.2. Entfernen eines logischen LVM2-Volumes für Swap ).

    [root@localhost ted]# swapoff -v /dev/cl/swap swapoff /dev/cl/swap  [root@localhost ted]# lvremove /dev/cl/swap Do you really want to remove active logical volume cl/swap? [y/n]: y Logical volume "swap" successfully removed 

    Kommentierte Zeile in /etc/fstab:

    #/dev/cl/swap swap swap defaults 0 0 
  2. Dann musste ich die Größe des logischen Stammvolumes ändern :

    [root@localhost ted]# lvextend -L+8G /dev/cl/root 
  3. Schließlich musste ich die Größe des Root-Dateisystems ändern . Ich habe Probleme beim Versuch, den resize2fsBefehl zu verwenden (weil XFS nicht unterstützt wird, siehe resize2fs: Ungültige magische Zahl im Superblock beim Versuch, sich zu öffnen ), xfs_growfstat aber den Trick:

    [root@localhost ted]# xfs_growfs /dev/cl/root meta-data=/dev/mapper/cl-root isize=512 agcount=4, agsize=393216 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0 data = bsize=4096 blocks=1572864, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 1572864 to 3670016 

Ich habe jetzt 14 GB Speicherplatz auf / dev / mapper / cl-root :)