Mount Storage Volumes onto Linux Distro Operating Systems
Learn how to connect an external storage devices onto Linux based operating systems. From partitioning and formatting towards auto mounting.
- External Storage Device
- Advanced Topics
Migrate from here… categories: [ Storage ] tags: [volume, storage, linux, mount]
External Storage Device
These instructions cover the necessary steps for connecting an external storage device onto a Linux operating system.
Linux Devices Naming
External volumes in Linux are prefixed with
sd which stands for SCSI Disk.
SCSI is the acronym of Small Computer System Interface.
The suffix of
sd which is
sdc refers to the 1st / 2nd / 3rd
SCSI mounted devices.
The numeric value for each mounted device i.e.
sda2 is the partitions within each disk.
Partition & Format
In this example I will use a USB drive as an external volume and connect it to a Raspberry Pi board named
kmaster, these instructions are relevant for every Linux distro, skip the first step if it is irrelevant for you.
(Optional): Connect the external storage device to a Raspberry Pi node and SSH into it
List all disks partition on the RPi server
sudo lsblk -o UUID,NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL,MODEL
List the current devices on the RPi server
sudo fdisk -l
sdXname of the external storage device and create a new partition table
1 2 3 4 5 6 7
sudo fdisk /dev/sda # m - print commands menu (for visibility) # g - create a new empty GPT partition table # n - add a new partition # Press enter x3 for defaults (Partition number, First sector, Last sector) # w - write table to disk and exitImportant: Make sure you are working on the current
sdXdevice, all data on the external storage device is about to wipe, there is no going back after writing table to disk !
Check that the external storage device is properly partitioned under a Linux filesystem
Format the external storage device into
sudo mkfs.ext4 /dev/sda1
Verify the external storage device is properly formatted into
UUIDof the storage device disk partition
Create a target folder to be the mount point of the storage device (
container-registryin this example)
sudo mkdir /mnt/container-registry
Mount the storage device partition
/dev/sda1at the mount point
sudo mount /dev/sda1 /mnt/container-registry
Verify that the storage device is mounted successfully
ls -lah /mnt/container-registry
(Optional): Unmount the storage device
sudo umount /mnt/container-registry
These instructions are relevant to any Linux distributions operating systems. This section orientation is going to be around
Debian OS which is the Raspberry Pi OS in use. Please follow the Setting Up a Raspberry Pi Cluster post for additional information.
We will edit the OS file system table
fstab to auto-mount the external storage device when the Raspberry Pi server starts up.
TYPEof the storage device disk partition
Edit the OS file system table
# Open fstab for editing sudo vi /etc/fstab
Append the following line at the end of the file
# Append to end of file UUID=<value-from-step-1> /mnt/container-registry ext4 defaults,auto,users,rw,nofail,x-systemd.device-timeout=30 0 0Note: We have set a mount point
ext4file system and defined a
30 sectimeout for the RPi board if storage disk is disconnected when the RPi starts up.
Upon completing this post you should be familiar with how external storage devices are identified and connected to a Linux operating system
What now? Partition, format and mount any external storage device you require onto your Linux distro OS directly from the CLI !
Please leave your comment, suggestion or any other input you think is relevant to this post in the discussion below.