proxmox+openwrt(lede)+overlay硬盘扩容(保姆级)

#openwrt(lede)默认磁盘大小就300多M,打日志监控打开,没多久就满了,因此需要做硬盘扩容,但更确切的说,应该是新磁盘挂载!
#proxmox部署openwrt(lede)在网上已经有一大堆的教程,这里就不再说明了,直接进入硬盘扩容操作方法!

1 现象说明

#pve自带的硬盘扩大,相信大家都已经会操作了,这里就不多说了;
#Disk /dev/sda: 40.34 GiB,我在pve上面扩容了40G,但实际上/overlay,还是只有170MB

root@OpenWrt:~# fdisk -l
Disk /dev/loop0: 172.83 MiB, 181207040 bytes, 353920 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


GPT PMBR size mismatch (689214 != 84582399) will be corrected by write.
The backup GPT table is not on the end of the device. This problem will be corrected by write.
Disk /dev/sda: 40.34 GiB, 43306188800 bytes, 84582400 sectors
Disk model: QEMU HARDDISK
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: D2255BC7-A8A7-FBE0-565F-0F2EB9A09D00

Device      Start    End Sectors  Size Type
/dev/sda1     512  33279   32768   16M EFI System
/dev/sda2   33792 689151  655360  320M Microsoft basic data
/dev/sda128    34    511     478  239K BIOS boot

Partition table entries are not in disk order.

root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root               147.3M    147.3M         0 100% /rom
tmpfs                   996.0M      8.7M    987.3M   1% /tmp
/dev/loop0              170.8M     79.7M     91.1M  47% /overlay
overlayfs:/overlay      170.8M     79.7M     91.1M  47% /
/dev/sda1                16.0M      5.4M     10.5M  34% /boot
/dev/sda1                16.0M      5.4M     10.5M  34% /boot
tmpfs                   512.0K         0    512.0K   0% /dev
cgroup                  996.0M         0    996.0M   0% /sys/fs/cgroup
overlayfs:/overlay      170.8M     79.7M     91.1M  47% /opt/docker

2 新建磁盘分区

#进入对应硬盘创建分区

root@OpenWrt:~# fdisk /dev/sda

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

GPT PMBR size mismatch (689214 != 84582399) will be corrected by write.
The backup GPT table is not on the end of the device. This problem will be corrected by write.

Command (m for help): m #查看各命令所代表的意思

Help:

  GPT
   M   enter protective/hybrid MBR

  Generic
   d   delete a partition
   F   list free unpartitioned space
   l   list known partition types
   n   add a new partition
   p   print the partition table
   t   change a partition type
   v   verify the partition table
   i   print information about a partition

  Misc
   m   print this menu
   x   extra functionality (experts only)

  Script
   I   load disk layout from sfdisk script file
   O   dump disk layout to sfdisk script file

  Save & Exit
   w   write table to disk and exit
   q   quit without saving changes

  Create a new label
   g   create a new empty GPT partition table
   G   create a new empty SGI (IRIX) partition table
   o   create a new empty DOS partition table
   s   create a new empty Sun partition table
   
Command (m for help): n #新建分区
Partition number (3-127, default 3): #回车,默认
First sector (33280-84582366, default 690176):#回车,默认
Last sector, +/-sectors or +/-size{K,M,G,T,P} (690176-84582366, default 84582366):#回车,默认

Created a new partition 3 of type 'Linux filesystem' and of size 40 GiB.
Command (m for help): w #保存退出
The partition table has been altered.
Syncing disks.

#校验分区是否创建成功

root@OpenWrt:~# fdisk -l
Disk /dev/loop0: 172.83 MiB, 181207040 bytes, 353920 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 /dev/sda: 40.34 GiB, 43306188800 bytes, 84582400 sectors
Disk model: QEMU HARDDISK
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: D2255BC7-A8A7-FBE0-565F-0F2EB9A09D00

Device       Start      End  Sectors  Size Type
/dev/sda1      512    33279    32768   16M EFI System
/dev/sda2    33792   689151   655360  320M Microsoft basic data
/dev/sda3   690176 84582366 83892191   40G Linux filesystem  #为新建分区
/dev/sda128     34      511      478  239K BIOS boot

Partition table entries are not in disk order.

#格式化新建分区,将新创建的分区格式化为ext4格式

root@OpenWrt:~# mkfs.ext4 /dev/sda3
mke2fs 1.45.6 (20-Mar-2020)
Discarding device blocks: done
Creating filesystem with 10486523 4k blocks and 2624496 inodes
Filesystem UUID: 29bce85b-1de1-4b63-880e-45c318c50086
Superblock backups stored on blocks:
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
	4096000, 7962624

Allocating group tables: done
Writing inode tables: done
Creating journal (65536 blocks): done
Writing superblocks and filesystem accounting information: done

3 替换/overlay分区

#临时挂载新建分区

