Linux : Mounting Hard Disk using fdisk.

Adding an external hard disk to your Linux system can be useful for additional storage, backups, or data migration. This guide covers the step-by-step process to partition, format, and permanently mount an external hard disk on a Linux system.
Step 1: Identify the External Hard Disk
First, connect your external hard disk to your Linux machine and identify it using the following command:
df -khAlternatively, you can use:
lsblkThis will list all storage devices connected to your system.
Step 2: Partitioning the External Hard Disk
Use fdisk to partition the external drive. Replace /dev/sdb with the correct device name.
sudo fdisk /dev/sdbInside fdisk, follow these steps:
Press
nto create a new partition.Select
pfor a primary partition.Choose a partition number (default is 1).
Specify the first and last sector (or press Enter to use the default values).
Press
wto write the changes and exit.
Step 3: Formatting the Partition
Once partitioning is complete, format the new partition with an appropriate filesystem (e.g., ext4):
sudo mkfs.ext4 /dev/sdb1Step 4: Creating a Mount Point
Create a directory where you will mount the external hard disk:
sudo mkdir /shubhamStep 5: Mounting the Partition
To temporarily mount the disk, use:
sudo mount /dev/sdb1 /shubhamVerify the mount using:
df -khStep 6: Making the Mount Permanent
To ensure the disk mounts automatically on reboot, edit the /etc/fstab file:
sudo nano /etc/fstabAdd the following line at the end:
/dev/sdb1 /shubham ext4 defaults 0 0 Step 7: Testing the Permanent Mount
Reboot your system and check if the mount persists:
df -khIf the disk is not mounted, manually mount it using:
sudo mount -aConclusion
By following these steps, you have successfully mounted an external hard disk permanently on your Linux system. This method ensures that your external disk is always available, even after a system restart.
=======================================================================
Thank you, check out more blogs for such information..!
For any queries,feel free to reach out me on shubhammore07007@gmail.com
Comments
Post a Comment