Linux: Difference between revisions

From DWIKI
Tony (talk | contribs)
mNo edit summary
Tony (talk | contribs)
Tag: wikieditor
 
(41 intermediate revisions by the same user not shown)
Line 8: Line 8:
*[[Distributions|Distributions]]  
*[[Distributions|Distributions]]  
*https://kb.novaordis.com/index.php/Events_OS_Metrics  
*https://kb.novaordis.com/index.php/Events_OS_Metrics  
 
*Linux on ircnet: #linux2
 
 


Line 20: Line 20:
 
 


== Checking resources ==
*inxi
*[http://www.slashroot.in/linux-system-io-monitoring http://www.slashroot.in/linux-system-io-monitoring]
=== show what is doing most disk accesses ===
iotop
glances
=== IO statistics ===
iostat
vmstat
dstat
ioping
atop
=== CPU usage etc ===
top
atop
htop
vtop
fio
pidstat


== Administration ==
== Administration ==
Line 59: Line 33:
 
 


== FAQ ==


=== check if virtual of physicalmachine ===


dmidecode -s system-manufacturer
virt-who


 
= FAQ =
==Dmesg messages==
===mce: [Hardware Error]: Machine check events logged===
Have a look at rasdaemon and then check
ras-mc-ctl --errors


=== pam_succeed_if(sudo:auth): requirement "uid >= 1000" not met ===
==Storage==
===Umount: /mnt/sda1 is busy===
Try
umount -lf /mnt/sda1


=== Grow (GPT) last partition to max available ===
=== Grow (GPT) last partition to max available ===
Line 80: Line 57:
  gdisk
  gdisk


=== timestamp to human readable ===
Assuming 3 is last partition
growpart /dev/sda 3
 
===I deleted a file but disk is still full===
It was in use by process, you'll need to kill that
lsof -nP | grep '(deleted)'
etc
 
 
===Which disk is 0.0.3.0===
lsblk -dno name,hctl
 
 
===Power-on or device reset occurred===
I had a case where megamaid decided to spin down "unused disks" that were in JBOD. Disable that option ot switch the controller to '''IT mode'''.
It could also be an iscsi disk that appeared, got a case with 'sd 19:0:0:0: Power-on or device reset occurred'
Identify the sd number with
lsscsi
 
==Network==
 
=== check if interface exists ===
 
/sys/class/net/$IF
 
===List disks and their sizes===
lsblk -d
or
fdisk -l | grep "Disk \/dev\/sd"
 
==Hardware info==
===Check number of CPUs===
lscpu | grep Socket
 
===Find bios version===
dmidecode -s bios-version
 
 
=== pam_succeed_if(sudo:auth): requirement "uid >= 1000" not met ===
 
 
 


date -d @1522142497


=== List hardware ===
=== List hardware ===
Line 90: Line 107:
*lsusb  
*lsusb  
*hwinfo  
*hwinfo  
*lspci  
*lspci
*lscpu


  dmidecode -t baseboard
  dmidecode -t baseboard


=== BLKRRPART: Device or resource busy ===
=== BLKRRPART: Device or resource busy ===
Line 113: Line 134:
  partprobe
  partprobe
  kpartx /dev/sdg
  kpartx /dev/sdg
  partx -uv /dev/sdg
  partx -uv /dev/sdg (this one worked on centos 7.3!)
 
This one gave new disk size!
Verified: CentOS 6, Ubuntu 22
  echo 1 > /sys/block/sde/device/rescan
  echo 1 > /sys/block/sde/device/rescan


Line 119: Line 143:


  echo "- - -" > /sys/class/scsi_host/host2/scan
  echo "- - -" > /sys/class/scsi_host/host2/scan
or scan all:
echo "- - -" | tee /sys/class/scsi_host/host*/scan


The winner so far:
The winner so far:
  blockdev --rereadpt /dev/sdg
  blockdev --rereadpt /dev/sdg
but may throw blockdev: ioctl error on BLKRRPART: Device or resource busy


maybe
maybe
Line 137: Line 166:
  #reboot
  #reboot
  echo b > /proc/sysrq-trigger
  echo b > /proc/sysrq-trigger
==Misc==
===Address already in use===
lsof -i :8080
===When was this linux installed?===
Check for /var/log/installer
Pick a device it was installed on
DEV=/dev/sda1
and then
tune2fs -l $DEV| grep -i created
===check if you're in virtual or physical machine===
dmidecode -s system-manufacturer
virt-who
lscpu
virt-what
=== watch which files a process opens ===
watch ls -l /proc/`pidof clamd`/fd
=== timestamp to human readable ===
date -d @1522142497


=== Mignight commander/dialog strange characters ===
=== Mignight commander/dialog strange characters ===
Line 164: Line 220:
 
 


 
 


=== Create swapfile ===
=== Create swapfile ===
Line 169: Line 228:
  fallocate -l 4G /var/swapfile
  fallocate -l 4G /var/swapfile
  mkswap /var/swapfile
  mkswap /var/swapfile
Temporary:
  swapon -v /var/swapfile
  swapon -v /var/swapfile
In fstab: /var/swapfile swap swap sw,prio=-1


swapon failed: Invalid argument
swapon failed: Invalid argument
Line 176: Line 240:


=== partx: error adding partition ===
=== partx: error adding partition ===
try kpartx instead
try kpartx instead




===Find maximum depth of directory===
find /var/www -type d | awk -F"/" 'NF > max {max = NF} END {print max}'
   [[Category:System Administration]] [[Category:Linux]]
   [[Category:System Administration]] [[Category:Linux]]
==Booting==
===Cannot open access to console, the root account is locked===
You probably messed up your grub config, maybe GRUB_CMDLINE_LINUX. Boot rescue CD image :)
===Kernel panic - not syncing: VFS: Unable to mount root fs"===
Maybe the initrd.img* for the kernel is missing.

