Category: Linux
-
install sysstat on centos
To install sysstat/sar on CentOS, run
yum install sysstat
Enable and start sysstat
systemctl enable sysstat systemctl start sysstat systemctl status sysstat
Allow several minutes to collect data, then you will be able to see stats with sar ommand.
See sar
-
hdd
blkid
Checking NVMe Disk
No space left on device
smartctl
sfdisk
Setup ZFS file system in Ubuntu
Resize Amazon EC2 Boot Disk
Partitioning hard disk for backup
Resize a linux file system with resize2fs
blkid – show UUID for disks.
Delayed block allocation failed for inode
Resize EC2 file system with LVMFile Systems
Linux Software Raid
- Manage Linux Software Raid with mdadm
- unknown filesystem type linux_raid_member
- Creating Software RAID 0
- Creating Software RAID 5
Disk Errors
-
No space left on device
On a server, when creating new files, i get error – “No space left on device”.
root@sok:~# touch 2 touch: cannot touch `2': No space left on device root@sok:~#
Check disk space with df -h, it shows 129 GB disk space is free
root@sok:~# df -h Filesystem Size Used Avail Use% Mounted on rootfs 383G 243G 129G 66% / udev 10M 0 10M 0% /dev tmpfs 1.6G 224K 1.6G 1% /run tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 3.5G 0 3.5G 0% /run/shm tmpfs 3.5G 4.0K 3.5G 1% /tmp root@sok:~#
This can be due to inodes getting full, check inodes usage with “df -i”.
root@sok:~# df -i Filesystem Inodes IUsed IFree IUse% Mounted on rootfs 25419184 25419184 0 100% / udev 2057538 319 2057219 1% /dev tmpfs 2059026 258 2058768 1% /run tmpfs 2059026 3 2059023 1% /run/lock tmpfs 2059026 2 2059024 1% /run/shm tmpfs 2059026 7 2059019 1% /tmp root@sok:~#
As you can use Inodes are all used up.
To find where inodes are used up, run
find / -xdev -printf '%h\n' | sort | uniq -c | sort -k 1 -n
If you have recent version of du, you can use
du --inodes -xS | sort -n
This will display all folders with inode usage, sorted by inode usage.
-
Disable IPv6
To disable IPv6, edit
vi /etc/sysctl.conf
Add following
net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1
run
sysctl -p
IPv6 config for RHEL
BOOTPROTO=dhcp DEFROUTE=yes DEVICE=eth0 DHCLIENT_SET_DEFAULT_ROUTE=yes HWADDR=fa:16:3e:83:96:4e IPV6ADDR=2607:5300:405:300::16dc/56 IPV6INIT=yes IPV6_AUTOCONF=no IPV6_DEFAULTGW=2607:5300:405:300::1 IPV6_FORCE_ACCEPT_RA=no MTU=1500 ONBOOT=yes TYPE=Ethernet USERCTL=no
Related Posts
-
vim E509: Cannot create backup file (add ! to override)
When i save file on a server in vim, i get error
“FILE_NAME.EXTN” E509: Cannot create backup file (add ! to override)
Press ENTER or type command to continueI verified vim backupdir with command
:verbose set backupdir
That showed “backupdir=.,~/tmp,~/”, i compared it with vim installed on my PC, it looked same.
I tried to create a file on the server using touch, it failed.
root@v22013111876215233:/home/firsthost/public_html/themes/blue/styles# touch 2 touch: cannot touch `2': No space left on device root@v22013111876215233:/home/firsthost/public_html/themes/blue/styles#
The error was due to disk full on the server and vim was not able to create a backup file.
See vim
-
Vim 8 goes Visual Mode on right click
Vim 8 shipped with Fedora 25 and Debian 9 when you mouse right click or use middle button to insert text to vim editor, it just go VISUAL mode.
This is because default changes in Vim 8.
Solution 1
The solution is to press SHIFT key before using mouse.
SHIFT + right mouse button = you will get paste option for copied text.
SHIFT + middle mouse button (press mouse wheel) = selected text will be pasted to vim.
SHIFT + INSERT = paste.
Solution 2
use vim.tiny, this can be activated by running
update-alternatives --config vi
Example
root@debug-instance:~# update-alternatives --config vi There are 3 choices for the alternative vi (providing /usr/bin/vi). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/nvim 30 auto mode 1 /usr/bin/nvim 30 manual mode 2 /usr/bin/vim.basic 30 manual mode 3 /usr/bin/vim.tiny 15 manual mode Press
to keep the current choice[*], or type selection number: 3 update-alternatives: using /usr/bin/vim.tiny to provide /usr/bin/vi (vi) in manual mode root@debug-instance:~# Solution 3
Run command
:set mouse-=a
to make this permanent, edit ~/.vimrc file, add
set mouse-=a
See vi
-
apt error after MariaDB to MySQL change
I have install MariaDB on a Ubuntu 16.04 server. Then installed Virtualmin, that require MySQL, so it removed MariaDB and installed MySQL, this caused apt stop working.
When i run “apt update”, it failed with
root@ok-vm:~# apt upgrade Reading package lists... Done Building dependency tree Reading state information... Done You might want to run 'apt-get -f install' to correct these. The following packages have unmet dependencies: mysql-server : Depends: mysql-server-5.7 but it is not installed E: Unmet dependencies. Try using -f. root@ok-vm:~#
Next i run ‘apt-get -f install’ as it said in above error message.
root@ok-vm:~# apt-get -f install Reading package lists... Done Building dependency tree Reading state information... Done Correcting dependencies... Done The following additional packages will be installed: mysql-server-5.7 Suggested packages: mailx tinyca The following NEW packages will be installed: mysql-server-5.7 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. 167 not fully installed or removed. Need to get 0 B/2,708 kB of archives. After this operation, 48.3 MB of additional disk space will be used. Do you want to continue? [Y/n] Y Preconfiguring packages ... (Reading database ... 120876 files and directories currently installed.) Preparing to unpack .../mysql-server-5.7_5.7.20-0ubuntu0.16.04.1_amd64.deb ... Aborting downgrade from (at least) 10.0 to 5.7. If are sure you want to downgrade to 5.7, remove the file /var/lib/mysql/debian-*.flag and try installing again. dpkg: error processing archive /var/cache/apt/archives/mysql-server-5.7_5.7.20-0ubuntu0.16.04.1_amd64.deb (--unpack): subprocess new pre-installation script returned error exit status 1 Errors were encountered while processing: /var/cache/apt/archives/mysql-server-5.7_5.7.20-0ubuntu0.16.04.1_amd64.deb E: Sub-process /usr/bin/dpkg returned an error code (1) root@ok-vm:~#
That too failed. The error message is
Preparing to unpack …/mysql-server-5.7_5.7.20-0ubuntu0.16.04.1_amd64.deb …
Aborting downgrade from (at least) 10.0 to 5.7.This is because MySQL detected MairaDB data files in /var/lib/mysql folder, it can’t use same data files as MariaDB is newer version.
To fix the problem, i renamed the folder
mv /var/lib/mysql /var/lib/mysql-old
Now running “apt-get -f install” fixed the problem with apt.
apt-get -f install
-
apt show
apt show command shows information about a package.
root@ok-vm:~# apt show apache2 Package: apache2 Version: 2.4.18-2ubuntu3.5 Priority: optional Section: web Origin: Ubuntu Maintainer: Ubuntu Developers
Original-Maintainer: Debian Apache Maintainers Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 501 kB Provides: httpd, httpd-cgi Pre-Depends: dpkg (>= 1.17.14) Depends: lsb-base, procps, perl, mime-support, apache2-bin (= 2.4.18-2ubuntu3.5), apache2-utils (>= 2.4), apache2-data (= 2.4.18-2ubuntu3.5) Recommends: ssl-cert Suggests: www-browser, apache2-doc, apache2-suexec-pristine | apache2-suexec-custom, ufw Conflicts: apache2.2-bin, apache2.2-common Replaces: apache2.2-bin, apache2.2-common Homepage: http://httpd.apache.org/ Task: lamp-server, mythbuntu-frontend, mythbuntu-desktop, mythbuntu-backend-slave, mythbuntu-backend-master, mythbuntu-backend-master Supported: 5y Download-Size: 86.7 kB APT-Manual-Installed: yes APT-Sources: http://azure.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages Description: Apache HTTP Server The Apache HTTP Server Project's goal is to build a secure, efficient and extensible HTTP server as standards-compliant open source software. The result has long been the number one web server on the Internet. . Installing this package results in a full installation, including the configuration files, init scripts and support scripts. N: There is 1 additional record. Please use the '-a' switch to see it root@ok-vm:~# See apt policy apt
-
apt policy
apt policy command show information about a package.
root@ok-vm:~# apt policy apache2 apache2: Installed: 2.4.18-2ubuntu3.5 Candidate: 2.4.18-2ubuntu3.5 Version table: *** 2.4.18-2ubuntu3.5 500 500 http://azure.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages 500 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages 100 /var/lib/dpkg/status 2.4.18-2ubuntu3 500 500 http://azure.archive.ubuntu.com/ubuntu xenial/main amd64 Packages root@ok-vm:~#
It shows the installed version “Installed: 2.4.18-2ubuntu3.5” and the repo from where it is installed.
See apt