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
blkidcommand:sudo blkidThis 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:sudo mkdir /mnt/mydisk
Edit the
/etc/fstabFile:Open the
/etc/fstabfile in a text editor:sudo nano /etc/fstabAdd an entry at the end of the file with the following format:
UUID=<your-disk-uuid> <mount-point> <filesystem-type> <options> <dump> <pass>For example, to mount
/dev/sda1as an ext4 filesystem to/mnt/mydisk, add:UUID=your-disk-uuid /mnt/mydisk ext4 defaults 0 2Replace
your-disk-uuidwith the actual UUID you found in step 1.Replace
/mnt/mydiskwith the mount point you created in step 2.The
ext4should be the correct filesystem type (you can check this withblkid).defaultsare the typical options (you can change them if needed).0means no backup for the partition.2indicates the order in which filesystems are checked byfsckat boot (root filesystem is usually1, and others are2).
Test the Mount:
After saving the
/etc/fstabfile, you can test the mount without rebooting:sudo mount -aThis 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:
sudo rebootAfter rebooting, check if the disk is mounted correctly:
df -h
Last updated