Kali Linux in VMware Fusion resize disk

Tue 30 March 2021

A common task is to resize my Kali VM disk, here is how I do it

Resize disk in VMWare Fusion

First thing to do is to power of your virtualmachine.

After the VM is powered down you can go "Virtual Machine" -> "Settings"

Power the VM on again.

Resize disk in Kali Linux

Let's check the status before we start:

root@kali:~# fdisk -l
Disk /dev/sda: 60 GiB, 64424509440 bytes, 125829120 sectors
Disk model: VMware Virtual S
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: 0x33843418

Device     Boot  Start      End  Sectors  Size Id Type
/dev/sda1  *      2048   499711   497664  243M 83 Linux
/dev/sda2       501758 83886079 83384322 39,8G  5 Extended
/dev/sda5       501760 83884031 83382272 39,8G 8e Linux LVM

Disk /dev/mapper/kali--vg-root: 35,76 GiB, 38394658816 bytes, 74989568 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/kali--vg-swap_1: 4 GiB, 4294967296 bytes, 8388608 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

root@kali:~# lsblk 
NAME                MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                   8:0    0   60G  0 disk 
├─sda1                8:1    0  243M  0 part /boot
├─sda2                8:2    0    1K  0 part 
└─sda5                8:5    0 39,8G  0 part 
  ├─kali--vg-root   254:0    0 35,8G  0 lvm  /
  └─kali--vg-swap_1 254:1    0    4G  0 lvm  [SWAP]
sr0                  11:0    1 1024M  0 rom

Fire up parted and resize the partitions:

root@kali:~# parted 
GNU Parted 3.3
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                            
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 64,4GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type      File system  Flags
 1      1049kB  256MB   255MB   primary   ext2         boot
 2      257MB   42,9GB  42,7GB  extended
 5      257MB   42,9GB  42,7GB  logical                lvm

(parted) resizepart                                                       
Partition number? 2                                                       
End?  [42,9GB]? 60GB                                                      
(parted) print                                                            
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 64,4GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type      File system  Flags
 1      1049kB  256MB   255MB   primary   ext2         boot
 2      257MB   60,0GB  59,7GB  extended
 5      257MB   42,9GB  42,7GB  logical                lvm

(parted) resizepart                                                       
Partition number? 5                                                       
End?  [42,9GB]? 60GB                                                      
(parted) print                                                            
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 64,4GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type      File system  Flags
 1      1049kB  256MB   255MB   primary   ext2         boot
 2      257MB   60,0GB  59,7GB  extended
 5      257MB   60,0GB  59,7GB  logical                lvm

(parted) quit                                                             
Information: You may need to update /etc/fstab.

Check the result with fdisk:

root@kali:~# fdisk -l
Disk /dev/sda: 60 GiB, 64424509440 bytes, 125829120 sectors
Disk model: VMware Virtual S
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: 0x33843418

Device     Boot  Start       End   Sectors  Size Id Type
/dev/sda1  *      2048    499711    497664  243M 83 Linux
/dev/sda2       501758 117187500 116685743 55,6G  5 Extended
/dev/sda5       501760 117187500 116685741 55,6G 8e Linux LVM

Disk /dev/mapper/kali--vg-root: 35,76 GiB, 38394658816 bytes, 74989568 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/kali--vg-swap_1: 4 GiB, 4294967296 bytes, 8388608 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

Extend the physical volume:

root@kali:~# pvresize /dev/sda5
  Physical volume "/dev/sda5" changed
  1 physical volume(s) resized or updated / 0 physical volume(s) not resized
root@kali:~# vgs
  VG      #PV #LV #SN Attr   VSize   VFree  
  kali-vg   1   2   0 wz--n- <55,64g <15,88g

Extend the logical volume:

root@kali:~# lvresize -l +100%FREE -r /dev/mapper/kali--vg-root
  Size of logical volume kali-vg/root changed from <35,76 GiB (9154 extents) to <51,64 GiB (13219 extents).
  Logical volume kali-vg/root successfully resized.
resize2fs 1.45.6 (20-Mar-2020)
Filesystem at /dev/mapper/kali--vg-root is mounted on /; on-line resizing required
old_desc_blocks = 5, new_desc_blocks = 7
The filesystem on /dev/mapper/kali--vg-root is now 13536256 (4k) blocks long.

root@kali:~# lvs
  LV     VG      Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root   kali-vg -wi-ao---- <51,64g                                                    
  swap_1 kali-vg -wi-ao----   4,00g

Check the ending result:

root@kali:~# df -Th
Filsystem                 Type             Størrelse Brukt Tilgj. Bruk% Montert på
udev                      devtmpfs              1,9G     0   1,9G    0% /dev
tmpfs                     tmpfs                 392M  1,2M   390M    1% /run
/dev/mapper/kali--vg-root ext4                   51G   34G    16G   69% /
tmpfs                     tmpfs                 2,0G   58M   1,9G    3% /dev/shm
tmpfs                     tmpfs                 5,0M     0   5,0M    0% /run/lock
/dev/sda1                 ext2                  236M  154M    70M   69% /boot
vmhgfs-fuse               fuse.vmhgfs-fuse      234G  205G    29G   88% /mnt/hgfs
tmpfs                     tmpfs                 392M   64K   391M    1% /run/user/1000

You should now have more space available for your VMWare Fusion Kali VM.

Tagged as : linux kali virtualization

Comments

Tagged as : linux kali virtualization