hcloud-upload-image icon indicating copy to clipboard operation
hcloud-upload-image copied to clipboard

How to upload images in other formats?

Open johanneskastl opened this issue 1 year ago • 2 comments

Hi,

I just found your very nice tool and successfully used it to upload a Flatcar image.

I wanted to try out the openSUSE MicroOS images, but those are only available in formats other than RAW.

https://get.opensuse.org/microos/ => Download => Alternative Downloads

Is there a way to upload e.g. a qcow2 image? Would it be possible to add a feature to support qcow2, maybe by piggy-backing as "compression"?

Or do I need to download the image, convert it manually and then use the local image file? (I guess this does not work, as the image is downloaded into the rescue system from $somewhere, where $somewhere needs to be reachable...)

Kind Regards, Johannes

johanneskastl avatar Sep 29 '24 15:09 johanneskastl

Hello,

you can download the image, convert it and then upload it from your local file with the --image-path= flag.

In general it makes sense to add support for other image types, but for simplicity the tools needed to convert the images should already be installed in the rescue environment, not sure if qemu-img is available there right now.

I would add it as a separate thing to compression though, but in the same way that compression is currently handled.

apricote avatar Sep 30 '24 09:09 apricote

Hello,

you can download the image, convert it and then upload it from your local file with the --image-path= flag.

Ah, thanks, that's nice. Is this documented and I just missed it? Or is this just visible from the help output?

In general it makes sense to add support for other image types, but for simplicity the tools needed to convert the images should already be installed in the rescue environment, not sure if qemu-img is available there right now.

I would add it as a separate thing to compression though, but in the same way that compression is currently handled.

Yes, that sounds good. IMHO it would be a nice feature. I'll keep this issue open, to track its progress?

Kind Regards, Johannes

johanneskastl avatar Sep 30 '24 17:09 johanneskastl

Ah, thanks, that's nice. Is this documented and I just missed it? Or is this just visible from the help output?

That was only included in the --help output. I now added the help output directly to the repository to make it easier to learn about the options: https://github.com/apricote/hcloud-upload-image/blob/main/docs/cli/hcloud-upload-image_upload.md

I'll keep this issue open, to track its progress?

Sounds good. I will update the title :)

apricote avatar Nov 02 '24 21:11 apricote

Any updates?

maxpain avatar Dec 09 '24 12:12 maxpain

No updates, happy to aid if you want to implement it.

apricote avatar Dec 10 '24 17:12 apricote

not sure if qemu-img is available there right now

I checked for that and the rescue system contains qemu-img, so implementing this shouldnt be a problem.

simonostendorf avatar Jan 10 '25 07:01 simonostendorf

any updates?

maxpain avatar Jan 29 '25 15:01 maxpain

Stumbled over this issue after toying around with this tool. Uploading a qcow2 image seems to work, at least the following command finished successfully:

go run github.com/apricote/hcloud-upload-image upload --image-url "https://download.opensuse.org/tumbleweed/appliances/openSUSE-MicroOS.x86_64-ContainerHost-OpenStack-Cloud.qcow2" --architecture x86
# Step 1: Generating SSH Key run-id="c1a9aaf0"
# Step 2: Creating Server run-id="c1a9aaf0"
# Step 3: Activating Rescue System run-id="c1a9aaf0" server=63281047
# Step 4: Booting Server run-id="c1a9aaf0" server=63281047
# Step 5: Opening SSH Connection run-id="c1a9aaf0" server=63281047
# Step 6: Downloading image and writing to disk run-id="c1a9aaf0" server=63281047
# Step 6: Finished writing image to disk run-id="c1a9aaf0" server=63281047
# Step 7: Shutting down server run-id="c1a9aaf0" server=63281047
# Step 8: Creating Image run-id="c1a9aaf0" server=63281047
# Image was created run-id="c1a9aaf0" server=63281047 image=232768124
Cleanup: Deleting temporary server run-id="c1a9aaf0" server=63281047
Cleanup: Deleting temporary ssh key run-id="c1a9aaf0" server=63281047
Successfully uploaded the image! image=232768124

However, the server won't boot from it (I get a "No bootable devices" error on the server console). Unless cqow2 images are aupported, would it make sense to at least implement a check that aborts the upload if a qcow2 image is provided? This might prevent some user frustration.

LenzGr avatar Apr 23 '25 17:04 LenzGr

Turns out, adding support for qcow2 is only a little bit more work than parsing the filename and showing a warning :D

Will be available in 1.0.0 of CLI and Go library.

apricote avatar May 04 '25 00:05 apricote