Adding a Virtual Disk to VMWare
If you need to add another virtual disk to an existing Linux VMWare virtual machine (parts of this can be used to add a physical disk to a non-virtual machine too), do the following steps:
First, shutdown your virtual machine, and make a backup of your virtual disk as a safety precaution.
/sbin/shutdown -h now
Next, Add the new virtual disk in Workstation's VM -> Settings menu. Choose IDE for the virtual hardware.
Start the VM. Login as root Create a partition table on the new disk using fdisk. This is an interactive tool, so you're going to need to answer a few questions.
fdisk /dev/hdb
choose n for "new partition"
choose p for "primary"
type 1 for the partition number
accept the default start and end options (hit Enter twice)
choose w to "write the partition table"
Make a filesystem on the new partition
mkfs.ext3 /dev/hdb1
Mount the filesystem on a temporary location
mount /dev/hdb1 /mnt
Copy the partition you wish to move to the new mount (I use /opt in this example)
cp -rp /opt/* /mnt
Add a line to /etc/fstab to cause your new partition to be mounted at boot
echo '/dev/hdb1 /opt ext3 defaults 1 1' >> /etc/fstab
Reboot
/sbin/shutdown -r now
After rebooting, you can confirm that your disk setup now has the new disk on the /opt directory mount point by typing on the command line:
df -h
You should see something like
# This file is edited by fstab-sync - see 'man fstab-sync' for details
LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
none /dev/pts devpts gid=5,mode=620 0 0
none /dev/shm tmpfs defaults 0 0
LABEL=/home /home ext3 defaults 1 2
LABEL=/opt /opt ext3 defaults 1 2
LABEL=/opt/IBM /opt/IBM ext3 defaults 1 2
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
LABEL=/tmp /tmp ext3 defaults 1 2
LABEL=/usr /usr ext3 defaults 1 2
LABEL=/var /var ext3 defaults 1 2
LABEL=SWAP-hda9 swap swap defaults 0 0
/dev/hdb1 /opt ext3 defaults 1 1
/dev/hdc /media/cdrom auto pamconsole,exec,noauto,managed 0 0
/dev/fd0 /media/floppy auto pamconsole,exec,noauto,managed 0 0
That's it.