Add a disk to linux LVM command line

Linux Systems Guides
  • If your starting from scratch, ‘imaging’ or installing linux , insure you’ve partitioned with setup LVM on the first disk for this guide. As this is just the basic setup.

    Once you’ve reached the command line, you can run lsblk to list all block devices, noticing what is a partition and what is a device, where sda would be a device, and sda1 would be a partition:

    lsblk
    

    Output:

    NAME                 MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
    sda                    8:0    0 465.8G  0 disk 
    ├─sda1                 8:1    0   243M  0 part /boot
    ├─sda2                 8:2    0     1K  0 part 
    └─sda5                 8:5    0 465.5G  0 part 
      ├─bak10--vg-root   254:0    0 465.5G  0 lvm  /
      └─bak10--vg-swap_1 254:1    0     4G  0 lvm  [SWAP]
    sdb                    8:16   0 465.8G  0 disk
    

    Once you know the device you want to expand the LVM (Logical Volume Management) in this case ‘sdb’

    Take care to notice, there are many disk identifiers aka ‘sda’ depending on the specific distro you are using

    First you’ll want to install the required tools:

    sudo apt-get install system-config-lvm
    

    Then run:

    sudo vgdisplay
    

    In this case the LVM has already been expanded, either way, take note of the volume group, which you would have been prompted to define during the OS install.

    We can see here as the volume group as ‘VG Name’ bak10-vg

    Output:

    --- Volume group ---
      VG Name               bak10-vg
      System ID             
      Format                lvm2
      Metadata Areas        2
      Metadata Sequence No  5
      VG Access             read/write
      VG Status             resizable
      MAX LV                0
      Cur LV                2
      Open LV               2
      Max PV                0
      Cur PV                2
      Act PV                2
      VG Size               931.28 GiB
      PE Size               4.00 MiB
      Total PE              238407
      Alloc PE / Size       238407 / 931.28 GiB
      Free  PE / Size       0 / 0   
      VG UUID               I3z4RM-RAsq-HfPD-FiUo-KxOZ-Jpsg-zROJPt
    

    We also need the logical volume root path, this can be found by running:

    sudo lvdisplay
    

    We can see the volume group root path is ‘LV Path /dev/bak10-vg/root’ Output:

    --- Logical volume ---
    LV Path                /dev/bak10-vg/root
    LV Name                root
    VG Name                bak10-vg
    LV UUID                ykeSJi-Q1mw-dWui-5D7p-Lr1y-wk18-swWVN8
    LV Write Access        read/write
    LV Creation host, time bak10, 2016-12-24 10:43:48 -0500
    LV Status              available
    # open                 1
    LV Size                927.28 GiB
    Current LE             237383
    Segments               2
    Allocation             inherit
    Read ahead sectors     auto
    - currently set to     256
    Block device           254:0
     
    --- Logical volume ---
    LV Path                /dev/bak10-vg/swap_1
    LV Name                swap_1
    VG Name                bak10-vg
    LV UUID                URTRk2-lcke-7oq6-TAtK-EGg8-qyTf-pAmr9Z
    LV Write Access        read/write
    LV Creation host, time bak10, 2016-12-24 10:43:48 -0500
    LV Status              available
    # open                 2
    LV Size                4.00 GiB
    Current LE             1024
    Segments               1
    Allocation             inherit
    Read ahead sectors     auto
    - currently set to     256
    Block device           254:1
    

    Now we convert the disk ‘sdb’ into a physical volume by running:

    sudo pvcreate /dev/sdb
    

    Then we add the physical volume to the volume group by extending the existing volume group to the second disk:

    sudo vgextend bak10-vg /dev/sdb
    

    Then we allocate the physical volume to the logical volume. You can allocate a specific partition or percentage of the new disk, however this is basic by adding the complete disk:

    sudo lvextend -l +100%FREE /dev/bak10-vg/root
    

    Now we must resize the volume group to the new physical drive:

    sudo resize2fs /dev/bak10-vg/root
    

    The LVM has been expanded to the second disk ‘/dev/sdb’, where the first disk contains a default and basic partitioning scheme :

    lsblk
    
    NAME                 MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
    sda                    8:0    0 465.8G  0 disk 
    ├─sda1                 8:1    0   243M  0 part /boot
    ├─sda2                 8:2    0     1K  0 part 
    └─sda5                 8:5    0 465.5G  0 part 
      ├─bak10--vg-root   254:0    0 927.3G  0 lvm  /
      └─bak10--vg-swap_1 254:1    0     4G  0 lvm  [SWAP]
    sdb                    8:16   0 465.8G  0 disk 
    └─bak10--vg-root     254:0    0 927.3G  0 lvm  /
    

    None the less, we can see the two available physical disks ‘sda and sdb’ are now part of one file system.

    Where sda contains necessary basic partitions, and the second disk is now part of the volume group as usable space.

    Fin! Enjoy your new space!

