ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Linux Practicum: Adding a Second Storage Drive on CentOS 7 with LVM and XFS

    Scheduled Pinned Locked Moved IT Discussion
    linuxsam linux administrationlinux practicumstoragecentoscentos 7scalescale hc3lsblklvmxfs
    1 Posts 1 Posters 1.9k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • scottalanmillerS
      scottalanmiller
      last edited by

      In this example I will walk through the creation of a new 1TB filesystem on CentOS 7 Linux using LVM and XFS.

      0_1468422280345_Screenshot from 2016-07-13 10:34:13.png

      In my example platform, I am working from a KVM based Scale HC3 cluster. This allows me to make a VIRTIO paravirtualized block device which will show up as a /dev/vd* device in my operating system.

      We can look up our available disk devices using the lsblk command:

      # lsblk 
      NAME                             MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
      sr0                               11:0    1   603M  0 rom  
      vda                              252:0    0  14.9G  0 disk 
      ├─vda1                           252:1    0   500M  0 part /boot
      └─vda2                           252:2    0  14.4G  0 part 
        ├─centos_lab--lnx--centos-root 253:0    0  12.9G  0 lvm  /
        └─centos_lab--lnx--centos-swap 253:1    0   1.5G  0 lvm  [SWAP]
      vdb                              252:16   0 931.3G  0 disk 
      

      We can see that /dev/vda is already in use and /dev/vdb is unused so we know that that is the new block device that we just added to our server.

      Now we will add /dev/ldb to LVM as a Physical Device (PV), add it into a Volume Group (VG) and create a single Logical Volume (LV) that will span the entire device. Then comes the filesystem creation. Then we will create a new logging location at /var/log2, put an entry into /etc/fstab for the new filesystem and mount the new filesystem there.

      # pvcreate /dev/vdb
        Physical volume "/dev/vdb" successfully created
      # vgcreate vg_logs /dev/vdb
        Volume group "vg_logs" successfully created
      # lvcreate -l 100%FREE -n lv_logs vg_logs
        Logical volume "lv_logs" created.
      # mkfs.xfs /dev/vg_logs/lv_logs 
      meta-data=/dev/vg_logs/lv_logs   isize=256    agcount=4, agsize=61035008 blks
               =                       sectsz=512   attr=2, projid32bit=1
               =                       crc=0        finobt=0
      data     =                       bsize=4096   blocks=244140032, imaxpct=25
               =                       sunit=0      swidth=0 blks
      naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
      log      =internal log           bsize=4096   blocks=119209, version=2
               =                       sectsz=512   sunit=0 blks, lazy-count=1
      realtime =none                   extsz=4096   blocks=0, rtextents=0
      # mkdir /var/log2
      # echo '/dev/vg_logs/lv_logs /var/log2                                   xfs     defaults        0 0' >> /etc/fstab
      # mount /var/log2
      # df -h /var/log2
      Filesystem                   Size  Used Avail Use% Mounted on
      /dev/mapper/vg_logs-lv_logs  931G   33M  931G   1% /var/log2
      

      That's it. We can see that the filesystem has been created and is able to be mounted via the configuration stored in /etc/fstab so that we know we are good for this to survive a reboot.

      We can see our LVM details below:

      # pvs
        PV         VG                    Fmt  Attr PSize   PFree 
        /dev/vda2  centos_lab-lnx-centos lvm2 a--   14.41g 40.00m
        /dev/vdb   vg_logs               lvm2 a--  931.32g     0 
      # vgs
        VG                    #PV #LV #SN Attr   VSize   VFree 
        centos_lab-lnx-centos   1   2   0 wz--n-  14.41g 40.00m
        vg_logs                 1   1   0 wz--n- 931.32g     0 
      # lvs
        LV      VG                    Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
        root    centos_lab-lnx-centos -wi-ao----  12.88g                                                    
        swap    centos_lab-lnx-centos -wi-ao----   1.49g                                                    
        lv_logs vg_logs               -wi-ao---- 931.32g  
      

      Part of a series on Linux Systems Administration by Scott Alan Miller

      1 Reply Last reply Reply Quote 3
      • scottalanmillerS scottalanmiller referenced this topic on
      • 1 / 1
      • First post
        Last post