Skip to content

Commit e22ae2c

Browse files
committed
Fix etc overlay and /tmp -> /usr/bin
1 parent 4fbc63b commit e22ae2c

File tree

6 files changed

+53
-38
lines changed

6 files changed

+53
-38
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ installer/
102102
### What the Installer Does
103103

104104
1. **Checks existing installation** - Prompts before overwriting
105-
2. **Copies binaries** - Places Sysbox binaries in `/tmp/` (writable location)
105+
2. **Copies binaries** - Places Sysbox binaries in `/usr/bin` (writable location)
106106
3. **Sets up /etc overlay** - Creates persistent overlay preserving existing configs
107107
4. **Creates symlinks** - Links rsync, modprobe, iptables for Sysbox requirements
108108
5. **Configures Docker** - Adds sysbox-runc runtime to Docker daemon
@@ -113,8 +113,7 @@ installer/
113113
### Data Locations
114114

115115
- **Sysbox data**: `/dstack/persistent/sysbox-data`
116-
- **Overlay data**: `/dstack/persistent/sysbox-etc-overlay`
117-
- **Binaries**: `/tmp/sysbox-*` and `/tmp/rsync-static`
116+
- **Binaries**: `/usr/bin`
118117

119118
### Security
120119

docker/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ COPY --from=builder /build/sysbox-install/sysbox-fs /usr/local/bin/sysbox-fs
7070
# Copy scripts and service files
7171
COPY scripts/install-sysbox-complete.sh /usr/local/bin/install-sysbox-complete.sh
7272
COPY scripts/verify-downloads.sh /usr/local/bin/verify-downloads.sh
73-
COPY scripts/sysbox-etc-overlay.service /usr/local/share/sysbox-etc-overlay.service
74-
COPY scripts/sysbox-mgr.service /usr/local/share/sysbox-mgr.service
73+
COPY scripts/sysbox-mgr.service /usr/local/share/sysbox-mgr.service
7574
COPY scripts/sysbox-fs.service /usr/local/share/sysbox-fs.service
7675

7776
# Make everything executable

scripts/install-sysbox-complete.sh

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -92,28 +92,60 @@ copy_binaries() {
9292
log_success "Binaries copied and dependencies linked"
9393
}
9494

