Adding a new disk, volume group and volume in CentOS6 from the command line.
- August 24th, 2012
- Posted in Documentation
- Write comment
I needed to add more storage to my CentOS6 machine for my remote system backups. I decided to allocate a completely new volume group and volume to facilitate this need. Here are the steps I used to create the volume:
The new disk was added via vSphere, since this a VM. I determined the correct device file by looking to the dmesg output.
Initialize the whole disk using pvcreate.
# pvcreate /dev/sde
For partitions, use pvcreate /dev/sde[x].
Create a volume group
# vgcreate vg_vmlinux01_backup /dev/sde
To add multiple disks or partions, use vgcreate volume_group_name /dev/sdx /dev/sdy …
Activate the volume group:
# vgchange -a y vg_vmlinux01_backup
Create logical volume
This will allocate all remaining available space to the volume. You can use -L to specify a particular size. Not needed in my case.
# lvcreate -l 100%FREE -n lv_rmbackup vg_vmlinux01_backup
Write the filesystem with the desired label.
# mkfs -t ext4 -j -L /rmbackup /dev/vg_vmlinux01_backup/lv_rmbackup
If you need to create the filesystem with more than the default number of inodes:
# mkfs -t ext4 -j -N 20000000 -L /rmbackup /dev/vg_vmlinux01_backup/lv_rmbackup
Modify the /etc/fstab:
# vi /etc/fstab
…
LABEL=/rmbackup /rmbackup ext4 defaults 1 0
…
Mount it:
# mount /rmbackup
No comments yet.