linux

How do I mount an LVM partition?

A few more steps are needed when mounting an LVM partition vs. a non-LVM partition.

sudo apt-get install lvm2   #This step may or may not be required.
sudo pvscan                 #Use this to verify your LVM partition(s) is/are detected.
sudo vgscan                 #Scans for LVM Volume Group(s)
sudo vgchange -ay           #Activates LVM Volume Group(s)
sudo lvscan                 #Scans for available Logical Volumes
sudo mount /dev/YourVolGroup00/YourLogVol00 /YourMountPoint

Do not sleep when close a laptop lid

vi /etc/systemd/logind.conf

You’ll see lines like these in this file:

#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
#HandlePowerKey=poweroff
#HandleSuspendKey=suspend
#HandleHibernateKey=hibernate
#HandleLidSwitch=suspend
#HandleLidSwitchDocked=ignore
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
#HoldoffTimeoutSec=30s
#IdleAction=ignore
#IdleActionSec=30min
#RuntimeDirectorySize=10%
#RemoveIPC=yes
#UserTasksMax=12288

What you have to do is to remove the # from some of the lines and change it’s value to:

HandleSuspendKey=ignore
HandleLidSwitch=ignore
HandleLidSwitchDocked=ignore

Auto-backup your configuration files with Vim

Not using versioning on your configuration files and editing them with Vim?

Use Vim’s backup option to automatically keep a copy of past versions. To put in your ~/.vimrc:

"Turn on backup option
set backup

"Where to store backups
set backupdir=~/.vim/backup//

"Make backup before overwriting the current buffer
set writebackup

"Overwrite the original backup file
set backupcopy=yes

"Meaningful backup name, ex: filename@2015-04-05.14:59
au BufWritePre * let &bex = '@' . strftime("%F.%H:%M")

From now on, each time you’ll save a file (hit :w), Vim will save a copy in ~/.vim/backup/ with this syntax your-file.py@2016-10-25.14:58.