gzip解壓縮
1.先將檔名改為.gz
mv initrd-2.6.18-92.el5.img initrd-2.6.18-92.el5.gz
2.gzip -d # -d --decompress
gzip -d initrd-2.6.18-92.el5.gz
file initrd-2.6.18-92.el5
initrd-2.6.18-92.el5: ASCII cpio archive (SVR4 with no CRC)
===========================================================
cpio 解壓縮
cpio -ivcdu < initrd-2.6.18-92.el5
cpio - copy files to and from archives
‘-c’ Identical to “-H newc”, use the new (SVR4) portable format.
If you wish the old portable (ASCII) archive format, use
“-H odc” instead.
‘-d, --make-directories’
Create leading directories where needed.
‘-i, --extract’
Run in copy-in mode. see “Copy-in mode”.
‘-u, --unconditional’
Replace all files, without asking whether to replace existing
newer files with older files.
‘-v, --verbose’冗長的
List the files processed, or with ‘-t’, give an ‘ls -l’ style
table of contents listing. In a verbose table of contents of a
ustar archive, user and group names in the archive that do not
exist on the local system are replaced by the names that corre-
spond locally to the numeric UID and GID stored in the archive.
===========================================================
查看硬碟使用容量
# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/centos-root xfs 6.7G 4.6G 2.1G 69% /
devtmpfs devtmpfs 906M 0 906M 0% /dev
tmpfs tmpfs 921M 88K 920M 1% /dev/shm
tmpfs tmpfs 921M 8.7M 912M 1% /run
tmpfs tmpfs 921M 0 921M 0% /sys/fs/cgroup
/dev/sda1 xfs 497M 157M 341M 32% /boot
tmpfs tmpfs 185M 8.0K 184M 1% /run/user/0
-h, -- human-readable (自動選擇KB,MB,GB顯示)
print sizes in human readable format (e.g., 1K 234M 2G)/
-T, -- print file system Type
列出目錄使用的容量
# du -sh /*
-s, --summarize
display only a total for each argument
0 /bin
131M /boot
816K /dev
39M /etc
5.7M /home
0 /lib
0 /lib64
0 /media
0 /mnt
20M /opt
du: cannot access ‘/proc/4761/task/4761/fd/4’: No such file or directory
du: cannot access ‘/proc/4761/task/4761/fdinfo/4’: No such file or directory
du: cannot access ‘/proc/4761/fd/4’: No such file or directory
du: cannot access ‘/proc/4761/fdinfo/4’: No such file or directory
0 /proc
5.3M /root
8.8M /run
0 /sbin
0 /srv
0 /sys
216K /tmp
3.3G /usr
1.3G /var
====================================================
用hdparm 測試讀取速度
-t Perform device read timings
-T Perform cache read timings
[root@localhost ~]# hdparm -t /dev/sda
/dev/sda:
Timing buffered disk reads: 612 MB in 3.00 seconds = 203.94 MB/sec
[root@localhost ~]# hdparm -t --direct /dev/sda
/dev/sda:
Timing O_DIRECT disk reads: 684 MB in 3.04 seconds = 225.30 MB/sec
[root@localhost ~]# hdparm -T /dev/sda
/dev/sda:
Timing cached reads: 9900 MB in 2.00 seconds = 4954.13 MB/sec
[root@localhost ~]# hdparm -T --direct /dev/sda
/dev/sda:
Timing O_DIRECT cached reads: 102 MB in 2.03 seconds = 50.33 MB/sec
====================================================
查看記憶體指令 — free
free 指令可以看實體記憶體和 Swap 的使用情況
-h human readable output (automatic unit scaling)
-s update every [delay] seconds
[root@localhost ~]# free -hs 5
[root@localhost ~]# watch -n 5 'free -h' (比較清楚)
total used free shared buffers cached
Mem: 996M 366M 629M 3.6M 8.3M 65M
-/+ buffers/cache: 292M 703M
Swap: 815M 0B 815M
====================================================
RAM Disk
[root@localhost ~]# mkdir /tmp/tmpfs
[root@localhost ~]# mount -t tmpfs -o size=50M tmpfs /tmp/tmpfs/
-t, --types vfstype
-o, --options opts
# df -TH
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
ext4 7.0G 4.3G 2.4G 64% /
tmpfs tmpfs 523M 308k 523M 1% /dev/shm
/dev/sda1 ext4 500M 39M 435M 9% /boot
tmpfs tmpfs 53M 0 53M 0% /tmp/tmpfs
寫入測試
# dd count=50 bs=1M if=/dev/zero of=/tmp/tmpfs/test.img
50+0 records in
50+0 records out
52428800 bytes (52 MB) copied, 0.0617388 s, 849 MB/s
# dd count=12500 bs=4k if=/dev/zero of=/tmp/tmpfs/test.img
12500+0 records in
12500+0 records out
51200000 bytes (51 MB) copied, 0.0744877 s, 687 MB/s
dd count=2k bs=1M if=/tmp/ramdisk/test2g.img of=/dev/null
讀取測試
# dd count=50 bs=1M if=/tmp/tmpfs/test.img of=/dev/null
48+1 records in
48+1 records out
51200000 bytes (51 MB) copied, 0.0272163 s, 1.9 GB/s
# dd count=12500 bs=4k if=/tmp/tmpfs/test2g.img of=/dev/null
12500+0 records in
12500+0 records out
51200000 bytes (51 MB) copied, 0.030945 s, 1.7 GB/s
=======================================