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
- Shutdown the Linux VM: shutdown –h now
- In Hyper-V, Right-click the VM, choose Settings.
- Add another IDE Drive on Controller0, ID1.
- Start the machine.
- After logged in, type df
- 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.
- Or instead of the above commands, type fdisk –l to check the drives available in there.
- 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.
- Format the hard drive: Now type fdisk /dev/sdb
- Enter p to see partitions
- To delete a partition, type d followed by Enter (in this case, there is no partition to delete)
- Make a new partition by typing n
- Press Enter for default start and Enter again for default end
- Type p to check partition table
- Enter t for type, enter code 83 tor EXT2
- Type w to save
- Type mkfs –t ext2 /dev/sdb (take a few minutes)
- Type fsck –f –y /dev/sdb
- Restart system
- Make a new directory using the command mkdir /mnt/MyDisk
- mount –t ext2 /dev/sdb /mnt/MyDisk
- Type df to verify all is working.
As you can see, there are two reboots and it could take some time.