Add a disk to linux LVM command line



  • 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!





Tmux Commands

screen and tmux

A comparison of the features (or more-so just a table of notes for accessing some of those features) for GNU screen and BSD-licensed tmux.

The formatting here is simple enough to understand (I would hope). ^ means ctrl+, so ^x is ctrl+x. M- means meta (generally left-alt or escape)+, so M-x is left-alt+x

It should be noted that this is no where near a full feature-set of either group. This - being a cheat-sheet - is just to point out the most very basic features to get you on the road.

Trust the developers and manpage writers more than me. This document is originally from 2009 when tmux was still new - since then both of these programs have had many updates and features added (not all of which have been dutifully noted here).

Action tmux screen
start a new session tmux OR
tmux new OR
tmux new-session
screen
re-attach a detached session tmux attach OR
tmux attach-session
screen-r
re-attach an attached session (detaching it from elsewhere) tmux attach -d OR
tmux attach-session -d
screen -dr
re-attach an attached session (keeping it attached elsewhere) tmux attach OR
tmux attach-session
screen -x
detach from currently attached session ^b d OR
^b :detach
^a ^d OR
^a :detach
rename-window to newname ^b , <newname> OR
^b :rename-window <newn>
^a A <newname>
list windows ^b w ^a w
list windows in chooseable menu ^a "
go to window # ^b # ^a #
go to last-active window ^b l ^a ^a
go to next window ^b n ^a n
go to previous window ^b p ^a p
see keybindings ^b ? ^a ?
list sessions ^b s OR
tmux ls OR
tmux list-sessions
screen -ls
toggle visual bell ^a ^g
create another window ^b c ^a c
exit current shell/window ^d ^d
split window/pane horizontally ^b " ^a S
split window/pane vertically ^b % ^a |
switch to other pane ^b o ^a <tab>
kill the current pane ^b x OR (logout/^D)
collapse the current pane/split (but leave processes running) ^a X
cycle location of panes ^b ^o
swap current pane with previous ^b {
swap current pane with next ^b }
show time ^b t
show numeric values of panes ^b q
toggle zoom-state of current pane (maximize/return current pane) ^b z
break the current pane out of its window (to form new window) ^b !
re-arrange current panels within same window (different layouts) ^b [space]
Kill the current window (and all panes within) ^b killw [target-window]
  • Mount NFS from Truenas

    mkdir -p /media/rick/pool1 chown -R rick:rick /media/rick/pool1

    Add the automount to: /etc/fstab

    truenas.thecave:/mnt/pool1 /media/rick/pool1 nfs user,auto 0 0

    Retstart Nautilus to see the share in files:

    killall nautilus

    For other shares, just repeat the same process under directory ‘media’ with the name of the share substituted

    read more
  • Again running smartctl after all is said and done:

    smartctl --all /dev/sda

    ddrescue-smartctl-after-rescue.png ddrescue-smartctl-2.png

    Yet an old drive in itself, I run the wheels off of them, and monitor regularly as anyone should.

    read more
});