-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
95c2c6a
commit a3d0b6a
Showing
9 changed files
with
229 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
vim:ft=help | ||
*centos* | ||
=================================================================== | ||
*yum* | ||
|
||
yum whatprovides */lspci 查看包含 lspci 的软件包 | ||
yum clean all 清除所有缓存 | ||
yum makecache 重新构建缓存 | ||
|
||
2024年6月30日,CentOS 7停止服务后, mirrorlist.centos.org无法访问 | ||
|
||
- http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=container | ||
|
||
解决方法:更换阿里云镜像 https://www.bilibili.com/read/cv36141293/?jump_opus=1 | ||
|
||
>bash | ||
http_proxy=http://localhost:3128 curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo | ||
yum clean all # 清除所有缓存 | ||
yum makecache # 重新构建缓存 | ||
< | ||
|
||
Transaction check error ~ | ||
|
||
`yum update` 报错 | ||
> | ||
Transaction check error: | ||
Unknown error during transaction test in RPM | ||
Error Summary | ||
------------- | ||
< | ||
|
||
解决方法:Unknown error,没有指出明确的依赖错误,试试 `sudo yum update` | ||
|
||
CentOS 7重新分区 ~ | ||
|
||
See also: ~/.vim/doc/linux/filesystem.md | ||
|
||
增加/home分区大小,减小/分区大小 | ||
|
||
要备份 `/home` 分区的数据并重新创建文件系统,然后恢复数据,您可以按照以下步骤操作: | ||
|
||
1. 备份数据 | ||
|
||
使用 `xfsdump` 工具备份 `/home` 分区。确保您有足够的空间来存储备份文件。 | ||
>bash | ||
sudo yum install xfsdump | ||
xfsdump -f /path/to/backup/file /home | ||
< | ||
|
||
这里的 `/path/to/backup/file` 是您存放备份文件的路径,确保该路径有足够的空间。 | ||
|
||
2. 卸载 `/home` 分区: | ||
|
||
在进行任何操作之前,您需要卸载 `/home` 分区。 | ||
>bash | ||
umount /home | ||
< | ||
|
||
3. 缩小`/home` 分区 | ||
|
||
使用 `lvreduce` 命令减小 `/home` 分区的大小。请小心操作,因为这可能会导致数据丢失。 | ||
>bash | ||
lvreduce -L 10G /dev/mapper/centos-home | ||
< | ||
|
||
这里将 `/home` 分区缩小到 10GB。请确保您有足够的空间来容纳缩小后的分区。 | ||
|
||
4. 扩展 `root` 分区 | ||
|
||
使用 `lvextend` 命令扩展 `root` 分区,使用 `/home` 分区释放出来的空间。 | ||
>bash | ||
lvextend -l +100%FREE /dev/mapper/centos-root | ||
< | ||
|
||
5. 重新创建 `/home` 分区的文件系统 | ||
|
||
缩小分区后,您需要重新创建 `/home` 分区的文件系统。 | ||
>bash | ||
mkfs.xfs -f /dev/mapper/centos-home | ||
< | ||
|
||
6. 恢复数据 | ||
|
||
重新挂载 `/home`分区,并使用 `xfsrestore` 工具恢复之前备份的数据。 | ||
>bash | ||
mount /home | ||
xfsrestore -f /path/to/backup/file /home | ||
< | ||
|
||
7. 更新 `/etc/fstab` | ||
如果 `/home` 分区的 UUID 发生了变化,您需要更新 `/etc/fstab` 文件中的相应条目。 | ||
|
||
8. 验证: | ||
最后,您可以使用 `df -h` 命令来验证分区大小是否已经按照您的预期进行了调整。 | ||
|
||
请注意,这些步骤涉及到的数据操作可能会导致数据丢失,因此在执行之前一定要确保已经备份了所有重要数据。另外,这些操作需要 root 权限。如果您不确定如何操作,或者没有信心完成这些步骤,可能需要寻求专业的系统管理员帮助。 | ||
|
||
修改Hostname ~ | ||
|
||
>bash | ||
sudo hostnamectl set-hostname 新的主机名 | ||
< | ||
|
||
添加用户 ~ | ||
|
||
>bash | ||
sudo useradd $username | ||
sudo passwd $username | ||
# 添加到sudo组 | ||
sudo usermod -aG wheel $username | ||
< |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
## XFS对比EXT4 | ||
|
||
http://xiaqunfeng.cc/2017/07/06/XFS-vs-EXT4/ | ||
|
||
## LVM,Logical Volume Manager,逻辑卷管理器 | ||
|
||
在 Linux 系统中,LVM(Logical Volume Manager,逻辑卷管理器)是一种用于管理硬盘驱动器的灵活方式,它允许系统管理员以更灵活和动态的方式来处理存储空间。LVM 通过将物理硬盘组合成卷组(Volume Groups),然后将卷组分割成逻辑卷(Logical Volumes),从而提供了一系列优点。 | ||
|
||
### LVM 的主要组件包括: | ||
|
||
1. **物理卷(Physical Volumes, PVs)**: | ||
- 物理卷是 LVM 分区中的最小单位,可以是整个硬盘或者硬盘上的一个分区。物理卷是实际存储数据的地方。 | ||
|
||
2. **卷组(Volume Groups, VGs)**: | ||
- 卷组是由两个或更多物理卷组成的集合,它们被组合在一起以提供更大的存储池。卷组跨越一个或多个物理硬盘,提供了一个统一的存储空间。 | ||
|
||
3. **逻辑卷(Logical Volumes, LVs)**: | ||
- 逻辑卷是卷组中的一块区域,它被格式化并挂载以供文件系统使用。逻辑卷是用户实际使用的存储空间,可以被视为一个独立的硬盘。逻辑卷可以动态地调整大小,而不影响数据和文件系统。 | ||
|
||
### LVM 的优点: | ||
|
||
1. **灵活性**: | ||
- 可以轻松地调整逻辑卷的大小,而不需要重新分区或复制数据。 | ||
|
||
2. **可扩展性**: | ||
- 可以在线添加更多硬盘到卷组中,以扩展存储空间。 | ||
|
||
3. **性能**: | ||
- 可以通过将数据分散到多个物理硬盘上来提高性能。 | ||
|
||
4. **数据保护**: | ||
- LVM 支持快照功能,可以创建逻辑卷的即时副本,用于备份和恢复。 | ||
|
||
5. **简化管理**: | ||
- 通过集中管理卷组和逻辑卷,简化了存储管理。 | ||
|
||
### LVM 的操作命令: | ||
|
||
- **创建物理卷**: | ||
```bash | ||
pvcreate /dev/sdb1 | ||
``` | ||
|
||
- **创建卷组**: | ||
```bash | ||
vgcreate myvg /dev/sdb1 | ||
``` | ||
|
||
- **创建逻辑卷**: | ||
```bash | ||
lvcreate -L 10G -n mylv myvg | ||
``` | ||
|
||
- **格式化逻辑卷**: | ||
```bash | ||
mkfs.ext4 /dev/myvg/mylv | ||
``` | ||
|
||
- **挂载逻辑卷**: | ||
```bash | ||
mount /dev/myvg/mylv /mnt/mylv | ||
``` | ||
|
||
- **调整逻辑卷大小**: | ||
```bash | ||
lvextend -L +5G /dev/myvg/mylv | ||
``` | ||
|
||
- **缩小逻辑卷**: | ||
```bash | ||
lvreduce -L 5G /dev/myvg/mylv | ||
``` | ||
|
||
LVM 提供了一种高级的存储管理解决方案,适用于需要灵活和可扩展存储的服务器和工作站。 | ||
|
||
## XFS 文件系统和 LVM | ||
|
||
XFS 文件系统在 LVM 管理下是可以动态调整大小的,但是这种调整是单向的,即只能增加不能减少。这意味着,您可以很容易地使用 `lvextend` 和 `xfs_growfs` 命令来增加逻辑卷和文件系统的大小,但是不能缩小它们。 | ||
|
||
要增加 XFS 文件系统的大小,您可以按照以下步骤操作: | ||
|
||
1. 确保有足够的空间在卷组中,您可以使用 `vgs` 命令查看卷组的可用空间。 | ||
2. 使用 `lvextend` 命令来增加逻辑卷的大小,例如:`lvextend -L +sizeG /dev/mapper/vg-lv`。 | ||
3. 然后,使用 `xfs_growfs` 命令来扩展文件系统以使用新分配的空间,例如:`xfs_growfs /dev/mapper/vg-lv`。 | ||
|
||
然而,如果您需要减小 XFS 文件系统的大小,这将涉及到更复杂的过程,因为 XFS 不支持在线缩小。您将需要: | ||
|
||
1. 备份数据。 | ||
2. 卸载文件系统。 | ||
3. 使用 `lvreduce` 命令减小逻辑卷的大小(请注意,这可能会破坏数据)。 | ||
4. 重新格式化逻辑卷,这将删除所有数据:`mkfs.xfs /dev/mapper/vg-lv`。 | ||
5. 恢复数据(如果之前有备份)。 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters