Sometimes you may need to mount disk from command line or mount disk partition. In this article, we will look at how to mount drive from terminal.
How to Mount Drive from Terminal
Here are the steps to mount drive from terminal.
1. Create Folder
First of all, you need to create a folder where you will mount the drive. For example, let us say, you want to mount /dev/sdb1 to /media/sdb1 then open terminal and create a new directory /media/sdb1
$ sudo mkdir /media/sdb1
2. Mount Drive
Enter the following command to mount drive /dev/sdb1 at /media/sdb1
$ sudo mount /dev/sdb1 /media/sdb1
3. View Files from Mounted drive
To view files in your drive, just cd to that folder and run ls -l command.
$ cd /media/sdb1 $ ls -l
4. Automatic mount at boot (optional)
Please note the above steps are temporary and last only till you end your terminal session. In order to automatically mount drive at bootup, edit fstab
$ sudo vi /etc/fstab
Add the following line depending on your file system. Replace /dev/sdb1 with your volume, and /media/sdb1 with your mount folder.
Ext3
/dev/sdb1 /media/sdb1 ext3 defaults 0 2
FAT32
/dev/sdb1 /media/sdb1 vfat defaults 0 2
Save and close the file.
That’s it. In this article, we have looked at how to mount drive to folder in terminal.
Also read:
How to Disable mod_deflate in Apache server
How to Stop/Prevent Brute Force SSH Attacks
How to Disable SSH Root Login in Linux
How to Open, Extract RAR File in Linux
How to Stop Package Update in Linux
Related posts:
Sreeram has more than 10 years of experience in web development, Python, Linux, SQL and database programming.