2

Using VMWare Workstation 15 Player (15.5.6) on Win10 host, Ubuntu 18.04 guest. I had originally 10GB disk attached to this VM. Started getting error no space left on device.

Deleted /tmp (rm -rf /tmp/*). Increased the 10GB Disk size to 25GB, added another disk 20GB. But the VM is not recognizing the new disk or the new increased size. (Yes I did restart work station and VM)

:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            2.1G     0  2.1G   0% /dev
tmpfs           422M  6.7M  415M   2% /run
/dev/sda2       9.8G  9.8G     0 100% /
tmpfs           2.1G     0  2.1G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           2.1G     0  2.1G   0% /sys/fs/cgroup
/dev/loop0       97M   97M     0 100% /snap/core/9804
/dev/loop4       18M   18M     0 100% /snap/gedit/605
/dev/loop1       63M   63M     0 100% /snap/gtk-common-themes/1506
/dev/loop2       98M   98M     0 100% /snap/core/9993
/dev/loop3      162M  162M     0 100% /snap/gnome-3-28-1804/128

You can see /dev/sda2 shows 10GB only and 0 aval. So I think this is the problem.

Tried looking at cfdisk - (never used it before) - but somehow it also does not recognize beyond 10GB. Pretty much I can do anything on this VM - barely can boot it - how to solve this.

Update 1

$ sudo fdisk -l

Device     Boot      Start        End    Sectors  Size Id Type
/dev/fd0p1      2425393296 4850786591 2425393296  1.1T 90 unknown
/dev/fd0p2      2425393296 4850786591 2425393296  1.1T 90 unknown
/dev/fd0p3      2425393296 4850786591 2425393296  1.1T 90 unknown
/dev/fd0p4      2425393296 4850786591 2425393296  1.1T 90 unknown

Disk /dev/sdb: 20 GiB, 21474836480 bytes, 41943040 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

GPT PMBR size mismatch (20971519 != 52428799) will be corrected by w(rite).
Disk /dev/sda: 25 GiB, 26843545600 bytes, 52428800 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: gpt
Disk identifier: A6944258-6EA8-4968-BA0A-E48315D8CEB6

Device     Start      End  Sectors Size Type
/dev/sda1   2048     4095     2048   1M BIOS boot
/dev/sda2   4096 20969471 20965376  10G Linux filesystem

~$ parted -l
Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0
has been opened read-only.
Error: /dev/sr0: unrecognised disk label
Model: NECVMWar VMware SATA CD00 (scsi)
Disk /dev/sr0: 68.0MB
Sector size (logical/physical): 2048B/2048B
Partition Table: unknown
Disk Flags:

Warning: Unable to open /dev/sr1 read-write (Read-only file system).  /dev/sr1
has been opened read-only.
Model: Unknown (unknown)
Disk /dev/sr1: 889MB
Sector size (logical/physical): 2048B/2048B
Partition Table: mac
Disk Flags:

Number  Start  End    Size    File system  Name   Flags
 1      2048B  6143B  4096B                Apple
 2      663MB  666MB  2523kB               EFI

$ lsblk -o name,fstype,size,fssize,mountpoint,label,model,vendor
lsblk: unknown column: fssize,mountpoint,label,model,vendor

$ lsblk -o name,fstype,size
NAME   FSTYPE     SIZE
fd0               1.4M
loop0  squashfs  96.6M
loop1  squashfs  62.1M
loop2  squashfs  97.1M
loop3  squashfs 161.4M
loop4  squashfs  17.9M
loop5  squashfs  55.3M
sda                25G
├─sda1              1M
└─sda2 ext4        10G
sdb                20G
sr0    iso9660   64.9M
sr1    iso9660    848M

~$ lsblk -o name,fstype,size,mountpoint,label,model,vendor
NAME   FSTYPE    SIZE MOUNTPOINT LABEL                           MODEL   VENDOR
fd0              1.4M
loop0  squashf  96.6M /snap/core
loop1  squashf  62.1M /snap/gtk-
loop2  squashf  97.1M /snap/core
loop3  squashf 161.4M /snap/gnom
loop4  squashf  17.9M /snap/gedi
loop5  squashf  55.3M /snap/core
sda               25G                                            VMware  VMware,
├─sda1             1M
└─sda2 ext4       10G /
sdb               20G                                            VMware  VMware,
sr0    iso9660  64.9M            CDROM                           VMware  NECVMWa
sr1    iso9660   848M            Ubuntu-Server 18.04.3 LTS amd64 VMware  NECVMWa
2
  • Start with parted -l or fdisk -l. Do they show you the increased disk (not fs) size on the first disk, and the second empty disk? This command will also help you: lsblk -o name,fstype,size,fssize,mountpoint,label,model,vendor Post the output of the commands and I'll add to the answer how you should proceed.
    – Krackout
    Sep 18, 2020 at 20:50
  • By adding another disk you've simply made a new device usable on the system, you haven't expanded your storage on the root drive (sdb is your 'new drive')Nor have you expanded the partition first so that it can use the excess space on the disk. Sep 18, 2020 at 22:53

2 Answers 2

3

About the increased size of /dev/sda: the guest OS can see the new size of the virtual disk, but you also need to resize the sda2 partition and the file system it contains to be able to use the additional storage space.

One way to do that (alternatively, use the graphical tool GParted, which will take care of most of the following steps in a single operation):

  1. Make sure you have a full backup of all the important data on the virtual machine. Possibly take a backup of the full VM image. Growing an on-line ext4 file system and the containing partition can be done on Linux, but you should never consider it a 100% safe operation.

  2. Start sudo parted /dev/sda.

  3. Print the partition table and take note of the End sector of the last line:

    unit s print free
    
  4. Resize the sda2 partition (it should be shown by parted as 2):

    resizepart 2
    

    answering "yes" if parted warns you about the partition being in use and asks for confirmation; type in the number you obtained in step (2)—the last available sector on the device—appending the s (sectors) unit to it, when parted asks you for the end sector (you may then be asked to accept a slightly different final sector out of alignment reasons; that would be fine).

  5. Print the partition table again (same as point (2)) to confirm that sda2 has been resized.

  6. Quit parted.

  7. Use lsblk /dev/sda to make sure the kernel is aware of the resized partition. If its shown size is still 10G, use sudo partprobe -s to refresh it and check it again.

  8. Resize the file system:

    sudo resize2fs /dev/sda2
    

    You may be asked to run sudo e2fsck -f /dev/sda2 before being able to resize the file system. Do it and then retry the resize2fs command.
    When given no size argument, resize2fs grows the file system to match the size of the containing partition.

  9. Use df -h /dev/sda2 to verify the new size.

About the newly added virtual disk, /dev/sdb: I'd suggest you not to use it and, if needed, grow /dev/sda further instead. You may want to remove the image that backs sdb on the host and add that storage space to sda before going through the above steps.

3
  • - Thanks. Went thru he steps - noted the end sector. It prompts with End? 20969472s? But this is actually Start sector - the End sector is 52428766s. What do I do here ?
    – Sam-T
    Sep 18, 2020 at 23:31
  • Type in the End sector of the free space. This isn't dangerous, as long as you type a bigger number than the End sector of sda2.
    – fra-san
    Sep 18, 2020 at 23:35
  • Yes I did that - it worked shows 25G lsblk /dev/sda NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 25G 0 disk ├─sda1 8:1 0 1M 0 part └─sda2 8:2 0 25G 0 part /
    – Sam-T
    Sep 18, 2020 at 23:52
0

Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0

this error is returned when you try parted .

disconnect any cd/dvd rom device in vmware and retry the same command [parted ].

1
  • I do not have any cd/dvd rom device attached to work station. But it does list the storage CD/DVD as SATA .iso
    – Sam-T
    Sep 18, 2020 at 21:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .