How to Create Second Primary or Additional Partition in OpenStack Virtual Machine
- Tuesday, October 6, 2015 By Ramya Santhosh
Question: I had created a two-node architecture based on Openstack cloud reading your previous article. It was of great help. Now I could able to boot the VM’s. I selected the m1.medium flavor and booted the CentOS virtual image. Upon logging to the guest OS, using df -h command found only 10GB of space mounted as shown below:
[root@openstack /]# df -h Filesystem Size Used Avail Use% Mounted on /dev/vda1 7.8G 613M 6.8G 9% / tmpfs 1.9G 0 1.9G 0% /dev/shm
The rest nearly 32GB of space is not shown! I couldn’t find how to access the space. Please help me.
List the virtual disk’s as shown below:
[root@openstack /]# ls /dev/vda* /dev/vda /dev/vda1
According to the above output, /dev/vda1 is already mounted. Find out the complete size of /dev/vda as shown below:
[root@openstack /]# fdisk -l /dev/vda
Disk /dev/vda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000574cf
/dev/vda is our complete virtual disk out of which /dev/vda1 is created and used as the primary first partition for OS installation. With the rest of the disk space, we need to create an another primary second partition.
Follow the below procedure to create the second partition:
1. Run the below command:
$ fdisk /dev/vda
2. Press n to create a new disk partition.
3. Press p to create a primary disk partition.
Since primary partition is already available, we’ll create the second partition:
4. Press 2 to designated it as the second disk partition.
5. Press ENTER twice to accept the default of second and last cylinder – to convert the remainder of hard disk to a single disk partition.
6. Press t, then select the new partition you made.
7. Press 83 change your new partition to 83, i.e. Linux partition type.
8. Press p to display the hard disk partition setup. Please take note that the first partition is denoted as /dev/vda1 in our instance and /dev/vda2 as second partition.
9. Press w to write the partition table and exit fdisk upon completion.
10. The kernel still uses the old table. The new table will be used at the next reboot. So just reboot the machine.
11. Once the machine comes up, list the virtual disks
[root@openstack /]# ls /dev/vda* /dev/vda /dev/vda1 /dev/vda2
12. Lastly, make a file system on the partition.
[root@openstack ~]# mkfs.ext4 /dev/vda2 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 2097152 inodes, 8387268 blocks 419363 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 256 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624
Writing inode tables: done
Creating journal (32768 blocks):
Writing superblocks and filesystem accounting information:
This filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
13. Mount the new filesystem.
[root@openstack ~]# mkdir /export [root@openstack ~]# mount /dev/vda2 /export/ [root@openstack ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/vda1 7.8G 613M 6.8G 9% / tmpfs 1.9G 0 1.9G 0% /dev/shm /dev/vda2 32G 48M 30G 1% /export
Your new volume has now been successfully mounted, and is ready for use!