Managing Drives in Linux
Drive Types
For more information on drive types and the /dev/ paths associated with them, review this StackOverflow post.
USB Drives
USB Drives are listed under /dev/sd*. You might see a drive under /dev/sda and
partitions on that drive under /dev/sda1
Internal Drives
Internal Drives are listed under /dev/ and have paths defined by the interface.
NVME Drives
- NVME Drives will be listed under
/dev/nvme0. - NVME Drives have a unique concept of "namespaces" that will be the second identifier in the string, i.e. /dev/nvme0n1
- NVME Drive partitions will be under a namespace and identified with p1, p2, etc. where 1 and 2 are the partition identifiers.
Formatting a New Drive
Instructions were adapted from DigitalOcean and CherryServers.
Create a Partition and File System
This walkthrough will use /dev/nvme0n1 as an example of a drive.
sudo fdisk /dev/nvme0n1- Type
nto start creating a new partition. - You can accept all defaults.
- Type
wto write your changes to the disk. This will also exit the fdisk utility.
Make sure you create a file system after creating the partition!
If you don't create a file system on new partitions, you won't be able to mount and use the drive(s).
sudo mkfs.ext4 /dev/nvme0n1p1
Wipe Existing Content
Make sure you are wiping the correct drive! This step is irreversible.
If you need to wipe an existing drive, you can do so with sudo fdisk.
For NVME drives, you will want to run fdisk against nvme0n1. In general, you won't
run any commands against the root level nvme0.
Mounting Internal Drives
- This section has instructions on how to configure internal drives to auto-mount.
- For manual mounting instructions, see the next section "Mounting External Drives".
Create a mount point for the new drive, i.e.
/data0, or increment the data# for subsequent drives.Find the UUID for the drive's primary partition with the command
blkid.Edit the fstab file with
sudo nano fstab.Add a new entry to the file for the new drive:
UUID=10104b0b-ffb6-4743-917b-880ef3ee4138 /data0 ext4 defaults,nofail 0 2Save the file and exit (ctrl+x).
Mount all configured and currently unmounted drives with
sudo mount -a.Verify that the drive was mounted with the command
df -h /data0. The results of this command should show the Filesystem as/dev/nvme01n1p1and the Mounted on as/data0.
Mounting External Drives
- This section has instructions on how to mount external drives like HD and SSD onto linux-based systems like MSI.
- Additional information can be found here: https://www.tomshardware.com/how-to/mount-drives-linux.
- To auto-mount external drives, you can use the previous section, "Mounting Internal Drives".
Instructions
We can go about mounting the drives in 2 ways:
- GUI
- Linux terminal
Both the approaches are mentioned in the link above. The below instructions are based on second approach.
Note that the gid and uid parameters may differ for a given system. You can find the group id (gid) and user id (uid) by running the id command.
Use umask permissions 0022 for rwx,rx,rx.
# To identify the USB drive. In our case, we are looking for sda or sdb
lsblk
# Create directory to mount the drive into
sudo mkdir mount_path
# To mount the drive to the directory created above
sudo mount drive_path mount_path -o umask=0022,gid=1000,uid=1000
You should run lsblk after this to verify that the drive is mounted at drive_path (which should be sda or sdb).
Example
The below example shows how to mount a drive called WD_BLACK onto MSI with permissions set for the 'gqc' user.
lsblk
sudo mkdir /media/gqc/WD_BLACK
sudo mount /dev/sda1 /media/gqc/WD_BLACK -o umask=0022,gid=1000,uid=1000
Instructions for Mounting Drives onto the MSI Server
There is a mount_drives.sh script present on the MSI server that is composed of commands to mount the unionsine1, unionsine2, T7, and WDBlack drives. The steps to use the script are as follows:
- SSH into the msi server by running
ssh msi - Edit the shell file by running
nano mount_drives.sh - Open up a new terminal window and run
lsblk | grep sd - To figure out which drive is which, check the sd* labels with listed sizes:
- T7 is 2 TB
- WD is 5 TB
- unionsine 1 and 2 are 10TB
- Correctly set T7 and WD sd* labels in shell script, then guess for the unionsines
- Run the mount_drives.sh script.
- To check if you guessed the unionsines correctly, run
ls -l /media/gqc/unionsine1. - VS_Research is in unionsine1, so if you see VS_Research after running the command in step 7, you are done and there is nothing left to do.
- If VS_Research doesn't show up in /media/gqc/unionsine1, then you need to unmount the unionsine drives and change the sd* mappings for unionsines.
- If you need to unmount unionsines:
sudo umount /media/gqc/unionsine1sudo umount /media/gqc/unionsine2
- Swap sd* labels in mount sh script.
- Finally, run ./mount_drives.sh