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

How to Install Visual Studio Code on Linux Mint 20.04

Linux Mint versions earlier than 20.04 would allow a user to install snapd, prior to…

How to Install Internet Explorer on Ubuntu 20.04

Step 1: Install PlayonLinux kim@kimlinux:~# sudo apt install playonlinux -y Step 2: Install Internet Explorer…

Linux Filesystem Hierarchy Standard (FHS)

/bin : binaries to run fundamental Linux functions/boot : boot partition/cdrom : legacy mounting point/dev…