First new disk partition to be created
fdisk can be used for disk lesser than 2TB. For greater than 2TB we need to used gparted
Partition Creation using fdisk
Check disk size
# fdisk /dev/sdb
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: The size of this disk is 5.9 TB (5908688535552 bytes).
DOS partition table format can not be used on drives for volumes
larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID
partition table format (GPT).
Creating 2TB partition using Fdisk
# fdisk /dev/sdb1
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-718357, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-267349, default 267349):
Using default value 267349
Command (m for help): p
Disk /dev/sdb: 5908.7 GB, 5908688535552 bytes
255 heads, 63 sectors/track, 718357 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x3dffd626
Device Boot Start End Blocks Id System
/dev/sdb1 1 267349 2147480811 83 Linux
Creating partition using GPT
# parted /dev/sdb
GNU Parted 2.1
Using /dev/sdb
Welcome to GNU Parted! Type ‘help’ to view a list of commands.
(parted) print
Error: /dev/sdb: unrecognised disk label
(parted) mklabel gpt
(parted) print
Model: Unknown (unknown)
Disk /dev/sdb: 5909GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
# parted /dev/sdb
(parted) mkpart primary 0GB 5909GB
(parted) print
Model: VMware Virtual disk (scsi)Disk /dev/sdb: 5909GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 1049kB 5909GB 5909GB primary
# fdisk /dev/sdb
Command (m for help): print
Disk /dev/sdb: 5908.7 GB, 5908688535552 bytes
255 heads, 63 sectors/track, 718357 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sdb1 1 267350 2147483647+ ee GPT
Format and Mount the Partition
# mkfs /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
360644608 inodes, 1442550528 blocks
72127526 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
44024 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848, 512000000, 550731776, 644972544
Writing inode tables: 3955/44024
Writing inode tables: 5022/44024
Writing inode tables: 7218/44024
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 23 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
Mounting
Note: Don’t mount if want to create LV (Logical Volume).
# mkdir /data
# mount /dev/sdb1 /data
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 127G 1.6G 119G 2% /
/dev/sdb1 5.3T 59M 5.1T 1% /data
Add UUID in /etc/fstab
UUID=”9c51dbd5-6a5e-4f02-986d-1976780916e4″ /data3 ext4 defaults 0 2
Steps To Create LVM Using vgcreate, lvcreate, and lvextend lvm2 Commands
Select the Physical Storage Devices for LVM – Use pvcreate, pvscan, pvdisplay Commands
$ sudo pvcreate /dev/sdb1
Physical volume “/dev/sdb1” successfully created
$ sudo pvscan
PV /dev/sdb1 lvm2 [3.72 GB]
Total: 1 [3.72 GB] / in use: 0 [0 ] / in no VG: 1 [3.72 GB]
$ sudo pvdisplay
— Physical volume —
PV Name /dev/sdb1
VG Name
PV Size 3.72 GB / not usable 2.12 MB
Allocatable yes
PE Size (KByte) 4096
Total PE 476
Free PE 456
Allocated PE 20
PV UUID m67TXf-EY6w-6LuX-NNB6-kU4L-wnk8-NjjZfv
Create the Volume Group – Use vgcreate, vgdisplay Commands
$ sudo vgcreate vol_grp1 /dev/sdb1
Volume group “vol_grp1” successfully created
vgdisplay command lists the created volume groups
$ sudo vgdisplay
— Volume group —
VG Name vol_grp1
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size 3.72 GB
PE Size 4.00 MB
Total PE 952
Alloc PE / Size 0 / 0
Free PE / Size 952 / 3.72 GB
VG UUID Kk1ufB-rT15-bSWe-5270-KDfZ-shUX-FUYBvR
Command to Create Logical Volume
lvcreate -L 786431 -n logical_vol1 vol_grp1
vgdisplay command lists the created volume
$ sudo lvdisplay
— Logical volume —
LV Name /dev/vol_grp1/logical_vol1
VG Name vol_grp1
LV UUID ap8sZ2-WqE1-6401-Kupm-DbnO-2P7g-x1HwtQ
LV Write Access read/write
LV Status available
# open 0
LV Size 80.00 MB
Current LE 20
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 252:0
Command to Extend Logical Volume
lvextend -l +100%FREE /dev/vol_esdata/lv_esdata
mksf.ext4 /dev/vol_esdata/lv_esdata