LVM Add Disks Cheat Sheet

$ 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 0xec3e2922.
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)

The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.

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-3907029167, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-3907029167, default 3907029167):
Using default value 3907029167

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): w
The partition table has been altered!

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

$ pvcreate /dev/sdb1 /dev/sdc1
  Physical volume "/dev/sdb1" successfully created
  Physical volume "/dev/sdc1" successfully created

$ pvdisplay

$ vgcreate vg_data /dev/sdb1 /dev/sdc1
  Volume group "vg_data" successfully created

$ lvcreate --name dbext4 --size 100GB vg_data
  Logical volume "dbext4" created

$ lvcreate --name dbxfs --size 100GB vg_data
  Logical volume "dbxfs" created

$ lvcreate --name backup --size 250GB vg_data
  Logical volume "backup" created

$ mkfs.ext4 /dev/vg_data/backup
$ mkfs.ext4 /dev/vg_data/dbext4
$ mkfs.xfs /dev/vg_data/dbxfs 

$ mkdir /mnt/backup /mnt/dbext4 /mnt/dbxfs

$ blkid
/dev/sda1: UUID="***" TYPE="ext2"
/dev/sda5: UUID="***" TYPE="LVM2_member"
/dev/sdb1: UUID="***" TYPE="LVM2_member"
/dev/sdc1: UUID="***" TYPE="LVM2_member"
/dev/mapper/vg_data-dbext4: UUID="***" TYPE="ext4"
/dev/mapper/vg_data-dbxfs: UUID="***" TYPE="xfs"
/dev/mapper/vg_data-backup: UUID="***" TYPE="ext4"
/dev/mapper/ender-root: UUID="***" TYPE="ext4"
/dev/mapper/ender-swap_1: UUID="***" TYPE="swap"

$ cat /etc/fstab
UUID=***       /mnt/backup     auto    defaults,nobootwait,data=writeback,barrier=0,nobh,errors=remount-ro     0       0
UUID=***       /mnt/dbext4     auto    defaults,nobootwait,noatime,data=writeback,barrier=0,nobh,errors=remount-ro       0       0
UUID=***       /mnt/dbxfs      auto    defaults,nobootwait,noatime,allocsize=64k       0       0



Add new comment

Plain text

  • No HTML tags allowed.
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link]( "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.