Offline image with GCC

Hello, I am new to snapcraft and been trying it out a bit. But I been unable to solve this myself so I am asking here.

I need an image to boot a device from a USB that won’t have any internet connection and will require a already setup user, already installed gcc/binutils/make and openssh server (will have network connection, just not internet). Any good guide for how to set this up?

Hi ! @fredrik00 .

Follow these steps

I. Installing the package debootstrap

  1. Installing of debootstrap

    sudo apt install debootstrap

II. Creating the base system image (e.g → debian buster )

  1. Creating a directory where the basic installation of the Debian system will be performed

    mkdir debian
    
  2. Accessing in there

    cd debian 
    
  3. Creating the basic installation of the Debian system (buster codename)

    sudo debootstrap --arch=amd64 buster ./debian-base https://deb.debian.org/debian/ 
    

III. Installing necessary packages

  1. Preparing the chroot environment

    sudo mount -o bind /dev/ ./debian-base/dev/
    sudo mount -t proc none ./debian-base/proc/
    sudo mount -t sysfs none ./debian-base/sys/
    sudo mount -t devpts none ./debian-base/dev/pts/
    
  2. Entering an environment in chroot mode

    sudo chroot ./debian-base /bin/bash
    
  3. Installing the desired packages

    apt-get update
    apt-get install -y gcc binutils make openssh-server
    

IV. Configuring user (e.g → a user like hello)

  1. Adding a user

    adduser hello
    

V. Configuring openssh-server

  1. Enable the ssh service

    systemctl enable ssh 
    

VI. Optionally (if you want): configure security settings in /etc/ssh/sshd_config.

VII. Optionally (if you want): customizing the image

VIII. Optionally (if you want): customize other system settings as per your specific requirements.

IX. Creating the bootable USB image

  1. Exiting chroot mode

    exit
    
  2. Unmounting filesystems that were previously mounted in the chroot environment

    sudo umount ./debian-base/dev/pts
    sudo umount ./debian-base/dev
    sudo umount ./debian-base/proc
    sudo umount ./debian-base/sys
    
  3. creating a bootable image from the contents of the debian-base directory

    sudo dd if=./debian-base of=debian_bootable_image.img bs=4M status=progress
    

X. When you arrive at this stage, we will continue the scenario, there are some intermediate stages which require some specificities