Check system hard disk info

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#check users
[root@localhost ~]# w
[root@localhost ~]# du -h
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 898M 0 898M 0% /dev
tmpfs 910M 12K 910M 1% /dev/shm
tmpfs 910M 9.6M 901M 2% /run
tmpfs 910M 0 910M 0% /sys/fs/cgroup
/dev/mapper/centos-root 8.0G 3.0G 5.1G 38% /
/dev/sda1 1014M 161M 854M 16% /boot
tmpfs 182M 0 182M 0% /run/user/0
[root@localhost ~]# free
total used free shared buff/cache available
Mem: 1863032 727184 400824 31376 735024 952520
Swap: 1048572 0 1048572
[root@localhost ~]# free -m
total used free shared buff/cache available
Mem: 1819 709 391 30 717 930
Swap: 1023 0 1023
[root@localhost ~]# free -g
total used free shared buff/cache available
Mem: 1 0 0 0 0 0
Swap: 0 0 0
[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]# cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 60
model name : Intel(R) Core(TM) i7-4720HQ CPU @ 2.60GHz
stepping : 3
microcode : 0x28
cpu MHz : 2594.009
cache size : 6144 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 2
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm invpcid_single ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid xsaveopt arat md_clear spec_ctrl intel_stibp flush_l1d arch_capabilities
bogomips : 5188.01
clflush size : 64
cache_alignment : 64
address sizes : 45 bits physical, 48 bits virtual
power management:

processor : 1
vendor_id : GenuineIntel
cpu family : 6
model : 60
model name : Intel(R) Core(TM) i7-4720HQ CPU @ 2.60GHz
stepping : 3
microcode : 0x28
cpu MHz : 2594.009
cache size : 6144 KB
physical id : 0
siblings : 2
core id : 1
cpu cores : 2
apicid : 1
initial apicid : 1
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm invpcid_single ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid xsaveopt arat md_clear spec_ctrl intel_stibp flush_l1d arch_capabilities
bogomips : 5188.01
clflush size : 64
cache_alignment : 64
address sizes : 45 bits physical, 48 bits virtual
power management:
[root@localhost ~]# cat /proc/meminfo
MemTotal: 1863032 kB
MemFree: 401056 kB
MemAvailable: 952816 kB
Buffers: 2108 kB
Cached: 691208 kB
SwapCached: 0 kB
Active: 807736 kB
Inactive: 399240 kB
Active(anon): 515132 kB
Inactive(anon): 29904 kB
Active(file): 292604 kB
Inactive(file): 369336 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 1048572 kB
SwapFree: 1048572 kB
Dirty: 8 kB
Writeback: 0 kB
AnonPages: 513784 kB
Mapped: 118772 kB
Shmem: 31376 kB
Slab: 113032 kB
SReclaimable: 41816 kB
SUnreclaim: 71216 kB
KernelStack: 5504 kB
PageTables: 13868 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 1980088 kB
Committed_AS: 2058616 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 183168 kB
VmallocChunk: 34359310332 kB
Percpu: 35328 kB
HardwareCorrupted: 0 kB
AnonHugePages: 346112 kB
CmaTotal: 0 kB
CmaFree: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 98176 kB
DirectMap2M: 1998848 kB
DirectMap1G: 0 kB
[root@localhost ~]# fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000b00b0

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 20971519 9436160 8e Linux LVM

Disk /dev/mapper/centos-root: 8585 MB, 8585740288 bytes, 16769024 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/centos-swap: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk partitions & Physical Devices & File system

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Hard disk (HDD/SDD)
[root@localhost ~]# ls /
bin dev home lib64 mnt proc run srv tmp var
boot etc lib media opt root sbin sys usr
[root@localhost ~]# ls /dev/
agpgart initctl sda2 tty23 tty48 urandom
autofs input sg0 tty24 tty49 usbmon0
block kmsg sg1 tty25 tty5 usbmon1
bsg log shm tty26 tty50 usbmon2
btrfs-control loop-control snapshot tty27 tty51 vcs
bus mapper snd tty28 tty52 vcs1
cdrom mcelog sr0 tty29 tty53 vcs2
centos mem stderr tty3 tty54 vcs3
char midi stdin tty30 tty55 vcs4
console mqueue stdout tty31 tty56 vcs5
core net tty tty32 tty57 vcs6
cpu network_latency tty0 tty33 tty58 vcsa
cpu_dma_latency network_throughput tty1 tty34 tty59 vcsa1
crash null tty10 tty35 tty6 vcsa2
disk nvram tty11 tty36 tty60 vcsa3
dm-0 oldmem tty12 tty37 tty61 vcsa4
dm-1 port tty13 tty38 tty62 vcsa5
dmmidi ppp tty14 tty39 tty63 vcsa6
dri ptmx tty15 tty4 tty7 vfio
fb0 pts tty16 tty40 tty8 vga_arbiter
fd random tty17 tty41 tty9 vhci
full raw tty18 tty42 ttyS0 vhost-net
fuse rfkill tty19 tty43 ttyS1 vmci
hidraw0 rtc tty2 tty44 ttyS2 zero
hpet rtc0 tty20 tty45 ttyS3
hugepages sda tty21 tty46 uhid
hwrng sda1 tty22 tty47 uinput
[root@localhost ~]# ls -l /dev/sd?
brw-rw----. 1 root disk 8, 0 Mar 29 22:18 /dev/sda
[root@localhost ~]# ls -l /dev/sd??
brw-rw----. 1 root disk 8, 1 Mar 29 22:18 /dev/sda1
brw-rw----. 1 root disk 8, 2 Mar 29 22:18 /dev/sda2

