Mounting disk on startup
To mount a disk on startup in Linux, you need to modify the /etc/fstab
file, which manages automatic mounting of file systems at boot time.
Steps to Mount a Disk on Startup:
Find the Disk's UUID:
First, you need to find the UUID of the partition you want to mount. You can use the
blkid
command:This will list all the partitions and their UUIDs. Look for the partition you want to mount, e.g.,
/dev/sda1
, and note down its UUID.
Create a Mount Point:
You need a directory where the disk will be mounted. You can create a mount point, for example,
/mnt/mydisk
:
Edit the
/etc/fstab
File:Open the
/etc/fstab
file in a text editor:Add an entry at the end of the file with the following format:
For example, to mount
/dev/sda1
as an ext4 filesystem to/mnt/mydisk
, add:Replace
your-disk-uuid
with the actual UUID you found in step 1.Replace
/mnt/mydisk
with the mount point you created in step 2.The
ext4
should be the correct filesystem type (you can check this withblkid
).defaults
are the typical options (you can change them if needed).0
means no backup for the partition.2
indicates the order in which filesystems are checked byfsck
at boot (root filesystem is usually1
, and others are2
).
Test the Mount:
After saving the
/etc/fstab
file, you can test the mount without rebooting:This command mounts all filesystems listed in
/etc/fstab
, including the one you just added. If there is no error, the disk should mount successfully.
Reboot and Verify:
Reboot your system:
After rebooting, check if the disk is mounted correctly:
Last updated