container importdisk

drthrax232

Member
Apr 11, 2022
14
0
6
Is there any solution to import .raw to the container?
Like command qm importdisk (vmid) (path) (storage)
 
hi,

unfortunately there's no easy command for that.

one way to do it would be if you have a directory storage (for example the default local storage /var/lib/vz/), you could place the raw image file in the directory of your container, and add the new disk to the container configuration as a mountpoint.

for example:
Code:
root@pve:~# cd /var/lib/vz/images/131/ # replace 131 with your container ID
root@pve:/var/lib/vz/images/131# ls
vm-131-disk-0.raw
root@pve:/var/lib/vz/images/131# cp /path/to/your/file.raw vm-131-disk-1.raw
root@pve:/var/lib/vz/images/131# nano /etc/pve/lxc/131.conf

and add a mountpoint line to your container configuration.

before:
Code:
arch: amd64
cores: 1
hostname: mycontainer
memory: 512
net0: name=eth0,bridge=vmbr0,firewall=1,ip=dhcp,type=veth
ostype: ubuntu
rootfs: local:131/vm-131-disk-0.raw,size=4G
swap: 512
unprivileged: 1

after:
Code:
arch: amd64
cores: 1
hostname: mycontainer
memory: 512
net0: name=eth0,bridge=vmbr0,firewall=1,ip=dhcp,type=veth
ostype: ubuntu
rootfs: local:131/vm-131-disk-0.raw,size=4G
mp0: local:131/vm-131-disk-1.raw,mp=/foo,size=4G # this line is new
swap: 512
unprivileged: 1

and run pct rescan at the end (to update the size parameter automatically)

start and enter your container, and the disk should be mounted in /foo directory

hope this helps
 
Last edited:
  • Like
Reactions: Kyle