欢迎光临散文网 会员登陆 & 注册

VMWare安装OpenWrt并扩展磁盘

2023-10-06 22:06 作者:影子8414  | 我要投稿

1 下载OpenWrt镜像

教育网联合镜像:https://mirrors.cernet.edu.cn/list/openwrt

下载地址:https://mirrors.ustc.edu.cn/openwrt/releases/22.03.5/targets/x86/64/openwrt-22.03.5-x86-64-generic-ext4-combined.img.gz

2 转换格式

  • 解压下载的文件,得到openwrt-22.03.5-x86-64-generic-ext4-combined.img

  • 下载qemu-img工具用于格式转换,下载链接:https://github.com/wxmeng04/qemu-img-prebuild。也可以下载msys2自己编译。

  • 从下载的文件中解压出openwrt-22.03.5-x86-64-generic-ext4-combined.img, 然后转换为vmdk格式。

qemu-img convert -f raw openwrt-22.03.5-x86-64-generic-ext4-combined.img -O vmdk openwrt.vmdk

3 创建虚拟机

自定义-->Workstation 17.x-->稍后安装操作系统-->Linux(L)-->配置安装路径-->配置处理器-->配置内存-->使用桥接网络-->LSI Logic(L)-->IDE(I)-->创建新虚拟磁盘-->配置磁盘-->指定磁盘文件-->完成。找到配置安装路径时设置的路径,用步骤2生成的openwrt.vmdk文件替换该文件夹下的vmdk文件。

启动虚拟机。

sed -i 's/downloads.openwrt.org/mirrors.ustc.edu.cn\/openwrt/g' /etc/opkg/distfeeds.conf

4 扩展磁盘

参考链接:

https://openwrt.org/docs/guide-user/installation/openwrt_x86

https://openwrt.org/docs/guide-user/advanced/expand_root

如果df -hT命令查看的磁盘尺寸与实际尺寸不符,可以对磁盘进行扩展。以sda为例操作如下:

opkg update
opkg install losetup resize2fs parted
parted -s /dev/sda resizepart 2 100%
losetup /dev/loop1 /dev/sda2
resize2fs -f /dev/loop1
reboot

其他版本的Linux系统操作也是类似的。关键是losetupresize2fs。也可以使用fdisk代替parted进行分区,但是需要注意记住需要扩展的分区的开始地址不能改变,仅改变结束地址。



VMWare安装OpenWrt并扩展磁盘的评论 (共 条)

分享到微博请遵守国家法律