VMWare

21
Jul

How to connect a new virtual disk in VMWare

Posted by anton as VMWare

Sometimes you need to manually create and attach a virtual disk to your virtual machine in VMWare. To do that, login to your machine as root and run the following commands (in bold):

[root@myserver ~]# fdisk /dev/hdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

The number of cylinders for this disk is set to 17753.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e
Partition number (1-4): 1
First cylinder (1-17753, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-17753, default 17753):
Using default value 17753

Command (m for help): n Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (1-17753, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-17753, default 17753):
Using default value 17753

Command (m for help): w The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

[root@myserver ~]# mkfs -t ext3 /dev/hdb5 mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1048576 inodes, 2097057 blocks
104852 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2147483648
64 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: done
Creating journal (32768 blocks):
done
Writing superblocks and filesystem accounting information:
done

This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@myserver ~]# mkdir /opt2
[root@myserver ~]# mount -t ext3 /dev/hdb5 /opt2