Ubuntu – How to merge 2 VMware disks in to a single one

partitioningvmware

I have installed an Ubuntu server on a VMWare workstation with a space of 20GB storage as seen below:

enter image description here

After the installation I've attached another 40GB worth storage to the existing Ubuntu server installation (seen below):

enter image description here

Now I want to add this 40GB to my / (root) directory it mean's
I want that my / directory became to 60G , like it will be resize from 20G to 60G
(20G + 40G), i don't know what should i do, can any body help me ?

, my df -h result shows;

root@Userver:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        18G  900M   16G   6% /
udev            990M  4.0K  990M   1% /dev
tmpfs           400M  308K  399M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            999M     0  999M   0% /run/shm
none            100M     0  100M   0% /run/user
root@Userver:~#

it must be 60G !

i have no graphic mode, then i can't use Gparted tools,
i'm just have ssh access !

Best Answer

It should be possible to resize you VMware disks, instead of adding an extra one, with the installed tools from VMware.

To expand a existing disk use the command:

vmware-vdiskmanager -x 1000GB myDisk.vmdk

where 100GB is the new disk size and myDisk.vmdk is the disk file for your Ubuntu server installation.

Next time you boot your vm the partition size will still be the same, you need to expand it to the new available space.

To check where your / is mounted use the command mount, it will return a line similar to:

dev/sda7 on / type ext3 (rw,noatime,nodiratime)

once you know where your / is mount you can use the command resize2fs as such:

resize2fs /dev/sda7

After the resize is finished you should to a file system check (not recommended while the device is mounted). Of course with any disk operations a disk backup is recommended.

By the way, you should be able to download the Ubuntu LiveCD for desktops and use it in your VM by booting the iso, that does not destroy your current setup and might make you life easier while repartitioning.

Related Question