# you can search these: primary partition, extension partition, logical partition. Swap partition. Guide partition (/boot), root partition
[root@localhost ~]# free -m
total used free shared buff/cache available
Mem: 1819 712 388 30 718 928
Swap: 1023 0 1023
[root@localhost ~]# ls /boot
config-3.10.0-1160.15.2.el7.x86_64
config-3.10.0-1160.el7.x86_64
efi
grub
grub2
initramfs-0-rescue-83de7518e79f4ea59f6b23046e70c006.img
initramfs-3.10.0-1160.el7.x86_64.img
initramfs-3.10.0-1160.el7.x86_64kdump.img
symvers-3.10.0-1160.15.2.el7.x86_64.gz
symvers-3.10.0-1160.el7.x86_64.gz
System.map-3.10.0-1160.15.2.el7.x86_64
System.map-3.10.0-1160.el7.x86_64
vmlinuz-0-rescue-83de7518e79f4ea59f6b23046e70c006
vmlinuz-3.10.0-1160.15.2.el7.x86_64
vmlinuz-3.10.0-1160.el7.x86_64

Char device, partition device, dd command

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#parted /gparted
[root@localhost ~]# fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000b00b0

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 20971519 9436160 8e Linux LVM

Disk /dev/mapper/centos-root: 8585 MB, 8585740288 bytes, 16769024 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/centos-swap: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
[root@localhost ~]# parted -l
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 10.7GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number Start End Size Type File system Flags
1 1049kB 1075MB 1074MB primary xfs boot
2 1075MB 10.7GB 9663MB primary lvm


Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/centos-swap: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:

Number Start End Size File system Flags
1 0.00B 1074MB 1074MB linux-swap(v1)


Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/centos-root: 8586MB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:

Number Start End Size File system Flags
1 0.00B 8586MB 8586MB xfs


Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0
has been opened read-only.
Model: NECVMWar VMware IDE CDR10 (scsi)
Disk /dev/sr0: 1020MB
Sector size (logical/physical): 2048B/2048B
Partition Table: msdos
Disk Flags:

Number Start End Size Type File system Flags
2 909kB 37.0MB 36.0MB primary
[root@localhost ~]# gparted

# char device, partition device (I/O)
[root@localhost ~]# ls -l /dev/tty?
crw--w----. 1 root tty 4, 0 Mar 29 22:18 /dev/tty0
crw--w----. 1 root tty 4, 1 Mar 29 22:20 /dev/tty1
crw--w----. 1 root tty 4, 2 Mar 29 22:18 /dev/tty2
crw--w----. 1 root tty 4, 3 Mar 29 22:18 /dev/tty3
crw--w----. 1 root tty 4, 4 Mar 29 22:18 /dev/tty4
crw--w----. 1 root tty 4, 5 Mar 29 22:18 /dev/tty5
crw--w----. 1 root tty 4, 6 Mar 29 22:18 /dev/tty6
crw--w----. 1 root tty 4, 7 Mar 29 22:18 /dev/tty7
crw--w----. 1 root tty 4, 8 Mar 29 22:18 /dev/tty8
crw--w----. 1 root tty 4, 9 Mar 29 22:18 /dev/tty9
# /dev/zero is a file that if you read from it, you will only get binary 0's
[root@localhost ~]# ls -l /dev/zero
crw-rw-rw-. 1 root root 1, 5 Mar 29 22:18 /dev/zero

# partition device (512 bytes to 32 kB)
[root@localhost ~]# ls -l /dev/sda?
brw-rw----. 1 root disk 8, 1 Mar 29 23:16 /dev/sda1
brw-rw----. 1 root disk 8, 2 Mar 29 23:16 /dev/sda2

# dd
# backup the device
[root@localhost ~]# dd if=/dev/sda1 of=backup
2097152+0 records in
2097152+0 records out
1073741824 bytes (1.1 GB) copied, 7.21811 s, 149 MB/s
[root@localhost ~]# ls -l backup
-rw-r--r--. 1 root root 1073741824 Mar 29 23:30 backup
[root@localhost ~]# dd if=/dev/zero bs=5M count=10 of=aFile
10+0 records in
10+0 records out
52428800 bytes (52 MB) copied, 0.0528909 s, 991 MB/s
[root@localhost ~]# dd if=/dev/zero bs=5M count=10 seek=20 of=bFile
10+0 records in
10+0 records out
52428800 bytes (52 MB) copied, 0.0339967 s, 1.5 GB/s
[root@localhost ~]# ls -lh aFile
-rw-r--r--. 1 root root 50M Mar 29 23:32 aFile
[root@localhost ~]# du -h aFile
50M aFile
[root@localhost ~]# ls -lh bFile
-rw-r--r--. 1 root root 150M Mar 29 23:33 bFile
[root@localhost ~]# du -h bFile
100M bFile

