VMWare安裝OpenWrt并擴展磁盤
教育網(wǎng)聯(lián)合鏡像: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 轉(zhuǎn)換格式
解壓下載的文件,得到
openwrt-22.03.5-x86-64-generic-ext4-combined.img
。下載
qemu-img
工具用于格式轉(zhuǎn)換,下載鏈接:https://github.com/wxmeng04/qemu-img-prebuild。也可以下載msys2
自己編譯。從下載的文件中解壓出
openwrt-22.03.5-x86-64-generic-ext4-combined.img
, 然后轉(zhuǎn)換為vmdk格式。
qemu-img convert -f raw openwrt-22.03.5-x86-64-generic-ext4-combined.img -O vmdk openwrt.vmdk
3 創(chuàng)建虛擬機
自定義
-->Workstation 17.x
-->稍后安裝操作系統(tǒng)
-->Linux(L)
-->配置安裝路徑-->配置處理器-->配置內(nèi)存-->使用橋接網(wǎng)絡(luò)
-->LSI Logic(L)
-->IDE(I)
-->創(chuàng)建新虛擬磁盤
-->配置磁盤-->指定磁盤文件-->完成。找到配置安裝路徑
時設(shè)置的路徑,用步驟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系統(tǒng)操作也是類似的。關(guān)鍵是losetup
和resize2fs
。也可以使用fdisk
代替parted
進行分區(qū),但是需要注意記住需要擴展的分區(qū)的開始地址不能改變,僅改變結(jié)束地址。