Alpine Linux OpenVZ Template

apmuthu

Active Member
Feb 26, 2009
745
6
38
Chennai - India & Singapore
Replace the ash with bash for the entire container.
To use bash as a shell just type bash:
$ bash

To login to alpine Linux LXD vm from host, enter:
$ lxc exec alpine-lxd-vm-name-here bash

To change root shell to bash, enter:
# vi /etc/passwd
Find user name and the default shell such as /bin/ash:

root:x:0:0:root:/root:/bin/ash
Replace it with /bin/bash:

root:x:0:0:root:/root:/bin/bash

Customize bash shell
Here is a sample file:
cat ~/.bashrc
Sample outputs:

alias update='apk update && apk upgrade'
export HISTTIMEFORMAT="%d/%m/%y %T "
export PS1='\u@\h:\W \$ '
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'
source /etc/profile.d/bash_completion.sh
See Customize the bash shell environments wiki page for more info.
 

LnxBil

Famous Member
Feb 21, 2015
6,292
777
163
Saarland, Germany
Ah, you mean LXC, not OpenVZ as you wrote in your first post.

What is wrong with the default Alpine template and why is bash part of a "minimal" alpine linux?
 

apmuthu

Active Member
Feb 26, 2009
745
6
38
Chennai - India & Singapore
ash comes in by default in Apline Linux Minimal. I needed bash for OpenVZ compatibility in PVE 3.x. Networkng in OpenVZ did not work on bootup and had to be manually started for both ash and bash (and sh). This is not for the standard LXC version of it in PVE 4.x series.

Will try the bash rc...
 

zenny

Active Member
Jul 7, 2008
86
2
28
@apmuthu : Thanks for sharing your alpine linux container image.

1. But, when I try to run anything, I am getting:

Feb 22 13:12:22 rproxy daemon.info init: process '/sbin/getty 38400 tty2' (pid 634) exited. Scheduling for restart.
Feb 22 13:12:22 rproxy daemon.info init: can't open /dev/1: No such file or directory
Feb 22 13:12:22 rproxy daemon.info init: can't open /dev/2: No such file or directory

2. Upon searching the Net, I came across http://pve.proxmox.com/wiki/OpenVZ_Console#Alpine_v3.5.1, but when executing:

root@rproxy:~# mknod /dev/1 c 4 1
mknod: /dev/1: Operation not permitted
root@rproxy:~# mknod /dev/2 c 4 2
mknod: /dev/2: Operation not permitted
root@rproxy:~# mknod /dev/tty2 c 4 2
mknod: /dev/tty2: File exists

3. Listing the /dev directory gives the following:

# ls /dev/
console full null pts/ shm/ stdin tty tty2 zero
fd/ log ptmx random stderr stdout tty1 urandom

4. Maybe 1) above is the reason that pound can not run:

# rc-service pound start
* Starting pound ...
* start-stop-daemon: failed to start `/usr/sbin/pound' [ !! ]
* ERROR: pound failed to start

Thanks in advance.
 

apmuthu

Active Member
Feb 26, 2009
745
6
38
Chennai - India & Singapore
My OpenVZ template has been tested in PVE 3.4 with the appropriate /etc/vz/dists/alpine.conf and /etc/vz/dists/scripts/set_console.sh as setout in the PVE Console wiki page. If you use it on PVE 4.x on LXC, you are on your own. Also make sure you are using the build 3 version of the template. Please note that the "#" prefix in the commands are just comments that need to be removed when executing the command.

Check if manually creating /dev/1 and /dev/2 folders makes any difference.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get your own in 60 seconds.

Buy now!