While messing about in my home lab I found I needed to add a SCSI drive to a virtual machine and had no idea how to do it. Although this doesn’t have anything to do with security I’ve posted it here as I know I will definitely need to do this again at some point. Here we have already attached the new VHD to a SCSI connection in the Virtual machine management console, so the disk is physically connected but needs to be formatted, labelled, and initialised.
To list all connected disks run
this will return the following
If you are unsure which is the new disk, then the easiest way to check is to disconnect the new SCSI drive and run this command, then reconnect the disk and run the same command again and compare the results. The disk that wasn’t there the first time is obviously your new disk. The disks should be labelled “sd” then with a corresponding letter. The primary disk is usually “sda” with the partitions numbered – so sda1 would be the first partition on the first disk. In our example sdb is our new disk so we will be applying changes to this, if your disk is named differently then you will need top replace “sdb” with the name of your own disk in the following instructions.
Once we have identified the new disk we are ready to launch “fdisk” utility.
sudo fdisk /dev/sdb
Always look at the help menus when using new tools as it will help you gain an understanding of it rather than just blindly following instructions. Help menu is shown below
From here we type “n” for a new partition, then “p” for primary and accept all the defaults.
You must then select “w” to write and save the changes, if you don’t do this then the partition will not be created.
Now that we’ve created our partition we need to create the file system
sudo mkfs.ext3 -L DATA /dev/sdb1
The “-L” switch sets the partition label, here we have used “DATA” but you can chose anything, and we are setting it on our new partition which is “/dev/sdb1”
Now we mount the filesystem
sudo mount /dev/sdb1/DATA
To check the location is mounted we can run
Next we make a directory
sudo mkdir /Documents
The final thing we need to do is change a configuration so that this new location is mounted every time the server is restarted.
We do this by editing the following file.
sudo nano /etc/fstab
Then add the following line as shown below. (If you named your partition differently then use your label name instead
/dev/sdb1 /Data auto defaults 0 0
That’s it. Check this config by restarting your machine then running the list disk, and show mounted commands again and you should see that your new partition is already mounted as shown in the screen shots below.