レッドキャップ学習ノート[RHCSA]第九課[ファイルファイリング、ハードディスク、パーティションおよび自動マウント、Swap、リンク]
14904 ワード
ファイルのアーカイブ tarとは何ですか 圧縮方式
gzipでドキュメントをフィルタリングし、最も広く使用
通常gzipより圧縮は小さいがgzipほど広くない
比較的新しい、圧縮率が比較的高い tarコマンドパラメータ紹介 tarコマンド操作
ハードドライブ分類 ハードディスク装置の命名規則 ハードディスク構造
パーティションの作成、使用なぜパーティション が必要なのかパーティションのタイプ パーティションを作成するには を作成する. を作成する.
パーティション自動マウントファイルを表示 自動マウントの3つの方式 UUID ラベル
注意:上記の編集が完了したら、
Swap仮想メモリ仮想メモリは、コンピュータメモリ管理の終了であり、一般的ではないデータをハードディスクにキャッシュすることができます. 両方式 仮想メモリを表示 ファイルをSwap として使用は、swap としてパーティションを使用する.
ソフトリンクとハードリンク
tar
コマンドでは、圧縮機能がないことに注意して、大規模なファイルを1つのファイル(アーカイブ)にまとめることができます.gzip
gzipでドキュメントをフィルタリングし、最も広く使用
bzip2
通常gzipより圧縮は小さいがgzipほど広くない
xz
比較的新しい、圧縮率が比較的高い
-A
-c
-v
-f
-t
-x
-a
-j bzip2
-J xz
-z gzip
# tar
[root@master kane]# tar cf 1.tar ./tar_test/
# tar
[root@master kane]# tar -tf 1.tar
./tar_test/
./tar_test/11.q
./tar_test/22.q
./tar_test/44.q
./tar_test/33.q
#
[root@master test]# ls
1.tar
[root@master test]# tar -xvf 1.tar
./tar_test/
./tar_test/11.q
./tar_test/22.q
./tar_test/44.q
./tar_test/33.q
[root@master test]# ls
1.tar tar_test
# gzip
[root@master kane]# tar -zcf 2.tar ./tar_test/
# 1.tar 2.tar 。 2.tar
[root@master test]# ll
total 16
-rw-r--r--. 1 root root 10240 Oct 22 14:57 1.tar
-rw-r--r--. 1 root root 178 Oct 22 15:01 2.tar
drwxr-xr-x. 2 root root 50 Oct 22 14:57 tar_test
ハードドライブ
/dev/sd
/dev/hd ( )
/dev/vd
#
/dev/sda
/dev/sdb
#
/dev/sda1
/dev/sda2
#
( )
#
1. : , 。
2. :
3. : ,
パーティションの作成、使用
1.
2.
3.
4.
1. :
, 。 `4` 。MBR(Master Boot Recorder) , 。 512B, 446B ,`64B` 16B。 4 。 。
2. :
4 。 , 。
3. :
。
4. :
, , 15 。`1~4` `5-15` 。 , 。
1.
2.
3.
4.
アクション1. , 。
2.
[root@localhost Desktop]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 19.5G 0 part
├─rhel-root 253:0 0 17.5G 0 lvm /
└─rhel-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 20G 0 disk
sr0 11:0 1 1024M 0 rom
3. fdisk sda
[root@master Desktop]# fdisk /dev/sda
4. ( ) p
( m ):p
/dev/sda:21.5 GB, 21474836480 ,41943040
Units = of 1 * 512 = 512 bytes
( / ):512 / 512
I/O ( / ):512 / 512
:dos
:0x0000220c
Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 41943039 20458496 8e Linux LVM
5. fdisk sdb
[root@localhost Desktop]# fdisk /dev/sdb
6.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +1000M
Partition 1 of type Linux and of size 1000 MiB is set
Command (m for help): p
Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 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: 0xb43d3ed1
Device Boot Start End Blocks Id System
/dev/sdb1 2048 2050047 1024000 83 Linux
7. : , +{K,M,G}
8. w
9.
[root@localhost Desktop]# partprobe
10.
[root@localhost Desktop]# mkfs.ext4 /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
64000 inodes, 256000 blocks
12800 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=262144000
8 block groups
32768 blocks per group, 32768 fragments per group
8000 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
11.
[root@localhost Desktop]# mount /dev/sdb1 /first
12.
[root@localhost Desktop]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 19.5G 0 part
├─rhel-root 253:0 0 17.5G 0 lvm /
└─rhel-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 1000M 0 part /first
sr0 11:0 1 1024M 0 rom
/etc/fstab
1. sdb
[root@localhost Desktop]# fdisk /dev/sdb
2. , 10 G
Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): e
Partition number (2-4, default 2):
First sector (2050048-41943039, default 2050048):
Using default value 2050048
Last sector, +sectors or +size{K,M,G} (2050048-41943039, default 41943039): +10G
Partition 2 of type Extended and of size 10 GiB is set
Command (m for help): p
Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 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: 0xb43d3ed1
Device Boot Start End Blocks Id System
/dev/sdb1 2048 2050047 1024000 83 Linux
/dev/sdb2 2050048 23021567 10485760 5 Extended
3.
Command (m for help): n
Partition type:
p primary (1 primary, 1 extended, 2 free)
l logical (numbered from 5)
Select (default p): l
Adding logical partition 5
First sector (2052096-23021567, default 2052096):
Using default value 2052096
Last sector, +sectors or +size{K,M,G} (2052096-23021567, default 23021567): +1G
Partition 5 of type Linux and of size 1 GiB is set
Command (m for help): p
Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 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: 0xb43d3ed1
Device Boot Start End Blocks Id System
/dev/sdb1 2048 2050047 1024000 83 Linux
/dev/sdb2 2050048 23021567 10485760 5 Extended
/dev/sdb5 2052096 4149247 1048576 83 Linux
4. - - -
[root@localhost Desktop]# partprobe
[root@localhost Desktop]# mkfs.ext4 /dev/sdb5
[root@localhost Desktop]# mount /dev/sdb5 /second
5.
[root@localhost Desktop]#
[root@localhost Desktop]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 19.5G 0 part
├─rhel-root 253:0 0 17.5G 0 lvm /
└─rhel-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 20G 0 disk
├─sdb1 8:17 0 1000M 0 part /first
├─sdb2 8:18 0 1K 0 part
└─sdb5 8:21 0 1G 0 part /second
sr0 11:0 1 1024M 0 rom
6.
[root@localhost Desktop]# df -H
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rhel-root 19G 3.2G 16G 17% /
devtmpfs 949M 0 949M 0% /dev
tmpfs 958M 144k 958M 1% /dev/shm
tmpfs 958M 9.3M 949M 1% /run
tmpfs 958M 0 958M 0% /sys/fs/cgroup
/dev/sda1 521M 125M 397M 24% /boot
/dev/sdb1 1.1G 2.6M 944M 1% /first
/dev/sdb5 1.1G 2.7M 951M 1% /second
パーティション自動マウント
/etc/fstab
[root@localhost Desktop]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Thu Aug 15 20:39:14 2019
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/rhel-root / xfs defaults 1 1
UUID=a0d45f55-dcf8-4d8e-b32d-4d1eb66a07bc /boot xfs defaults 1 2
/dev/mapper/rhel-swap swap swap defaults 0 0
1. UUID
2. label
3. ( , )
1. UUID
[root@localhost Desktop]# blkid /dev/sdb5
/dev/sdb5: UUID="1eb4fbaa-5744-48e1-809d-90181843eddb" TYPE="ext4"
/* UUID */
2. /etc/fstab
UUID=1eb4fbaa-5744-48e1-809d-90181843eddb /third xfs defaults 0 0
3.
4. ,
[root@localhost Desktop]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rhel-root 18G 3.0G 15G 17% /
devtmpfs 905M 0 905M 0% /dev
tmpfs 914M 84K 914M 1% /dev/shm
tmpfs 914M 8.9M 905M 1% /run
tmpfs 914M 0 914M 0% /sys/fs/cgroup
/dev/sdb5 190M 1.6M 175M 1% /third
/dev/sda1 497M 119M 379M 24% /boot
1. db6
1. ( )
[root@localhost Desktop]# e2label /dev/sdb6
2.
[root@localhost Desktop]# e2label /dev/sdb6 game
[root@localhost Desktop]# e2label /dev/sdb6
game
3. /etc/fstab
LABEL=game /forth ext4 defaults 0 0
4.
[root@localhost Desktop]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rhel-root 18G 3.0G 15G 17% /
devtmpfs 905M 0 905M 0% /dev
tmpfs 914M 152K 914M 1% /dev/shm
tmpfs 914M 8.9M 905M 1% /run
tmpfs 914M 0 914M 0% /sys/fs/cgroup
/dev/sdb6 190M 1.6M 175M 1% /forth
/dev/sdb5 190M 1.6M 175M 1% /third
/dev/sda1 497M 119M 379M 24% /boot
注意:上記の編集が完了したら、
mount -a
が正しいかどうかをテストしてください.そうしないと、仮想マシンが起動できない可能性があります.Swap仮想メモリ
1.
2.
[root@localhost Desktop]# free -h
total used free shared buffers cached
Mem: 1.8G 809M 1.0G 9.6M 912K 268M
-/+ buffers/cache: 539M 1.3G
Swap: 2.0G 0B 2.0G
1. /swap/swapfile, dd
[root@localhost Desktop]# dd if=/dev/zero of=/swap/swapfile bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 7.59467 s, 141 MB/s
2. swap
root@localhost Desktop]# mkswap /swap/swapfile
Setting up swapspace version 1, size = 1048572 KiB
no label, UUID=7df01b33-7874-4ae9-b275-1306427bcf82
3. swap
[root@localhost Desktop]# swapon /swap/swapfile
swapon: /swap/swapfile: insecure permissions 0644, 0600 suggested.
4. 1 G
[root@localhost Desktop]# free -h
total used free shared buffers cached
Mem: 1.8G 1.7G 77M 9.7M 168K 1.0G
-/+ buffers/cache: 711M 1.1G
Swap: 3.0G 0B 3.0G
5.
vi /etc/fstab
/swap/swapfile swap swap defaults 0 0
6. swap
[root@localhost Desktop]# swapoff /swap/swapfile
[root@localhost Desktop]# free -h
total used free shared buffers cached
Mem: 1.8G 1.7G 75M 9.8M 168K 1.0G
-/+ buffers/cache: 711M 1.1G
Swap: 2.0G 0B 2.0G
7.
root@localhost Desktop]# free -h
total used free shared buffers cached
Mem: 1.8G 818M 1.0G 9.8M 916K 266M
-/+ buffers/cache: 551M 1.2G
Swap: 3.0G 0B 3.0G
1. 1G swap
[root@localhost Desktop]# fdisk /dev/sdb
Command (m for help): n
Partition type:
p primary (0 primary, 1 extended, 3 free)
l logical (numbered from 5)
Select (default p): l
Adding logical partition 8
First sector (2926592-20973567, default 2926592):
Using default value 2926592
Last sector, +sectors or +size{K,M,G} (2926592-20973567, default 20973567): +1G
Partition 8 of type Linux and of size 1 GiB is set
Command (m for help): t
Partition number (1,5-8, default 8): 8
Hex code (type L to list all codes): 82
Changed type of partition 'Linux' to 'Linux swap / Solaris'
Command (m for help): p
Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 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: 0xed07c356
Device Boot Start End Blocks Id System
/dev/sdb1 2048 20973567 10485760 5 Extended
/dev/sdb5 4096 413695 204800 83 Linux
/dev/sdb6 415744 825343 204800 83 Linux
/dev/sdb7 827392 2924543 1048576 82 Linux swap / Solaris
/dev/sdb8 2926592 5023743 1048576 82 Linux swap / Solaris
/* t 82( Linux swap / Solaris ) */
2.
3.
[root@localhost Desktop]# mkswap /dev/sdb8
Setting up swapspace version 1, size = 1048572 KiB
no label, UUID=0cf98e08-cfe7-4818-8a39-2c51987c0677
4. 1G
[root@localhost Desktop]# swapon /dev/sdb8
[root@localhost Desktop]# free -h
total used free shared buffers cached
Mem: 1.8G 830M 996M 9.8M 1.7M 273M
-/+ buffers/cache: 555M 1.2G
Swap: 4.0G 0B 4.0G
ソフトリンクとハードリンク
:ほとんど使用されません.ハードリンクはcpと似ていますが、ハードリンクはメモリを消費しません.ハード接続はファイル時間を更新しません.パーティション間で作成できません
:シンボル接続、windowsショートカットのように、iを占用してあなたを接待して、作成する時その他の制限はありませんtouch testfile
#
ln testfile testfile.hard
#
ln -s testfile testfile.hard
# ,
#