In this tutorial we will see how to mount disk of size 8 Terabytes on an Azure Virtual Machine that is running Ubuntu 18.0 Operating System.
During the VM creation, Azure provides the option of attaching extra disk space. But in order to use the attached disk space, you need to mount it manually.
The mounting process is different for disks of size higher than 2TB. It is recommended to make GUID Partition Table (GPT) to perform partitions for disks larger than 2TB. If your disk size attached to an Azure VM Linux is less than 2TB, then I recommend you to go through the video tutorial that walks you through How to attach and mount 1 TB disk to an Azure VM having Ubuntu OS or you can refer to the article Add a disk less than 2 TB to a Linux VM.
The attach and mount disk process is also applicable for typical Virtual Machines and does not necessarily have to be VM deployed on Azure. Also, the step by step tutorial to mount disk of size larger than 2TB is applicable to all Linux distributions viz., Debian and RHEL.
It is highly recommended to take a back up of the VM before proceeding with the following tutorial. If you are not sure about what you are doing or performing this on a production facing VM, ensure you consult IT admin. If you are just practicing on a fresh VM and have little hands on on shell and Linux, you are good to go.
Lets find the 8TB disk that is attached to our Azure VM running Ubuntu 18 OS.
sudo lsblk -o NAME,HCTL,SIZE,MOUNTPOINT
NAME HCTL SIZE MOUNTPOINT sda 0:0:0:0 30G ├─sda1 29.9G / ├─sda14 4M └─sda15 106M /boot/efi sdb 1:0:1:0 7G └─sdb1 7G /mnt sdc 3:0:0:0 8T sr0 5:0:0:0 628K
We will make use of
parted to make partition of the 8TB disk. parted is program for creating and manipulating partition tables In my case it is sdc and identified by /dev/sdc. Your disk could be identified by sda or sdb or sdc etc,. Ensure you refer the correct disk all across the tutorial.
sudo parted /dev/sdc
GNU Parted 3.2 Using /dev/sdc Welcome to GNU Parted! Type 'help' to view a list of commands.
You will now enter in to the
parted command prompt which can be identified by (parted) at the beginning of each line.
Issue the below commands excluding (parted). In the commands below (parted) is mentioned just to indicate the commands to be entered in the (parted) console.
Make GPT partition by giving
mklabel gpt command.
(parted) mklabel gpt (parted) unit TB (parted) mkpart primary 0.00TB 8.00TB (parted) print
Here, I have specified the memory measurement unit type as TB (TeraBytes). Also, I am making only one partition that takes all the size 8TB as mentioned in command
mkpart primary 0.00TB 8.00TB.
Model: Msft Virtual Disk (scsi) Disk /dev/sdc: 8.80TB Sector size (logical/physical): 512B/4096B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 0.00TB 8.00TB 8.00TB primary
Now that you have successfully created a single partition /dev/sdc1 of size 8TB, exit out of (parted) console by hitting
Information: You may need to update /etc/fstab.
You will be informed to update /etc/fstab which we will be doing once we configure the disk partition mounted successfully.
Generally new partitions will be appended by 1 and then the number increases as we make more partitions of the same disk. You can also provide partition number of your choice that doesn’t collide with the existing partitions of the disk.
sudo lsblk -o NAME,HCTL,SIZE,MOUNTPOINT
NAME HCTL SIZE MOUNTPOINT sda 0:0:0:0 30G ├─sda1 29.9G / ├─sda14 4M └─sda15 106M /boot/efi sdb 1:0:1:0 7G └─sdb1 7G /mnt sdc 3:0:0:0 8T └─sdc1 7.3T <-- New Disk Partition 🎉 sr0 5:0:0:0 628K
We can observe the new disk partition sdc1 of size 8TB is created. Lets format and mount disk partition.
We need to format the file system of our new disk partition /dev/sdc1. This will take a while depending on the size of partition. I am using ext4 journaling file system to format the disk. Because ext4 is the default file system for many Linux distributions including Debian and Ubuntu.
sudo mkfs.ext4 /dev/sdc1
mke2fs 1.44.1 (24-Mar-2018) Discarding device blocks: done Creating filesystem with 1953124864 4k blocks and 244142080 inodes Filesystem UUID: 43275f96-0636-4a8d-8c2e-18227487c4dd Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 102400000, 214990848, 512000000, 550731776, 644972544, 1934917632 Allocating group tables: done Writing inode tables: done Creating journal (262144 blocks): done Writing superblocks and filesystem accounting information: done
Before we mount the new disk partition that we just created /dev/sdc1, we will see the existing file system and other details by running the following command.
Filesystem Size Used Avail Use% Mounted on udev 1.7G 0 1.7G 0% /dev tmpfs 341M 668K 340M 1% /run /dev/sda1 29G 1.4G 28G 5% / tmpfs 1.7G 0 1.7G 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 1.7G 0 1.7G 0% /sys/fs/cgroup /dev/sda15 105M 3.6M 101M 4% /boot/efi /dev/sdb1 6.9G 32M 6.5G 1% /mnt tmpfs 341M 0 341M 0% /run/user/1000
We notice that /dev/sdc1 is not shown which indicates it is not yet mounted on to the file system. We will be mounting the 8TB disk to a directory named 8tbdrive at the top level directory /. Lets create a directory with the name 8tbdrive
Now lets mount disk partition /dev/sdc1 to point to /8tbdrive
sudo mount /dev/sdc1 /8tbdrive
Verify the disk /dev/sdc1 mounted on /8tbdrive
Filesystem Type Size Used Avail Use% Mounted on udev devtmpfs 1.7G 0 1.7G 0% /dev tmpfs tmpfs 341M 668K 340M 1% /run /dev/sda1 ext4 29G 1.4G 28G 5% / tmpfs tmpfs 1.7G 0 1.7G 0% /dev/shm tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs tmpfs 1.7G 0 1.7G 0% /sys/fs/cgroup /dev/sda15 vfat 105M 3.6M 101M 4% /boot/efi /dev/sdb1 ext4 6.9G 32M 6.5G 1% /mnt tmpfs tmpfs 341M 0 341M 0% /run/user/1000 /dev/sdc1 ext4 7.3T 93M 6.9T 1% /8tbdrive
We see the disk partition /dev/sdc1 successfully mounted on the directory /8tbdrive we just created.
After the disk mounted successfully, we will Update /etc/fstab so that the OS reboots will automount disk partition. Run the command to obtain the UUID of the disk partition.
sudo blkid | grep -i "/dev/sdc1"
/dev/sdc1: UUID="43275f96-0636-4a8d-8c2e-18227487c4dd" TYPE="ext4" PARTLABEL="primary" PARTUUID="5bec9fdb-f0fe-435c-8318-11c5f6dd7bad"
We will place the
UUID in the /etc/fstab along with partition and mount details.
PARTUUID is also printed in the output but ensure you copy the value of
UUID. In my case, the
UUID is 43275f96-0636-4a8d-8c2e-18227487c4dd. Your
UUID will be different.
Open the /etc/fstab in editor of your choice. I will be using
sudo nano /etc/fstab
At the last line of the /etc/fstab add the following line. Be sure to change your
UUID, mount directory and file system as
UUID=43275f96-0636-4a8d-8c2e-18227487c4dd /8tbdrive ext4 defaults,nofail 1 2
nofail lets the OS continue to boot without any fail in case of any discrepancies.
Save and exit out of
nano by hitting
Ctrl + X,
Y and hit return.
Run the following command to see there are no errors.
sudo mount -a
You should not see any output generated by this command which indicates no errors and you have non-breakable configuration mentioned in the /etc/fstab.
Congratulations🎉 , you have successfully mounted a disk partition of size higher than 2 Terabytes, an actual of 8TB disk on Azure VM with Ubuntu 18.0 OS. Bookmark this page (
D ) for quick future reference.
To summarize what we did,
- Made a Partition of the 8TB disk attached to VM using parted and GPT.
- Identified the new disk partition /dev/sdc1
- Did the disk partition Format using mkfs.ext4
- Mounted the disk partition /dev/sdc1 to a directory /8tbdrive
- Configured the disk partition to Automount on reboots in