Posted On August 24, 2021

Linux: Commands to Add a New Disk

kimconnect 0 comments
blog.KimConnect.com >> Linux >> Linux: Commands to Add a New Disk
# Step 1: create partitioning table (gpt or msdos/mbr)
device=/dev/sdc
sudo parted $device mklabel gpt

# Step 2: Create primary partition and reserve the whole disk toward it
device=/dev/sdc
sudo parted -a opt $device mkpart primary ext4 0% 100%

# Step 3: Creating an ext4 file system
partition=/dev/sdc1
label=data
mkfs.ext4 -L $label $partition

# Optional: Change disk label
# partition=/dev/sdc1
# label=data
# e2label $partition data

# Step 4: Mount the new partition
mount=/media/data
partition=/dev/sdc1
mkdir -p $mount # create new mount point
mount $partition $mount # mounting partition toward new target mount point

# Add this line to /etc/fstab
LABEL=data /media/data ext4 defaults 0 2

# Reload mounts
mount -a

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

Linux: RSYNC Examples

Following are a few practical uses of this command: # Copying from a Local Directory…

Linux: How to Set Startup Script

In previous Linux versions, startup scripts can simply be enabled by linking a script into…

Administering CentOS 8 with Cockpit

CentOS 8 default installation already has this utility installed. To render it active, one only…