Scaleway provides you a wide selection of operation system images and InstantApps, however sometimes you want to customize an image more or have needs for some specific configurations. In this case you can create your own image from scratch.
- You have an account and are logged into console.scaleway.com
- You have configured your SSH Key
- You have installed and configured the Scaleway Command Line Interface (CLI)
Important: Images for
X86_64instances, must be bootable using UEFI. This means that the partition table must be of the GPT format and that the first partition is of EFI System partition type containing the EFI boot files.
1 . Start a DEV1-S instance and install the required package so it can act as an web server for the cloud image. You can either start it from the console or using the Scaleway CLI:
scw instance server create name=image-server image=ubuntu_focal
2 . Once the instance is available, update the
apt package repositories, install the following packages, and download the cloud image. In this tutorial we download the Ubuntu Focal Fossa Cloud Image:
apt update apt -y install nginx p7zip libguestfs-tools wget https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64-disk-kvm.img
3 . Use
guestfishto adapt the image to your needs. The
--network option is only required if you intend to install packages from the internet :
Important: It is important to add the Scaleway specific ecosystem which is availble as
guestfish -a focal-server-cloudimg-amd64-disk-kvm.img --network Welcome to guestfish, the guest filesystem shell for editing virtual machine filesystems and disk images. Type: ‘help’ for help on commands ‘man’ to read the manual ‘quit’ to quit the shell <fs> run 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00 <fs> mount /dev/sda1 / <fs> sh "add-apt-repository ppa:scaleway/stable" <fs> sh "apt -y install scaleway-ecosystem" <fs> quit
You can use the sh command of guestfish or any other command to customize your image.
4 . Copy the QCOW2 file to the webserver directory
cp focal-server-cloudimg-amd64-disk-kvm.img /var/www/html
1 . Start a new instance from the Cloud Image served by the builder instance. The following arguments are important:
root-volume=l:10G additional-volumes.0=l:10G- This will make sure that the resulting image size is 10G
tags.0=build_method=from-qcow2- This will tell the bootscript to install from a provided QCOW2
tags.1=disk_img_url=http://<IP_adress_of_the_builder_instance>/focal-server-cloudimg-amd64-disk-kvm.imgThis specifies the URL of the Cloud Image to use
bootscript-id=c9ae8463-370d-4c83-8f71-b8282e7f6f81- This specifies the image build bootscript (Note: The Bootscript ID is zone specific)
You should have a command like the following exemaple, run it using the Scaleway CLI:
scw instance server create type=DEV1-S zone=fr-par-1 image=ubuntu_focal name=image-builder \ root-volume=l:10G additional-volumes.0=l:10G \ tags.0=build_method=from-qcow2 \ tags.1=disk_img_url=http://22.214.171.124/focal-server-cloudimg-amd64-disk-kvm.img \ bootscript-id=c9ae8463-370d-4c83-8f71-b8282e7f6f81
Note: The bootscript IDs for each zone are:
2 . Connect yourself to the console of the building instance and watch for
>>> Listening on port 22 to signal build done., which indicates that the building of the volume has completed.
scw instance server console <image_builder_instance_id> ... Disk /dev/vda: 19531250 sectors, 9.3 GiB Logical sector size: 512 bytes Disk identifier (GUID): 00000000-0000-4000-A000-000000000001 Partition table holds up to 128 entries First usable sector is 34, last usable sector is 19531216 Partitions will be aligned on 2048-sector boundaries Total free space is 2014 sectors (1007.0 KiB) Number Start (sector) End (sector) Size Code Name 1 2048 4095 1024.0 KiB EF02 BIOS-BOOT 2 4096 264191 127.0 MiB EF00 EFI-SYSTEM 3 264192 1050623 384.0 MiB 8300 boot 4 1050624 19531216 8.8 GiB 8300 >>> Listening on port 22 to signal build done.
1 . Log yourself into the Scaleway Console and go to the Attached Volumes tab of your image builder instancer.
2 . Click the … button at the Volume0 to expand the menu.
3 . Click on Snapshot:
4 . Enter a meaningful name for the snapshot and click Take Snapshot.
5 . The snapshot displays in the list of your snapshots. Once it is ready (marked with a green dot), click … to expand the menu and click on Image from Snapshot:
6 . Enter a name for your image and select the
x86_64 architecture. Confirm by clicking Create image from snapshot:
Your new image is ready now and you can start deploying your instances using this image.