-1

Problem:

I have a VMware workstation 12 running the latest Kali Linux image, downloaded from offensive-security.com, by default recommended image size is 40GB, but now I have exceeded the memory and I needed to expand the size of the image's disc.

While attempting to do so I have encountered a problem running the pvcreate command resulting in the following error: Device /dev/sda3 not found (or ignored by filtering).

Research:

I have looked online for solutions for this problem, on this forum and other forums but couldn't find the right answer to help me. I have followed the steps in the tutorial given on VMWare's website on how to expand the disc space on the virtual image. The link to the steps suggested:

and followed this tutorial i found on YouTube:

Question:

How do I resolve this problem and what is causing it?

Additional information:

I believe I am using ext4 as the filesystem on my kali linux machine, (would be glad if someone specify me the right way to check this, i believe this might cause the problem as the VMWare website mentions the steps were specified for ext3 filesystem).

output of lsblk:

NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
fd0      2:0    1    4K  0 disk 
sda      8:0    0  100G  0 disk 
├─sda1   8:1    0   38G  0 part /
├─sda2   8:2    0    1K  0 part 
├─sda3   8:3    0 1023K  0 part 
└─sda5   8:5    0    2G  0 part [SWAP]
sr0     11:0    1 1024M  0 rom 

output of df --print-type:

Filesystem     Type     1K-blocks     Used Available Use% Mounted on
udev           devtmpfs   1010296        0   1010296   0% /dev
tmpfs          tmpfs       204856     6736    198120   4% /run
/dev/sda1      ext4      39089504 36375684    705144  99% /
tmpfs          tmpfs      1024276      376   1023900   1% /dev/shm
tmpfs          tmpfs         5120        0      5120   0% /run/lock
tmpfs          tmpfs      1024276        0   1024276   0% /sys/fs/cgroup
tmpfs          tmpfs       204852       16    204836   1% /run/user/132
tmpfs          tmpfs       204852       16    204836   1% /run/user/0

output of fdisk -l:

Disk /dev/sda: 100 GiB, 107374182400 bytes, 209715200 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: 0xf9fbdc32

Device     Boot    Start      End  Sectors  Size Id Type
/dev/sda1  *        2048 79693823 79691776   38G 83 Linux
/dev/sda2       79695870 83884031  4188162    2G  5 Extended
/dev/sda3       79693824 79695869     2046 1023K 8e Linux LVM
/dev/sda5       79695872 83884031  4188160    2G 82 Linux swap / Solaris

Partition table entries are not in disk order.
  • Please post the output of sudo lsblk. – AlexP Jan 20 '17 at 21:19
  • @AlexP added it to the post – Vertigo Jan 20 '17 at 21:30
  • It doesn't look to me that you are using LVM at all. You may try to run Gparted or parted to make a new partition in the free space after sda5, format it and mount it somewhere. pvcreate rejected your sda3 because it is tiny (smaller than the space needed for the LVM header). – AlexP Jan 20 '17 at 21:32
  • @Alexp Yes that is true i can see the partition i have created (sda3) is very small, I am new to this subject so i thought there would be some automated adjusting.. I have added to my question more information showing that I have changed this partition type to 8e which is actually the hex code for LVM, but there might be something that have been mistaken here. – Vertigo Jan 20 '17 at 22:30
  • What are you going to do with a 1MB partition? It wasn't even reasonable when disks were 40MB (30 years ago). – Julie Pelletier Jan 21 '17 at 3:19
0

Use the following command:

/usr/bin/vmware-vdiskmanager -x {diskSize}GB yourvm.vmdk

Example:

/usr/bin/vmware-vdiskmanager -x 32GB /share/vms/WindowsVista/vista.vmdk
  • 2
    could you explain what this will do? I don't like to type random commands that might ruin my machine, plus i don't really have a usr and share directories (?) – Vertigo Jan 20 '17 at 22:47
0

Solution:

Okay so I finally found the solution: I was running ext4 filesystem on my partition, u can see it by typing df, after a lot of research online I got more specific looking for: "how to change/resize/extend/expand ext4 partition, I have found the following answer:

It was published here by Znik (a lot of thanks to him @Znik) and it solved my problem. I even read somewhere about solving this out with a graphical interface using the tool gparted, but it was not convenient to me (less than the fdisk tool atleast).

the steps i took are very clear and i will list them here:

  1. Firstly I expanded the allocated machine size on vmware settings, very simple.
  2. You'll get prompted you need to adjust the guest settings to support that allocated space.
  3. open a terminal type fdisc -u /dev/sda (or the name of your hard disc)
  4. press p to view all the partitions for that disc.
  5. I had the main ext4 partition of 38 GB and the swap partition in the size of 2GB (both sda2 - extended, sda5 swap)
  6. Delete all the partitions by pressing d and following the instructions. (data won't be erased you only erase the table that point each partition what sectors on the hard disc it should use, it is saved in the memory and can be undone by type q at anytime while still running fdisk).
  7. Then you should take the allocated space you have and substract the size of the swap partition, for example in my case: 100 GB allocated space - 2 GB swap partition = 98 GB of ext4 partition.
  8. create new partition by typing n and set it's number to 1,make it a primary partition by typing p, leave the starting sector as default (2048 in my case), and calculate the number of blocks with the size of the ext4 you calculated before (98GB in my case), I used this website.
  9. create another partition numbered 2, and make it extended by using e instead of p.
  10. the last step should create you a /dev/sda2 partition with the id of 5 and type - extended and /dev/sda5 with id of 83 and type - linux.
  11. change the /dev/sda5 id to 82 Linux-swap by using the t command
  12. after finishing all of the changes use w to write the changes and exit fdisc
  13. use mkswap /dev/sda5 and place that UUID you got in the file /etc/fstab using some sort of text editor (vi or nano) instead of the existing UUID for the swap
  14. type swapon -a -v
  15. reboot the system in order to take change (if you can't take the down time you can try to use partx /dev/sda1 command) but if that fails you'll have to reboot.
  16. last step is to resize the file system to the partition size, ext4 has a command for that resize2fs /dev/sda1.

Congratulations!! You have successfuly expanded your VMWare linux machine disc size.

Hopefully this will save a lot of people headaches and time:)

Another source i found just now (wish I have found it before) with similar explanation to mine: source

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.