# what is diff between ls and du
[root@localhost ~]# echo -n 1 > 1B.txt
[root@localhost ~]# ls -l 1B.txt
-rw-r--r--. 1 root root 1 Mar 29 23:40 1B.txt
[root@localhost ~]# du -h 1B.txt
4.0K 1B.txt

Hardware and mount/umount commands

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# mount command -t for designated file system types, -a file systems in /etc/fstab
[root@localhost ~]# mount /dev/sda1 /backup
mount: mount point /backup does not exist
[root@localhost ~]# mkdir /backup
[root@localhost ~]# mount /dev/sda1 /backup
[root@localhost ~]# ls
1B.txt anaconda-ks.cfg bFile wordpress
aFile backup name.txt wordpress-5.4.zip
[root@localhost ~]# ls /backup/
config-3.10.0-1160.15.2.el7.x86_64
config-3.10.0-1160.el7.x86_64
efi
grub
grub2
initramfs-0-rescue-83de7518e79f4ea59f6b23046e70c006.img
initramfs-3.10.0-1160.el7.x86_64.img
initramfs-3.10.0-1160.el7.x86_64kdump.img
symvers-3.10.0-1160.15.2.el7.x86_64.gz
symvers-3.10.0-1160.el7.x86_64.gz
System.map-3.10.0-1160.15.2.el7.x86_64
System.map-3.10.0-1160.el7.x86_64
vmlinuz-0-rescue-83de7518e79f4ea59f6b23046e70c006
vmlinuz-3.10.0-1160.15.2.el7.x86_64
vmlinuz-3.10.0-1160.el7.x86_64
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 898M 0 898M 0% /dev
tmpfs 910M 12K 910M 1% /dev/shm
tmpfs 910M 9.6M 901M 2% /run
tmpfs 910M 0 910M 0% /sys/fs/cgroup
/dev/mapper/centos-root 8.0G 4.2G 3.9G 52% /
/dev/sda1 1014M 161M 854M 16% /boot
tmpfs 182M 0 182M 0% /run/user/0

# /etc/fstab
[root@localhost ~]# vim /etc/fstab
# umount --> just un-mount
[root@localhost ~]# umount /backup/
[root@localhost ~]# ls /backup/

Add hard disk devices and swap partition

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[root@localhost ~]# fdisk /dev/sdb
p --> show partition infot
n p --> add a new primary partition
w
# add a new Linux file system, you can see available system types below
[root@localhost ~]# mkfs.
mkfs.btrfs mkfs.ext2 mkfs.ext4 mkfs.xfs
mkfs.cramfs mkfs.ext3 mkfs.minix
[root@localhost ~]# mkfs.xfs /dev/sdb1
[root@localhost ~]# mkdir /newFS
[root@localhost ~]# mount /dev/sdb1 /newFS/
[root@localhost ~]# df -h
[root@localhost ~]# free -m
[root@localhost ~]# fdisk /dev/sdb
[root@localhost ~]# ls -l /dev/sd??
[root@localhost ~]# partprobe
[root@localhost ~]# mkswap /dev/sdb2
[root@localhost ~]# swapon /dev/sdb2
[root@localhost ~]# free -m
[root@localhost ~]# vim /etc/fstab
# add the following things
/dev/sdb1 /newFS xfs defaults 0 0
/dev/sdb2 swap swap defaults 0 0
[root@localhost ~]# reboot

Set disk volume: quota

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[root@localhost ~]# vim /etc/fstab 
# change the following
UUID=056fdc81-4fc7-4212-9b6b-348c2d2f11c9 /boot xfs defaults,uquota 0 0
[root@localhost ~]# reboot
[root@localhost ~]# mount | grep boot
[root@localhost ~]# useradd thomas
[root@localhost ~]# chmod -Rf o+w /boot
[root@localhost ~]# ls -dl /boot/
[root@localhost ~]# quota

# xfs_quota
[root@localhost ~]# xfs_quota -x -c 'limit bsoft=4m bhard=7m isoft=5 ihard=9 thomas' /boot
[root@localhost ~]# xfs_quota -x -c report /boot
[root@localhost ~]# su - thomas
[root@localhost ~]# dd if=/dev/zero of=/boot/thomas bs=6M count=1
[root@localhost ~]# ls -l /boot/thomas
#edquota: edit quota
[root@localhost ~]# su -
[root@localhost ~]# edquota -u thomas
# set a uplimit and try the following command see if it works
[root@localhost ~]# dd if=/dev/zero of=/boot/thomas bs=8M count=1
[root@localhost ~]# dd if=/dev/zero of=/boot/thomas bs=11M count=1