Manage partition system and how to handle the some serious scenario’s

How to create a partition in Linux

First, check available partitions

~lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
vda 252:0 0 9G 0 disk
├─vda1 252:1 0 1G 0 part /boot
└─vda2 252:2 0 8G 0 part
├─cl-root 253:0 0 7.1G 0 lvm /
└─cl-swap 253:1 0 924M 0 lvm [SWAP]
vdb 252:16 0 20G 0 disk
vdc 252:32 0 10G 0 disk
└─vdc1 252:33 0 4.7G 0 part
└─vg002-002 253:2 0 8G 0 lvm /home/chirag/moun
vdd 252:48 0 10G 0 disk
└─vdd1 252:49 0 7.5G 0 part
└─vg002-002 253:2 0 8G 0 lvm /home/chirag/moun

To select and start working on partition (vdb)

parted /dev/vdb

Need to create MBR table to start working on disk ( Parition table)

mklabel
print free

It will look like this

GNU Parted 3.1
Using /dev/vdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print free
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number Start End Size Type File system Flags
32.3kB 21.5GB 21.5GB Free Space



Create primary partition

(parted) mkpart
Partition type? primary/extended? primary
File system type? [ext2]? ext4
Start? 32.2kb
End? 4gb

quit

[[email protected] techouse]# mkfs.ext4 /dev/vdb1

mount -t ext4 /dev/vdb1 /test

Edit fstab file

vim /etc/fstab
/dev/sdax /media/user/label ext4 defaults 0 0

lsblk

Leave a comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.