Setting up a new hard drive on Windows and Linux
Windows
To set up a new hard drive with raw space on Windows 10:
Open Start.
Search for Create and format hard disk partitions and click the top result to open the Disk Management console.
Right-click the hard drive marked as "Unknown" and "Not Initialized" and select the Initialize Disk option.
Under the "Select disks" section, check the disk to initialize.
Select the partition style:
Master Boot Record (MBR) for hard drives smaller than 2TB in size
GUID Partition Table (GPT) for hard drives larger than 2TB in size
Click the OK button.
Right-click the Unallocated space part of the storage, and select the New Simple Volume option.
Click the Next button.
Under the "Simple volume size in MB" section, leave the default size if you plan to use the entire hard drive to store files. Otherwise, specify the amount of space in megabytes you want to allocate for the partition.
10. Click the Next button.
11. Use the "Assign the following drive letter" drop-down menu to select a new drive letter.
Add a volume label - “Data”
Click the Next button.
Use the "File system" drop-down menu, and select the NTFS option (recommended for Windows 10).
15. Use the "Allocation unit size" drop-down menu, and select the Default option.
16. Type a descriptive name for the storage in the "Value label" field.
17. Check the Perform a quick format option.
Quick tip: Clear the quick format option to perform a full format that includes a disk check. If you use the full format option, remember that it can take many hours to complete depending on the size.
18. Clear the Enable file and folder compression option.
19. Click the Next button.
20. Click the Finish button.
RESULT
After you complete the steps, the new hard drive will be initialized, partitioned, and properly formatted.
Linux
Formatting the Volume
At this point, the Volume is only attached to the instance in question. If the Volume was created with Volume Source
set to "No source, empty volume," we still need to format the drive.
To format the volume, take note of where it is attached, and run:
ubuntu@dev-doc-1:~$ sudo mkfs -t ext4 /dev/vdb
mke2fs 1.44.1 (24-Mar-2018)
Creating filesystem with 13107200 4k blocks and 3276800 inodes
Filesystem UUID: 24db0256-4a5f-458d-8f95-36b28fa6a352
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424
Allocating group tables: done
Writing inode tables: done
Creating journal (65536 blocks): done
Writing superblocks and filesystem accounting information: done
ubuntu@dev-doc-1:~$
Mounting the Volume
To be used, the last step is to mount the drive. In this case, I will make a directory at the root level called data
and mount the volume there:
sudo mkdir /data
sudo mount /dev/vdb /data
You will now be able to copy or write your data to the 50GB Volume mounted at /data
:
ubuntu@dev-doc-1:~$ df -H
Filesystem Size Used Avail Use% Mounted on
udev 2.1G 0 2.1G 0% /dev
tmpfs 414M 3.0M 411M 1% /run
/dev/vda1 32G 2.0G 29G 7% /
tmpfs 2.1G 0 2.1G 0% /dev/shm
tmpfs 5.3M 0 5.3M 0% /run/lock
tmpfs 2.1G 0 2.1G 0% /sys/fs/cgroup
tmpfs 414M 0 414M 0% /run/user/1000
/dev/vdb 53G 55M 50G 1% /data
Permanently mounting the Volume
Unfortunately, that mount will not persist over a reboot. The data will be safe, but the mount will disappear and you will need to run the sudo mount
command again.
To prevent this, we can make the mount permanent. To do this, we will add an entry to the configuration file that controls the mounted volumes, /etc/fstab
. Using the text editor of your choice, add the following line to the bottom of the file: /dev/vdb /data auto defaults 0 0
.
You can now rest easy knowing that your Volume will always be mounted at /data
when you reboot your instance.
Change the permission of the new drive
Change the owner of the new drive so that the user can access it without sudo permission:
sudo chown username:username /data