95+
setup_subuid_subgid() {
96+
log_info "Setting up subuid/subgid..."
97+
hostrun sh -c 'echo "sysbox:200000:65536" > /etc/subuid'
98+
hostrun sh -c 'echo "sysbox:200000:65536" > /etc/subgid'
99+
log_success "Created subuid/subgid mappings"
100+
}
101+
95102
# Setup /etc overlay and configuration
96103
setup_etc_overlay() {
104+
# Check if main overlay already exists
105+
if hostrun mount | grep -q " /etc .*overlay"; then
106+
log_warning "/etc already has overlay mounted - skipping mount"
107+
return
108+
fi
109+
97110
log_info "Setting up /etc overlay..."
98111

99-
# Create persistent overlay directories
100-
hostrun mkdir -p /dstack/persistent/sysbox-etc-overlay/upper /dstack/persistent/sysbox-etc-overlay/work
112+
# Create volatile overlay directories for /etc
113+
hostrun mkdir -p /var/volatile/overlay/etc/sysbox/upper /var/volatile/overlay/etc/sysbox/work
101114

102-
# Check if main overlay already exists
103-
if hostrun mount | grep -q "/etc.*overlay.*sysbox-etc-overlay"; then
104-
log_warning "/etc already has sysbox overlay mounted"
105-
else
106-
# Mount main /etc overlay
107-
hostrun mount -t overlay overlay \
108-
-o lowerdir=/etc,upperdir=/dstack/persistent/sysbox-etc-overlay/upper,workdir=/dstack/persistent/sysbox-etc-overlay/work \
109-
/etc
110-
log_success "Main /etc overlay mounted"
115+
# Preserve wireguard config if it exists in volatile storage
116+
if [ -f /host/var/volatile/overlay/etc/wireguard/upper/wg0.conf ]; then
117+
log_info "Preserving existing wireguard configuration..."
118+
mkdir -p /host/var/volatile/overlay/etc/sysbox/upper/wireguard
119+
cp /host/var/volatile/overlay/etc/wireguard/upper/* /host/var/volatile/overlay/etc/sysbox/upper/wireguard/ 2>/dev/null || true
111120
fi
112121

113-
# Create subuid/subgid
114-
hostrun sh -c 'echo "sysbox:200000:65536" > /etc/subuid'
115-
hostrun sh -c 'echo "sysbox:200000:65536" > /etc/subgid'
116-
log_success "Created subuid/subgid mappings"
122+
# Preserve docker config if it exists in volatile storage
123+
if [ -d /host/var/volatile/overlay/etc/docker/upper ]; then
124+
log_info "Preserving existing Docker configuration..."
125+
mkdir -p /host/var/volatile/overlay/etc/sysbox/upper/docker
126+
cp -r /host/var/volatile/overlay/etc/docker/upper/* /host/var/volatile/overlay/etc/sysbox/upper/docker/ 2>/dev/null || true
127+
fi
128+
129+
# Unmount existing individual overlays (except /etc/users which should remain persistent)
130+
log_info "Unmounting individual overlays..."
131+
hostrun umount /etc/wireguard 2>/dev/null || true
132+
hostrun umount /etc/docker 2>/dev/null || true
133+
134+
# Mount volatile /etc overlay
135+
hostrun mount -t overlay overlay \
136+
-o lowerdir=/etc,upperdir=/var/volatile/overlay/etc/sysbox/upper,workdir=/var/volatile/overlay/etc/sysbox/work \
137+
/etc
138+
log_success "Volatile /etc overlay mounted"
139+
140+
# Remount /etc/users as persistent (if it exists) to override the volatile /etc mount
141+
if [ -d /host/dstack/persistent/overlay/etc/users ]; then
142+
log_info "Remounting /etc/users as persistent overlay..."
143+
hostrun mkdir -p /dstack/persistent/overlay/etc/users/upper /dstack/persistent/overlay/etc/users/work
144+
hostrun mount -t overlay overlay \
145+
-o lowerdir=/etc/users,upperdir=/dstack/persistent/overlay/etc/users/upper,workdir=/dstack/persistent/overlay/etc/users/work \
146+
/etc/users
147+
log_success "/etc/users mounted as persistent overlay"
148+
fi
117149
}
118150

119151
# Configure Docker runtime
@@ -231,7 +263,6 @@ show_status() {
231263
echo
232264
echo "📁 Data Location:"
233265
echo " • Sysbox data: /dstack/persistent/sysbox-data"
234-
echo " • Overlay data: /dstack/persistent/sysbox-etc-overlay"
235266
echo
236267
}
237268

@@ -240,6 +271,7 @@ main() {
240271
check_existing
241272
copy_binaries
242273
setup_etc_overlay
274+
setup_subuid_subgid
243275
configure_docker
244276
create_systemd_services
245277
start_sysbox

scripts/sysbox-etc-overlay.service

Lines changed: 0 additions & 15 deletions
This file was deleted.

scripts/sysbox-fs.service

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Requires=sysbox-mgr.service
66

77
[Service]
88
Type=simple
9-
ExecStart=/tmp/sysbox-fs
9+
ExecStart=/usr/bin/sysbox-fs
1010
ExecStop=/bin/kill -TERM $MAINPID
1111
Restart=on-failure
1212
RestartSec=5

scripts/sysbox-mgr.service

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Wants=docker.service
66

77
[Service]
88
Type=simple
9-
ExecStart=/tmp/sysbox-mgr --data-root /dstack/persistent/sysbox-data
9+
ExecStart=/usr/bin/sysbox-mgr --data-root /dstack/persistent/sysbox-data
1010
ExecStop=/bin/kill -TERM $MAINPID
1111
Restart=on-failure
1212
RestartSec=5

0 commit comments

Comments
 (0)