How to Add an Extra Hard Drive to a Linux VM in Microsoft Hyper-V

How to add an extra Hard drive to Linux VM in Microsoft Hyper-V

CHUONG K. NGUYEN – BSc., MCSEx2, MCSAx2, MCP, MCTS, MCITP, CCNA

In Hyper-V, suppose that there is a Linux machine called MYVM. Our task is to add a hard drive (a virtual hard disk to be exact) to this machine (MYVM).

Step by Step instruction

  1. Shutdown the Linux VM: shutdown –h now
  2. In Hyper-V, Right-click the VM, choose Settings.
  3. Add another IDE Drive on Controller0, ID1.
  4. Start the machine.
  5. After logged in, type df
  6. Type dmesg | grep sd, you will see the new virtual hard drive; it is usually sdb if this is the second hard drive in the system.
  7. Or instead of the above commands, type fdisk –l to check the drives available in there.
  8. Or To see all your hard drives, you can enter the command: ls /dev/sd*; you need to make sure you know which sd* it is; in this case it is sdb.
  9. Format the hard drive: Now type fdisk /dev/sdb
  10. Enter p to see partitions
  11. To delete a partition, type d followed by Enter (in this case, there is no partition to delete)
  12. Make a new partition by typing n
  13. Press Enter for default start and Enter again for default end
  14. Type p to check partition table
  15. Enter t for type, enter code 83 tor EXT2
  16. Type w to save
  17. Type mkfs –t ext2 /dev/sdb (take a few minutes)
  18. Type fsck –f –y /dev/sdb
  19. Restart system
  20. Make a new directory using the command mkdir /mnt/MyDisk
  21. mount –t ext2 /dev/sdb /mnt/MyDisk
  22. Type df to verify all is working.

As you can see, there are two reboots and it could take some time.