In Computer's file-sharing system, mounting typically refers to making the file system accessible to a number of users. MS Windows has the option to automatically mount discs. However, Linux does not and hence requires a storage device to be mounted (attached) to the operating system manually before it can be used. This mounted storage is subsequently used to build a filesystem and store data. 

In this tutorial, we'll help you know how to mount the attached volume on an Ubuntu instance.  

Pre-requisites: 

  1. An Ubuntu instance 
  2. Attached volume 
  3. Code editor 
  4. Good internet connectivity 

Step 1: Login as: ubuntu 

Step 2: Listing Disk Partition Table 

i. Execute the below command to see the list of mounted file systems as well as file systems in RAM, usage percentage, availability, and the path it's mounted on. This command displays the details in 'human-readable' size format, i.e., gigabytes, megabytes, and kilobytes. Moreover, it will help us draw the difference in the partition table in the last (step 10). 

df –h

ii. Run the following command to get the report of the device's major and minor numbers, block size, amount of free and total space on the device, as well as information on all available or specified block devices.

lsblk

Step3: Create Disk partition 

The Linux command fdisk, commonly referred to as format disc, is used to create and modify the disc partition table. It is used to examine, create, delete, modify, resize, copy, and transfer partitions on a hard drive.  

Use the following commands to create a disk partition for your volume. 

i. Sudo -i 

ii. fdisk /path <give the path of your attached volume> 

 

Step 4: Type m for help, and you'll be prompted to a list of commands. 

 

Step 5: Building Partition Tables: 

i. Enter n for adding a new partition.  

   Linux has two partition styles, namely: 

  • Primary partition: The computer's operating system(s) are located on the primary disc, which is a bootable partition.  
  • Extended partition: The extended partition is non-bootable; these are used to store data and often have numerous logical partitions. 

ii. Enter p for selecting the number of primary partitions, which range from 1 to 4, and default value of 1. Then, you may choose the sectors of your choice; else, it'll pick the default values. Here, we have taken the default values. 

iii. Enter w to write table to disk and exit. 

 

Step 6: Creating a File System 

Use the following command to create an ext4 file system from disc partitions, which is used to build a Linux file system on a device.

mkfs.ext4 /path  

 

Step 7: Creating a drive for mounting volume 

Volume is always mounted on a drive. For that, we'll create a drive with the following command.

1. mkdir  /new_mount   

2. lsblk –fs 

3. Copy the UUID (Universally Unique Identifier) for your just-created partition (here it is vdc1). 

 

Step 8: Creating a configuration file 

Use the following command to edit the configuration file. Here, we are using nano code editor. 

nano /etc/fstab 

This file has some default settings, which need to remain untouched. Further need to fill the following details into the file: 

  1. UUID (already copied from the partition table in Step.7) 
  2. Path of drive (refer to step.7) 
  3. File system type, i.e., ext4 
  4. Settings- default 
  5. 0- If you want the volume backup 
  6. 1- If you want the volume bootup at the startup 

 

Step 9: Mounting the volume 

i. Reload the daemon using the command: 

systemctl daemon-reload 

ii. Mount the volume 

mount –a 

Note: If the below error appears

Use the following commands instead for mounting: 

sudo mount /path /drive 

 

Step 10: Verifying the volume mount 

The following commands will show our drive in the Disk partition table, which was missing earlier in step 2: 

df -h 

 

lsblk --fs 

 

Помог ли вам данный ответ? 2 Пользователи нашли это полезным (3 голосов)