Linux : Storage Management (Day 6)

Linux : Storage Management (Day 6)

Linux Storage Management Commands

Understanding Disk Storage

Disk storage refers to the physical storage devices (such as hard drives or SSDs) used to store data. In Linux, disks are represented as block devices (e.g., /dev/sda, /dev/nvme0n1). Understanding disk storage involves knowing how to manage these devices effectively.


Partitioning Hard Disks

Partitioning is the process of dividing a disk into logical areas called partitions. Each partition can be managed separately. Here are the steps for creating partitions:


Attach the Disk:


  • Physically connect the new disk to the system (e.g., using VMware).
  • Verify that the disk is recognized by the system (use lsblk or cat /proc/partitions).


Create Partitions:


  • Use tools like parted or fdisk to create partitions on the disk.
  • Example: Creating a primary partition with parted:

sudo parted /dev/sdb mklabel gpt        
sudo parted /dev/sdb mkpart primary ext4 1MiB 10GiB        

Create a File System:


  • After creating a partition, format it with a filesystem (e.g., ext4, xfs).
  • Example: Creating an ext4 filesystem

sudo mkfs.ext4 /dev/sdb1        

Mount the File Systems:


  • Mount the filesystems to specific directories in the filesystem hierarchy.
  • Example: Mounting the partition to /mnt/data:

sudo mount /dev/sdb1 /mnt/data        

Logical Volume Management (LVM)


LVM provides flexible disk management by allowing you to create logical volumes (LVs) from physical volumes (PVs). Here are some LVM-related commands:


Checking Existing LVM:


  • Use lvdisplay or vgdisplay to view existing logical volumes and volume groups.


Creating LVM Logical Volumes:


  • Create a volume group (VG) and logical volume (LV).
  • Example:

sudo vgcreate myvg /dev/sdc        
sudo lvcreate -n mylv -L 5G myvg        

Growing LVM Logical Volumes:


  • Extend an existing LV.
  • Example:

sudo lvextend -L +2G /dev/myvg/mylv        
sudo resize2fs /dev/myvg/mylv        

Mounting Filesystems


  • Supported Filesystems: Linux supports various filesystems (e.g., ext4, xfs, btrfs).
  • Use the /etc/fstab file to define mountable filesystems.
  • Mount filesystems using the mount command.
  • Example: Mounting an ext4 filesystem:

sudo mount /dev/sdb1 /mnt/data        

Swap Areas


  • Swap space provides virtual memory.
  • Enable/disable swap using swapon and swapoff.
  • Example:

sudo mkswap /dev/sdb2        
sudo swapon /dev/sdb2        

Creating a Filesystem with mkfs


  • Use mkfs to create a filesystem on a partition.
  • Example:

sudo mkfs.ext4 /dev/sdb1        

Remember to adjust the commands and paths according to your specific setup. Feel free to explore more options and dive deeper into each topic! ??




Pavan Kumar Dasari

DevOps Engineer ??

10 个月

Bhupesh Patil Very useful thanks for sharing ??

要查看或添加评论,请登录

Bhupesh Patil ?的更多文章

  • Linux : Networking & Security (Day 7)

    Linux : Networking & Security (Day 7)

    10 Commands Of Networking You Should Know !!! Ping Explanation: The command tests network connectivity by sending ICMP…

  • Linux : User Group Management (Day 5)

    Linux : User Group Management (Day 5)

    Local User Accounts useradd The command is used to create a new user account in Linux. Syntax: Options: : Specify the…

    1 条评论
  • Linux : Operation Deployment (Day 4)

    Linux : Operation Deployment (Day 4)

    Manage System Using systemctl : Syntax : : Additional flags or options for the command. : The action you want to…

  • Linux : Essential Commands - Part 2 (Day 3)

    Linux : Essential Commands - Part 2 (Day 3)

    Four Magic Commands : Options : : Count of occurrences : Only print duplicate lines : Only print unique lines : Ignore…

  • Linux : Essential Commands - Part 1 (Day 2)

    Linux : Essential Commands - Part 1 (Day 2)

    Working with Files & Directories :- - Options: : List all entries including those starting with a dot . : Use a long…

  • Linux : Introduction Commands (Day 1)

    Linux : Introduction Commands (Day 1)

    1. help The command in Linux is used to display information about shell built-in commands.

    2 条评论

社区洞察

其他会员也浏览了