root@OpenWrt:~# mount -t ext4 /dev/sda3 /mnt/sda3
root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root               147.3M    147.3M         0 100% /rom
tmpfs                   996.0M      8.9M    987.1M   1% /tmp
/dev/loop0              170.8M     79.7M     91.1M  47% /overlay
overlayfs:/overlay      170.8M     79.7M     91.1M  47% /
/dev/sda1                16.0M      5.4M     10.5M  34% /boot
/dev/sda1                16.0M      5.4M     10.5M  34% /boot
tmpfs                   512.0K         0    512.0K   0% /dev
cgroup                  996.0M         0    996.0M   0% /sys/fs/cgroup
overlayfs:/overlay      170.8M     79.7M     91.1M  47% /opt/docker
/dev/sda3                39.1G     48.0M     37.1G   0% /mnt/sda3

#复制overlay数据进/dev/sda3

root@OpenWrt:~# cp -r /overlay/* /mnt/sda3
root@OpenWrt:~#

#设置开机自动挂载/dev/sda3,不会的参考以下截图
#vi /etc/rc.local

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

echo 1 > /sys/fs/cgroup/memory/memory.use_hierarchy
#添加以下这句挂载命令
mount /dev/sda3 /overlay 
exit 0

#使用TTYD终端进行编辑文件
在这里插入图片描述

#设置完成后,重启openwrt验证

root@OpenWrt:~# reboot

4 校验是否替换成功

#查看磁盘分区已生效

root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root               147.3M    147.3M         0 100% /rom
tmpfs                   996.0M      7.9M    988.1M   1% /tmp
/dev/loop0               39.1G     54.4M     37.1G   0% /overlay #已变化
overlayfs:/overlay      170.8M     79.7M     91.1M  47% /
/dev/sda1                16.0M      5.4M     10.5M  34% /boot
/dev/sda1                16.0M      5.4M     10.5M  34% /boot
tmpfs                   512.0K         0    512.0K   0% /dev
cgroup                  996.0M         0    996.0M   0% /sys/fs/cgroup
/dev/sda3                39.1G     54.4M     37.1G   0% /mnt/sda3
/dev/sda3                39.1G     54.4M     37.1G   0% /overlay
overlayfs:/overlay      170.8M     79.7M     91.1M  47% /opt/docker

#查看openwrt
在这里插入图片描述
在这里插入图片描述

至此表演结束,可以放心的安装软件包,随便造!

  • 4
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
img2kvm是一个在PVE下将OW固件添加到VM的工具,可以方便地将固件文件(包括gz方式的压缩格式)快速添加到OW虚拟机中,从而简化让人工操作的麻烦。 若是你的PVE主机能访问Internet,可以直接下载到目录“/usr/bin”或“/usr/local/bin”下,下面是将img2kvm下载到目录“/usr/local/bin”以及增加其可执行权限的命令: wget -P /usr/local/bin http://dl.everun.top/softwares/utilities/img2kvm/img2kvm chmod +x /usr/local/bin/img2kvm 若是PVE主机不能直接访问Internet,可以先下载到电脑中,然后上传到指定的目录“/usr/bin”或“/usr/local/bin”下,然后再通过chmod命令增加可执行权限。 这样完成后,就可以直接使用img2kvm命令了。 img2kvm详细的帮助信息可以通过命令“img2kvm -h”直接获取,旧版本img2kvm帮助信息的主要内容如下: A utility that convert OpenWrt firmware to disk image for KVM guest in Proxmox VE. Copyright (C) 2017-2018 everun.top usage: img2kvm [storage] -h or --help display this help. -V or --version output img2kvm version informaton. Command parameters: img_name the name of OpenWrt image file, e.g. 'openwrt-x86-kvm64-combined-ext4.img'. vm_id the ID of VM for OpenWrt guest, e.g. '200'. vmdisk_name the name of disk for OpenWrt guest, e.g. 'vm-200-disk-1'. storage Storage pool of Proxmox VE, default is 'local-lvm'. 其中,-h可以获得所有的帮助信息,-V可以获得版本信息。 所用的命令格式为: img2kvm [storage] 其具体参数说明如下: img_name:是OW固件的文件名称。一般为“xxx.img”或“xxx.img.gz”的格式。img2kvm可以直接识别并转换“img.gz”压缩格式的固件文件,对于“xxx.img.gz”来说,只需要输入“xxx.img”作为名称即可,不需要再另外加“.gz”。 vm_id:是创建好的OW虚拟机的ID。一般为一组非零开头的数字,如200。 vmdisk_name:是OW虚拟机要使用的磁盘名称。建议采用vm--disk-的命名方式,如vm-200-disk-1。 storage:是指导入使用的存储池的ID,默认为“local-lvm”,这是安装PVE时自动创建的。此项为可选项,若不指定则使用默认值。 v0.1.8版之后的img2kvm对所需的选项参数进行了简化,取消了参数“”,简化后的命令格式如下: img2kvm [storage] 即img2kvm命令后面仅需要加加两个参数:固件的文件名称和需要添加磁盘的虚拟机ID。 其中,固件的文件可以是img的映像格式,也可以是.gz的压缩格式。 例如,将文件名为“openwrt-x86-kvm64-combined-squashfs.img.gz”的固件导入到ID为“123”的VM中的命令为: img2kvm openwrt-x86-kvm64-combined-squashfs.img.gz 123 这里使用了默认的存储池local,故可以省略。 * 增补信息: 当前img2kvm最新的版本为v0.1.10。 最后更新于2019年3月20日。 特注:本下载已获得原作者授权。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值