I don’t do this often enough, and I have a terrible memory, so I’m going to commit this here.
Today, I needed to create an xfs file system on a linux server. The disk was attached over iscsi, and was presented as multiple raid arrays, each array greater than 2TB. So, the way to deal with this is to use GNU’s parted tool, and create a GPT label. The built in fdisk can only do EFI and that’s not going to cut it here.
For each raided disk :
# parted /dev/sda
GNU Parted 2.1
Using /dev/sda
Welcome to GNU Parted! Type ‘help’ to view a list of commands.
(parted) mklabel gpt
Warning: The existing disk label on /dev/sda will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? YEs
(parted) print
Model: NEXSAN SATABeast2 (scsi)
Disk /dev/sdg: 16.0TB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
(parted) unit TB
(parted) mkpart primary 0.00TB 16.00TB
(parted) print
Model: NEXSAN SATABeast2 (scsi)
Disk /dev/sdg: 16.0TB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 0.00TB 16.0TB 16.0TB primary
(parted) quit
Information: You may need to update /etc/fstab.
Ok, that’s done then. Now, to work on the LVM. There’s an excellent howto in the references section below, but here’s the basic commands I use :
# pvcreate /dev/sda1 /dev/sdb1 /dev/sdc1
# vgcreate vg_photographs /dev/sda1 /dev/sdb1 /dev/sdc1 <--- vg_photographs being the volume group name
# lvcreate --name lv_photodisk --size 40T vg_photographs <--- lv_photodisk being the logical volume name. Also, 40TB is the size of all raid disks combined
Now, we create an xfs file system :
# mkfs.xfs /dev/vg_photographs/lv_photodisk
# mount /dev/vg_photographs/lv_photodisk /mnt/photos
Anddddd, done.
Now, to extend the file system because 40TB just isn't enough for your photos. Do the parted thing again for the new disk :
# parted /dev/sdd
And the LVM pieces too :
# pvcreate /dev/sdd1
# vgextend vg_photographs /dev/sdd1
Now, run :
# vgdisplay --verbose
And from the output, add up all the X and Y pieces :
...snip...
Total PE / Free PE X / 0
...snip...
Total PE / Free PE Y / Y
...snip...
The total space of the disk is going to be X+Y
# lvextend -l 40060959 /dev/vg_photographs/lv_photodisk
And finally, grow the file system :
# xfs_growfs /mnt/photos
You can do a df to check but it should be pretty good at this point.
H.
Ref :
1) Linux LVM Howto
2) Growing XFS in LVM
3) GNU Parted









