weinull

0%

系统安装

虚拟机安装

安装准备:

  • PE镜像(老毛桃PE或者其他带桌面的PE镜像,桌面比较方便,命令行也行,这里只说明桌面版本)
  • 软路由img镜像(OpenWRT,默认使用EFI,非EFI也可以,使用iso工具直接放入PE镜像中或者网络下载)
  • img写盘工具(推荐physdiskwrite,使用iso工具直接放入PE镜像中或者网络下载)

安装步骤:

  1. 配置虚拟机为2C4G 2G硬盘(注意硬盘类型需改为SATA或者IDE模式,引导改为EFI,内存配置太低可能PE桌面系统启动不了,如果要使用网络需调整网卡类型,不同PE系统支持的网卡驱动不相同)。
  2. 挂载PE系统iso文件启动虚拟机并进入桌面。
  3. 找到physdiskwrite以及img镜像(或者网络下载到PE系统本地)。
  4. 打开cmd使用physdiskwrite工具把软路由img镜像写入硬盘(写入时会选择硬盘,选择我们添加的2G硬盘即可)。
    1
    physdiskwrite.exe -u xxxx.img
  5. 关机,修改虚拟机配置为1C1G,如果使用的非EFI影响则需要引导修改为BIOS即可(一般都够用,或者2C4G也行)。
  6. 开机使用默认口令root/root登录即可,后续就根据自己需求配置。

普通磁盘模式

参考链接

https://blog.csdn.net/xwmrqqq/article/details/109828166

操作步骤

  1. 关闭虚机,创建快照(以防万一出问题可以还原)。
  2. 直接在虚机平台调整Linux虚机硬盘大小(调整后开机)。
  3. 切换到root用户(sudo操作命令也可以,直接使用root方便一点)。
  4. 输入 fdisk -l 命令查看现有分区以及检查调整的硬盘大小是否已正常显示。 注意:这里会有一个GPT的告警,大概意思就是说分区表的大小不在硬盘的最后(因为我们扩充了硬盘)。
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    GPT PMBR size mismatch (125829119 != 419430399) will be corrected by write.
    Disk /dev/sda: 200 GiB, 214748364800 bytes, 419430400 sectors
    Disk model: Virtual disk
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: gpt
    Disk identifier: B1D5268C-61B9-4C12-B04D-CB42CCD09229

    Device Start End Sectors Size Type
    /dev/sda1 2048 4095 2048 1M BIOS boot
    /dev/sda2 4096 125827071 125822976 60G Linux filesystem
  5. 输入 fdisk /dev/sda 命令开始调整分区(这里根据调整的硬盘进行修改,这里调整的是/dev/sda硬盘的大小)。
    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
    root@k8s-node-01:~# fdisk /dev/sda

    Welcome to fdisk (util-linux 2.34).
    Changes will remain in memory only, until you decide to write them.
    Be careful before using the write command.


    Command (m for help): d # 输入d删除现有的分区
    Partition number (1,2, default 2): # 默认删除最后一个分区,在第5步中我们看到现有的Linux系统分区是/dev/sda2,所以这里删除的是编号为2的分区(注意看Type,不要删错分区,只删需要扩充的分区)

    Partition 2 has been deleted.

    Command (m for help): p # 这里查看一下是不是没有我们删掉的分区了
    Disk /dev/sda: 200 GiB, 214748364800 bytes, 419430400 sectors
    Disk model: Virtual disk
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: gpt
    Disk identifier: B1D5268C-61B9-4C12-B04D-CB42CCD09229

    Device Start End Sectors Size Type
    /dev/sda1 2048 4095 2048 1M BIOS boot

    Command (m for help): n # 创建新分区
    Partition number (2-128, default 2): # 默认编号即可
    First sector (4096-419430366, default 4096): # 默认起始位置
    Last sector, +/-sectors or +/-size{K,M,G,T,P} (4096-419430366, default 419430366): # 默认结束位置

    Created a new partition 2 of type 'Linux filesystem' and of size 200 GiB.
    Partition #2 contains a ext4 signature.

    Do you want to remove the signature? [Y]es/[N]o: n # 这里选择不删除签名

    Command (m for help): p # 查看一下新建的分区大小是不是正常,不正常就继续删除分区重新来

    Disk /dev/sda: 200 GiB, 214748364800 bytes, 419430400 sectors
    Disk model: Virtual disk
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: gpt
    Disk identifier: B1D5268C-61B9-4C12-B04D-CB42CCD09229

    Device Start End Sectors Size Type
    /dev/sda1 2048 4095 2048 1M BIOS boot
    /dev/sda2 4096 419430366 419426271 200G Linux filesystem

    Command (m for help): w # 写入分区
    The partition table has been altered.
    Syncing disks.
  6. 输入 partprobe /dev/sda 命令告知系统分区表的变化(这里是告知整块硬盘的分区表变化,所以不需要加编号)。
  7. 输入 resize2fs /dev/sda2 命令对文件系统进行扩容(这里选择我们新建的分区)。
  8. 输入 df -TH 命令查看扩容的根目录大小是否正常,无问题重启系统即可,有问题则重新进行分区调整操作或还原快照再使用其他教程操作。

LVM磁盘模式

参考链接

https://www.jianshu.com/p/273daea17b2a

操作步骤

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
# 查看当前磁盘信息
df -TH
lsblk

# 创建分区
fdisk /dev/vda

n 新建分区
p 查看新建分区
w 写入分区

# 刷新分区
partprobe /dev/vda

# 创建物理卷
pvcreate /dev/vda5

# 查看卷组名称,以及卷组使用情况
vgdisplay

# 将物理卷扩展到卷组,根据上条命令查看pv名字
vgextend klas /dev/vda5

# 查看当前逻辑卷的空间状态
lvdisplay

# 将卷组中的空闲空间扩展到根分区逻辑卷,根据上条命令查看路径
lvextend -l +100%FREE /dev/klas/root

# 刷新根分区
xfs_growfs /