Mounting a new hard drive to a Linux system involves several steps. Here's a step-by-step guide:
-
Identify the New Hard Drive:
- First, you need to identify the new hard drive. You can use the
lsblk
orfdisk -l
command to list all the block devices and find your new drive.
lsblk
or
sudo fdisk -l
- First, you need to identify the new hard drive. You can use the
-
Partition the New Hard Drive:
- If your new hard drive is not already partitioned, you need to create a partition. You can use the
fdisk
orparted
tool.
sudo fdisk /dev/sdX
Replace
/dev/sdX
with your actual device name (e.g.,/dev/sdb
).In
fdisk
:- Press
n
to create a new partition. - Press
p
for primary partition. - Choose the partition number and accept the default values to use the entire disk.
- Press
w
to write the changes and exit.
- If your new hard drive is not already partitioned, you need to create a partition. You can use the
-
Format the New Partition:
- Once the partition is created, you need to format it with a filesystem. For example, to format it with the ext4 filesystem:
sudo mkfs.ext4 /dev/sdX1
Replace
/dev/sdX1
with your actual partition name. -
Create a Mount Point:
- You need to create a directory where you will mount the new hard drive.
sudo mkdir /mnt/newdrive
-
Mount the New Partition:
- Now, you can mount the new partition to the mount point you created.
sudo mount /dev/sdX1 /mnt/newdrive
-
Update /etc/fstab:
- To ensure the new drive mounts automatically at boot, you need to add an entry to the
/etc/fstab
file. - First, get the UUID of the new partition:
sudo blkid /dev/sdX1
- Open
/etc/fstab
in a text editor:
sudo nano /etc/fstab
- Add a line for the new drive:
UUID=your-uuid-here /mnt/newdrive ext4 defaults 0 2
Replace
your-uuid-here
with the UUID you got from theblkid
command. - To ensure the new drive mounts automatically at boot, you need to add an entry to the
-
Mount All Filesystems:
- Finally, test the
/etc/fstab
entry by running:
sudo mount -a
- If there are no errors, your new hard drive should be mounted and ready to use.
- Finally, test the
Assuming your new hard drive is /dev/sdb
and you want to mount it at /mnt/newdrive
:
sudo fdisk /dev/sdb
# Create partition, write changes
sudo mkfs.ext4 /dev/sdb1
# Format partition
sudo mkdir /mnt/newdrive
# Create mount point
sudo mount /dev/sdb1 /mnt/newdrive
# Mount partition
sudo blkid /dev/sdb1
# Get UUID
sudo nano /etc/fstab
# Add line: UUID=your-uuid-here /mnt/newdrive ext4 defaults 0 2
sudo mount -a
# Test fstab entry