Latest revision as of 08:54, 13 March 2026

Linux is a free Unix-type operating system originally created by Linus Torvalds with the assistance of developers around the world. Developed under the GNU General Public License , the source code for Linux is freely available to everyone.


 

Rescue CDs

 


Administration

 



FAQ

Dmesg messages

mce: [Hardware Error]: Machine check events logged

Have a look at rasdaemon and then check

ras-mc-ctl --errors

Storage

Umount: /mnt/sda1 is busy

Try

umount -lf /mnt/sda1

Grow (GPT) last partition to max available

Where '3' is partition number

parted /dev/sdf resize 3 100%

No longer allowed?

gdisk

Assuming 3 is last partition

growpart /dev/sda 3

I deleted a file but disk is still full

It was in use by process, you'll need to kill that

lsof -nP | grep '(deleted)'

etc


Which disk is 0.0.3.0

lsblk -dno name,hctl


Power-on or device reset occurred

I had a case where megamaid decided to spin down "unused disks" that were in JBOD. Disable that option ot switch the controller to IT mode. It could also be an iscsi disk that appeared, got a case with 'sd 19:0:0:0: Power-on or device reset occurred' Identify the sd number with

lsscsi

Network

check if interface exists

/sys/class/net/$IF

List disks and their sizes

lsblk -d

or

fdisk -l | grep "Disk \/dev\/sd"

Hardware info

Check number of CPUs

lscpu | grep Socket

Find bios version

dmidecode -s bios-version


pam_succeed_if(sudo:auth): requirement "uid >= 1000" not met

List hardware

  • lshw
  • dmidecode
  • lsusb
  • hwinfo
  • lspci
  • lscpu
dmidecode -t baseboard



BLKRRPART: Device or resource busy

spend all day or reboot

 

calling ioclt to re-read partition table: Device or resource busy

rescan partition table

Keep an eye on

cat /proc/partitions

Partition(s) have been written, but we have been unable to inform the kernel of the change

partprobe
kpartx /dev/sdg
partx -uv /dev/sdg (this one worked on centos 7.3!)

This one gave new disk size! Verified: CentOS 6, Ubuntu 22

echo 1 > /sys/block/sde/device/rescan

Only one that seemed to work on (centos7.x)

echo "- - -" > /sys/class/scsi_host/host2/scan

or scan all:

echo "- - -" | tee /sys/class/scsi_host/host*/scan

The winner so far:

blockdev --rereadpt /dev/sdg

but may throw blockdev: ioctl error on BLKRRPART: Device or resource busy


maybe

hdparm -z /dev/sdg

Force reboot

I found sometimes 'reboot' and 'shutdown' don't work in virtual machines, in that case try:

#sync
echo s > /proc/sysrq-trigger
#optionally umount
echo u > /proc/sysrq-trigger
#reboot
echo b > /proc/sysrq-trigger

Misc

Address already in use

lsof -i :8080

When was this linux installed?

Check for /var/log/installer

Pick a device it was installed on

DEV=/dev/sda1

and then

tune2fs -l $DEV| grep -i created

check if you're in virtual or physical machine

dmidecode -s system-manufacturer
virt-who
lscpu
virt-what

watch which files a process opens

watch ls -l /proc/`pidof clamd`/fd

timestamp to human readable

date -d @1522142497

Mignight commander/dialog strange characters

Quick fix:

export LANG=en_US.ISO-8859-1

This probleem seems to be related to screen/su -

kpartx failing silently

No output/result when trying to create:

kpartx -lv /dev/mapper/foo

this might means the device hasn't been partitioned

No output when trying to delete:

kpartx -d /dev/mapper/foop1

means you should use

kpartx -d /dev/mapper/foo

 

 

 

Create swapfile

fallocate -l 4G /var/swapfile
mkswap /var/swapfile

Temporary:

swapon -v /var/swapfile

In fstab: /var/swapfile swap swap sw,prio=-1

swapon failed: Invalid argument

problably trying to use fallocate on rhel/centos, use dd instead

partx: error adding partition

try kpartx instead


Find maximum depth of directory

find /var/www -type d | awk -F"/" 'NF > max {max = NF} END {print max}' 



Booting

Cannot open access to console, the root account is locked

You probably messed up your grub config, maybe GRUB_CMDLINE_LINUX. Boot rescue CD image :)

Kernel panic - not syncing: VFS: Unable to mount root fs"

Maybe the initrd.img* for the kernel is missing.