Home » Uncategorized » Dealing with Large Linux Partitions (greater than 2 TB)

Dealing with Large Linux Partitions (greater than 2 TB)

  1. Start off by getting optimal alignment for the best disk performance and create the partition

Verify the disk is there

#replace sdc with whatever disk you are working with

DISK="sdc"
fdisk -l /dev/${DISK}


Get some information about the disk now

OIOSZ=`cat /sys/block/${DISK}/queue/optimal_io_size`
OFFSET=`cat /sys/block/${DISK}/alignment_offset`

Get Logical block size

LBS=`parted -l /dev/${DISK} | grep "Sector size" | head -1 | awk -F ":" '{print $2}' | awk -F "/" '{print $1}' | sed 's/[A-Z]//g' | sed 's/ //g'`
let a=${OIOSZ}+${OFFSET}
let start=${a}/${LBS}
echo "Start here: $start"

Start the parted command


parted /dev/${DISK}
mklabel gpt
mkpart primary $start 100%
align-check optimal 1

2. create the LVM

pvcreate /dev/${DISK}1
vgcreate vgdisk /dev/${DISK}1

# get the free disk space 
vgdisplay vgdisk  | grep Free


example:
[root@grv-kdb-res11 ~]# vgdisplay vgdisk | grep Free
Free PE / Size 5186 / 20.26 GiB

lvcreate -n lv_disk -L 20G vgdisk
mkfs.ext4 /dev/mapper/vgdisk-lv_disk

# remember to mount and make an entry in /etc/fstab

Note:  I use ext4 for lvm filesystems because some other filesystems can't be shrunk.  

Leave a Reply