FreeBSD Notes
  • rickR

    Remove old kernel images that are cluttering the system

    zstd-no-space-error.png

    Most of these errors are due to low or not enough space left in the root partition.

    If you are using a Debian flavor:

    sudo apt-get autoremove --purge

    zstd-error.png

    Inform grub whenever an old kernel is removed:

    update grub

    update-grub.png

    Remove the un-used kernel config files:

    These will be the files pre cursed as ‘rc’ where installed kernels use ‘ii’

    … As well as files no longer used or required due to dependencies

    This command will detect, print, and remove left over cruft from previously installed packages or scripts, that have been removed or updated.

    sudo dpkg --purge $(dpkg -l | awk '/^rc/{print $2}')

    purge.png

    You can re-run the following to view the installed kernel(s):

    dpkg --list | grep linux-image

    installed-kernels.png

    read more

  • rickR

    To list all files in current directory including dot files (hidden files or directories), as well as print permissions :

    ls -la
    read more

  • rickR
    Install Ruby on Debian

    Install rbenv

    sudo apt install rbenv

    Then initialize the environment:

    rbenv init

    rbenv-init.png

    nano ~/.bashrc

    Type or paste the output above, Ctrl +x to save

    Apply:

    source .bashrc

    Install ruby-build

    Install git:

    sudo apt install git

    install-git.png

    mkdir -p "$(rbenv root)"/plugins

    Clone to local:

    git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build

    clone-ruby.png

    curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | bash

    ruby-doctor.png

    Now install Ruby:

    print ruby versions available

    rbenv install --list

    rb-list.png

    Install the latest version unless you have a reason otherwise:

    rbenv install 3.3.0

    On this system there was an error compiling at this point with fiddle, as well as psych: ruby-failed.png

    Therefore manually installing the following filled dependencies

    sudo apt install libtool sudo apt install libffi-dev

    rb-compile.png

    rbenv global 3.3.0

    print installed ruby version

    ruby -v

    ruby-version-installed.png

    read more

  • rickR

    Re: Set script to executable

    755 - Owner has all permissions, and Group and Other can read and execute 700 - Owner has all permissions 644 - Owner can read and write, and Group and Other can read 600 - Owner can read and write 775 - Owner can read and write, and Group and Other can read 770 - Owner and Group have all, and Other can read and execute 750 - Owner has all permissions, and Group can read and execute 664 - Owner and Group can read and write, and Other can just read 660 - Owner and Group can read and write 640 - Owner can read and write, and Group can read
    read more

  • rickR

    Re: Find or Locate a file or extension command line

    Install locate command linux: Use your sudo command!

    apt install mlocate

    OR:

    apt-get install mlocate

    OR:

    yum install mlocate

    Update the database:

    updatedb

    Depending on the size of the complete filesystem this could take a few minutes

    After the database has been populated:

    locate mariadb

    Where mariadb is the word your looking for

    read more