I have a USB flash drive, which boots Alpine Linux into RAM memory.

I wish to run a script directly after startup (login to WIFI, etc.). Is that possible?

It is advised to place a startup script in /etc/local.d/UpdateIssue.start, but my USB flash drive does not contain the folder /etc. Simply having the script after boot in the filesystem would be enough, then I manually execute the file. However, all I see is this:

enter image description here

1 Answer 1


I think that to answer to this question, there are several points that needs to be clarified.

1. Why there's no /etc dir in my USB?

Because the USB content you see is what is needed to allow Alpine to boot. If you download an ISO file [1], you are not going to find any /etc dir as well. The /etc dir will appear when the USB starts, when the filesystem is uncompressed and loaded in memory.

2. Yes, but I need the /etc dir to run my cool script, where can I find it?

The filesystem resides, compressed, into boot/initramfs-lts[2].

You can open it and take a look inside[3], but that's not the way you can accomplish your goal.

3. Ok, gotcha. But now, can you answer my question?

Proceed as follow:

  • Boot your PC with that USB (I assume you have a bootable USB with Alpine Linux Image, if not, look at [4] )
  • Run setup-alpine and follow the installation guide. Alpine has three different disk modes[5], here we assume you would choose diskless
  • Now, it's time to create your /etc/local.d/UpdateIssue.start. Don't forget to make it executable with chmod +x /etc/local.d/UpdateIssue.start, and to add local service to start on boot: rc-update add local
  • Save what you have done with lbu commit

This last step is MANDATORY if you are going to use diskless mode. In this way, Alpine will create a file named $hostname.apkovl.tar.gz in your USB key [6].

At the next reboot, when Alpine found this overlay file, will unpack it and restore the saved state.

[1] https://dl-cdn.alpinelinux.org/alpine/v3.15/releases/x86_64/alpine-standard-3.15.4-x86_64.iso

[2] If you are using the ISO mentioned on [1]

[3] https://linuxconfig.org/how-to-uncompress-and-list-an-initramfs-content-on-linux

[4] https://docs.alpinelinux.org/user-handbook/0.1a/Installing/medium.html#_using_the_image

[5] https://wiki.alpinelinux.org/wiki/Installation#Installation_Overview

[6] https://wiki.alpinelinux.org/wiki/Alpine_local_backup

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .