How to create partition and logical volume on the partition in Linux

Find the disk you are trying to create partition on by typing:

[email protected]: fdisk -l
Disk /dev/sda: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders, total 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00056a89

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 58720255 29359104 83 Linux
/dev/sda2 58722302 62912511 2095105 5 Extended
/dev/sda3 62912512 104857599 20972544 83 Linux
/dev/sda5 58722304 62912511 2095104 82 Linux swap / Solaris

Disk /dev/sdb: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders, total 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0007dccf

Device Boot Start End Blocks Id System
/dev/sdb1 2048 52430847 26214400 83 Linux
/dev/sdb2 52430848 104857599 26213376 83 Linux

Disk /dev/sdc: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/sdc doesn't contain a valid partition table

You will your disk listed and may have a warning besides it that this disk doesn’t contain parition.

You can quickly create partition on the desired disk by typing:

[email protected]:~# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x0f878caa.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the DOS compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1):
Using default value 1
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):
Using default value 41943039

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Once the partition is created if you would like you can create file system on it or maybe create a logical volume group:

[email protected]:~# vgcreate vm /dev/sdc1
No physical volume label read from /dev/sdc1
Physical volume "/dev/sdc1" successfully created
Volume group "vm" successfully created
[email protected]:~# lvcreate -L 5G -n Vol1 vm
Logical volume "Vol1" created
[email protected]:~# lvs
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
Vol1 vm -wi-a---- 5.00g

There you can see we have new logical volume that we just created.

Leave a Reply

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