-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfeatures.html
More file actions
848 lines (828 loc) · 53.3 KB
/
features.html
File metadata and controls
848 lines (828 loc) · 53.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="description" content="Deep dive into every Droidspaces feature: namespace isolation, init system support, OverlayFS volatile mode, GPU acceleration, cgroup isolation, seccomp shields, and Android-specific tuning.">
<meta name="keywords" content="droidspaces, features, namespace, isolation, cgroup, overlayfs, volatile, mode, init, system, support, gpu, acceleration">
<title>Feature Deep Dives - Droidspaces Docs</title>
<meta property="og:title" content="Feature Deep Dives - Droidspaces Docs">
<meta property="og:description" content="Deep dive into every Droidspaces feature: namespace isolation, init system support, OverlayFS volatile mode, GPU acceleration, cgroup isolation, seccomp shields, and Android-specific tuning.">
<meta property="og:url" content="https://www.droidspaces.org/docs/features.html">
<meta property="og:type" content="website">
<meta property="og:image" content="https://i.ibb.co/d4PLN7Gg/og-image.png">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Feature Deep Dives - Droidspaces Docs">
<meta name="twitter:description" content="Deep dive into every Droidspaces feature: namespace isolation, init system support, OverlayFS volatile mode, GPU acceleration, cgroup isolation, seccomp shields, and Android-specific tuning.">
<meta name="twitter:image" content="https://i.ibb.co/d4PLN7Gg/og-image.png">
<link rel="canonical" href="https://www.droidspaces.org/docs/features.html">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=DM+Sans:wght@300;400;500;600&display=swap" rel="stylesheet">
<link rel="icon" href="/favicon.ico">
<link rel="apple-touch-icon" href="/favicon.ico">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css">
<link rel="stylesheet" href="../style.css">
<style>
.docs-layout {
display: flex; min-height: calc(100vh - 56px);
}
.sidebar {
width: 300px; flex-shrink: 0;
border-right: 1px solid var(--border);
background: var(--bg2);
overflow-y: auto;
position: sticky; top: 56px; height: calc(100vh - 56px);
}
.sidebar-inner {
padding: 0;
position: relative;
width: 100%;
min-width: 0;
}
.sidebar-group {
margin-bottom: 0;
}
.sidebar-heading {
font-family: var(--mono); font-size: 0.7rem; font-weight: 700;
text-transform: uppercase; letter-spacing: 0.08em;
color: var(--muted); padding: 1rem 1rem 0.25rem;
}
.sidebar-link {
display: block; padding: 0.5rem 1rem;
font-size: 0.9rem; color: var(--muted);
text-decoration: none; border-radius: 0;
transition: all 0.1s;
}
.sidebar-link:hover {
color: var(--text); background: var(--bg3);
}
.sidebar-link.active {
color: var(--accent2); background: rgba(79,142,247,0.08);
font-weight: 600;
}
.sidebar-content {
flex: 1; min-width: 0;
padding: 2rem 2rem 4rem;
max-width: none;
}
.sidebar-content h1 {
font-family: var(--mono); font-size: clamp(1.5rem, 2.5vw, 2rem);
font-weight: 700; letter-spacing: -0.03em; color: var(--text);
margin-bottom: 1.5rem; padding-bottom: 0.75rem;
border-bottom: 1px solid var(--border);
}
.sidebar-content h2 {
font-family: var(--mono); font-size: 1.25rem; font-weight: 700;
color: var(--text); margin: 2rem 0 0.75rem;
letter-spacing: -0.02em;
}
.sidebar-content h2:target {
border-left: 3px solid var(--accent);
padding-left: 0.75rem;
}
.sidebar-content h3 {
font-family: var(--mono); font-size: 1rem; font-weight: 600;
color: var(--accent2); margin: 1.5rem 0 0.5rem;
}
.sidebar-content h3:target {
border-left: 2px solid var(--accent);
padding-left: 0.5rem;
}
.sidebar-content p {
color: var(--muted); line-height: 1.7; margin-bottom: 1rem;
}
.sidebar-content strong { color: var(--text); }
.sidebar-content a {
color: var(--accent2); text-decoration: none;
word-break: break-word; overflow-wrap: anywhere;
}
.sidebar-content a:hover { text-decoration: underline; }
.sidebar-content code {
font-family: var(--mono); font-size: 0.82rem;
background: var(--bg3); padding: 0.15rem 0.4rem;
border-radius: 4px; color: var(--accent2);
word-break: break-word; overflow-wrap: anywhere;
}
.sidebar-content pre {
background: var(--bg2); border: 1px solid var(--border);
border-radius: 8px; padding: 1rem; overflow-x: auto;
margin-bottom: 1rem;
}
.sidebar-content pre code {
background: none; padding: 0; font-size: 0.78rem;
color: var(--text); line-height: 1.6;
}
.code-block {
position: relative;
}
.code-block:hover .copy-btn {
opacity: 1;
}
.copy-btn {
position: absolute; top: 0.5rem; right: 0.5rem;
background: var(--bg3); border: 1px solid var(--border);
color: var(--muted); font-size: 0.7rem;
font-family: var(--sans); padding: 0.2rem 0.5rem;
border-radius: 4px; cursor: pointer;
opacity: 0; transition: opacity 0.15s; z-index: 1;
display: inline-flex; align-items: center; gap: 0.25rem;
}
.copy-btn:hover {
color: var(--accent2); border-color: var(--accent2);
}
@media (max-width: 768px) {
.copy-btn { opacity: 1; }
}
.sidebar-content ul, .sidebar-content ol {
color: var(--muted); line-height: 1.7;
margin-bottom: 1rem; padding-left: 1.25rem;
}
.sidebar-content li { margin-bottom: 0.25rem; }
.sidebar-content li > .code-block { margin-top: 0.5rem; }
.sidebar-content blockquote {
border-left: 3px solid var(--accent); background: var(--bg3);
padding: 0.75rem 1rem; margin-bottom: 1rem;
border-radius: 0 6px 6px 0;
color: var(--text); font-size: 0.9rem;
}
.sidebar-content blockquote p { color: var(--text); margin-bottom: 0; }
.sidebar-content hr {
border: none; border-top: 1px solid var(--border); margin: 2rem 0;
}
.table-wrap {
overflow-x: auto;
-webkit-overflow-scrolling: touch;
margin-bottom: 1.5rem;
}
.table-wrap table {
width: max-content;
min-width: 100%;
margin-bottom: 0;
}
.sidebar-content table {
width: max-content; min-width: 100%;
border-collapse: collapse; font-size: 0.85rem;
margin-bottom: 1.5rem;
}
.sidebar-content th {
font-family: var(--mono); font-size: 0.72rem; font-weight: 700;
text-transform: uppercase; letter-spacing: 0.06em;
padding: 0.75rem 1rem; text-align: left; color: var(--muted);
border-bottom: 1px solid var(--border); background: var(--bg3);
white-space: nowrap;
}
.sidebar-content td {
padding: 0.75rem 1rem; border-bottom: 1px solid var(--border);
color: var(--muted);
white-space: normal; word-break: normal;
overflow-wrap: break-word; max-width: 300px;
}
.sidebar-content img {
max-width: 100%; border-radius: 8px; border: 1px solid var(--border);
margin: 1rem 0;
}
.sidebar-content details {
background: var(--bg2); border: 1px solid var(--border);
border-radius: 8px; padding: 1rem; margin-bottom: 1rem;
}
.sidebar-content summary {
font-family: var(--mono); font-size: 0.85rem;
cursor: pointer; color: var(--accent2);
}
.callout {
border-left: 4px solid var(--accent);
background: var(--bg3); padding: 0.75rem 1rem;
margin-bottom: 1rem; border-radius: 0 6px 6px 0;
font-size: 0.9rem; color: var(--text);
}
.callout-title {
font-family: var(--mono); font-size: 0.72rem;
text-transform: uppercase; letter-spacing: 0.06em;
display: block; margin-bottom: 0.25rem;
}
.callout-note { border-left-color: var(--accent); }
.callout-note .callout-title { color: var(--accent); }
.callout-tip { border-left-color: var(--green); }
.callout-tip .callout-title { color: var(--green); }
.callout-warning { border-left-color: #f59e0b; }
.callout-warning .callout-title { color: #f59e0b; }
.callout-caution { border-left-color: #f59e0b; }
.callout-caution .callout-title { color: #f59e0b; }
.callout-important { border-left-color: #ef4444; }
.callout-important .callout-title { color: #ef4444; }
.doc-nav-buttons {
display: flex; justify-content: space-between; gap: 1rem;
margin: 2rem 0 1rem;
}
.doc-nav-btn {
padding: 0.5rem 1rem; border-radius: 8px;
font-family: var(--sans); font-size: 0.82rem; font-weight: 500;
text-decoration: none; color: var(--muted);
border: 1px solid var(--border);
transition: all 0.15s; max-width: 50%;
}
.doc-nav-btn:hover {
color: var(--text); border-color: var(--muted);
}
.doc-nav-next {
margin-left: auto; text-align: right;
}
.doc-nav-prev {
text-align: left;
}
.doc-copyright {
font-size: 0.78rem; color: var(--border2);
padding-top: 1rem; border-top: 1px solid var(--border);
margin-top: 1.5rem; text-align: center;
}
.doc-copyright a {
color: var(--border2); text-decoration: none;
}
.doc-copyright a:hover {
color: var(--muted);
}
.nav-overlay {
display: none; position: fixed;
top: 56px; left: 0; right: 0; bottom: 0;
background: rgba(0,0,0,0.5); z-index: 199;
}
.nav-overlay.active { display: block; }
.sidebar-close {
display: none;
position: absolute; top: 0.5rem; right: 1rem;
background: none; border: none;
color: var(--muted); font-size: 1.5rem;
cursor: pointer; padding: 0.25rem 0.5rem;
line-height: 1; border-radius: 4px;
}
.sidebar-close:hover {
color: var(--text); background: var(--bg3);
}
.doc-breadcrumb {
display: none;
position: sticky;
top: 56px;
z-index: 50;
align-items: center;
gap: 0.5rem;
padding: 0.5rem 1rem;
background: var(--bg2);
border-bottom: 1px solid var(--border);
font-size: 0.78rem;
color: var(--muted);
user-select: none;
cursor: pointer;
}
.doc-breadcrumb .bc-sep {
color: var(--border2);
}
.doc-breadcrumb .bc-section {
color: var(--text);
}
.doc-breadcrumb .bc-label {
color: var(--accent2);
}
@media (max-width: 768px) {
.sidebar {
display: flex;
position: fixed; top: 56px; left: 0;
width: 300px; height: calc(100dvh - 56px); z-index: 200;
border-right: 1px solid var(--border);
transform: translateX(-100%);
transition: transform 0.25s ease;
box-shadow: 4px 0 12px rgba(0,0,0,0.2);
}
.sidebar.open { transform: translateX(0); }
.sidebar-close { display: block; }
.sidebar-content { padding: 1.5rem 1rem 3rem; }
.doc-breadcrumb { display: flex; }
.docs-layout { flex-direction: column; }
.sidebar-content th,
.sidebar-content td {
padding: 0.5rem 0.5rem;
font-size: 0.78rem;
}
}
</style>
<script>
(function () {
const savedTheme = localStorage.getItem('theme');
if (savedTheme) document.documentElement.setAttribute('data-theme', savedTheme);
})();
</script>
</head>
<body>
<nav aria-label="Main navigation">
<div class="container" style="display:flex;align-items:center;justify-content:space-between;height:100%;">
<a href="/" class="nav-logo">
<svg class="logo-icon" viewBox="8.25 10.35 31.5 27.3" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path d="M36.85 30.16H11.15c-0.82 0-1.48 0.68-1.48 1.52v3.05c0 0.84 0.66 1.52 1.48 1.52h25.69c0.82 0 1.48-0.68 1.48-1.52v-3.05c0-0.84-0.66-1.52-1.48-1.52ZM12.58 34.97c-0.95 0-1.73-0.79-1.73-1.77s0.77-1.77 1.73-1.77 1.73 0.79 1.73 1.77-0.77 1.77-1.73 1.77Z"/>
<path d="M36.85 21.00H11.15c-0.82 0-1.48 0.68-1.48 1.52v3.05c0 0.84 0.66 1.52 1.48 1.52h25.69c0.82 0 1.48-0.68 1.48-1.52v-3.05c0-0.84-0.66-1.52-1.48-1.52ZM12.58 25.82c-0.95 0-1.73-0.79-1.73-1.77s0.77-1.77 1.73-1.77 1.73 0.79 1.73 1.77-0.77 1.77-1.73 1.77Z"/>
<path d="M36.84 11.74H11.15c-0.82 0-1.48 0.68-1.48 1.52v3.05c0 0.84 0.66 1.52 1.48 1.52h25.69c0.82 0 1.48-0.68 1.48-1.52v-3.05c0-0.84-0.66-1.52-1.48-1.52ZM12.58 16.57c-0.95 0-1.73-0.79-1.73-1.77s0.77-1.77 1.73-1.77 1.73 0.79 1.73 1.77-0.77 1.77-1.73 1.77Z"/>
</svg>
<span class="logo-text">Droidspaces</span>
</a>
<div style="display:flex;align-items:center;gap:0.5rem;">
<ul class="nav-links">
<li class="nav-features"><a href="/#features">Features</a></li>
<li><a href="/docs/" style="color:var(--accent2)"><i class="fas fa-book nav-icon nav-icon-docs"></i><span class="nav-label">Documentation</span></a></li>
<li class="nav-downloads"><a href="/downloads.html"><i class="fas fa-download nav-icon nav-icon-docs"></i><span class="nav-label">Downloads</span></a></li>
<li><a href="https://github.com/ravindu644/Droidspaces-OSS" rel="noopener noreferrer"><i class="fab fa-github nav-icon"></i><span class="nav-label nav-label-gt">GitHub</span></a></li>
<li><a href="https://t.me/Droidspaces" rel="noopener noreferrer"><i class="fab fa-telegram nav-icon"></i><span class="nav-label nav-label-gt">Telegram</span></a></li>
</ul>
<button class="theme-toggle" id="theme-toggle" title="Toggle theme">
<svg class="sun-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="display:none">
<circle cx="12" cy="12" r="5"></circle>
<line x1="12" y1="1" x2="12" y2="3"></line>
<line x1="12" y1="21" x2="12" y2="23"></line>
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
<line x1="1" y1="12" x2="3" y2="12"></line>
<line x1="21" y1="12" x2="23" y2="12"></line>
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
</svg>
<svg class="moon-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path>
</svg>
</button>
</div>
</div>
</nav>
<div class="nav-overlay" id="sidebar-overlay"></div>
<div class="doc-breadcrumb" id="sidebar-toggle" role="button" tabindex="0" aria-label="Toggle docs navigation">
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" style="flex-shrink:0">
<rect x="3" y="3" width="18" height="18" rx="2"/>
<line x1="9" y1="3" x2="9" y2="21"/>
</svg>
<span>Docs</span><span class="bc-sep">/</span><span class="bc-section">Guides</span><span class="bc-sep">/</span><span class="bc-label">Feature Deep Dives</span>
</div>
<div class="docs-layout">
<aside class="sidebar" id="sidebar">
<div class="sidebar-inner">
<button class="sidebar-close" id="sidebar-close" aria-label="Close sidebar">×</button>
<div class="sidebar-group">
<div class="sidebar-heading">Basics</div>
<a href="installation-android.html" class="sidebar-link">Android Installation</a>
<a href="installation-linux.html" class="sidebar-link">Linux Installation</a>
</div>
<div class="sidebar-group">
<div class="sidebar-heading">Guides</div>
<a href="features.html" class="sidebar-link active">Feature Deep Dives</a>
<a href="gpu-acceleration.html" class="sidebar-link">GPU Acceleration</a>
<a href="kernel-configuration.html" class="sidebar-link">Kernel Configuration</a>
<a href="usage-android-app.html" class="sidebar-link">Android App Usage</a>
<a href="linux-cli.html" class="sidebar-link">Linux CLI</a>
</div>
<div class="sidebar-group">
<div class="sidebar-heading">Recipes</div>
<a href="cool-things-you-can-do.html" class="sidebar-link">Cool Things You Can Do</a>
</div>
<div class="sidebar-group">
<div class="sidebar-heading">Reference</div>
<a href="troubleshooting.html" class="sidebar-link">Troubleshooting</a>
<a href="community-supported-devices.html" class="sidebar-link">Community-Supported Devices</a>
<a href="nix-nixos.html" class="sidebar-link">Nix/NixOS</a>
<a href="uninstallation.html" class="sidebar-link">Uninstallation</a>
</div>
</div>
</aside>
<div class="sidebar-content">
<h1 id="feature-deep-dives">Feature Deep Dives</h1>
<p>Detailed explanations of each major Droidspaces feature and how it works under the hood.</p>
<hr>
<h2 id="namespace-isolation">Namespace Isolation</h2>
<h3 id="what-are-namespaces">What Are Namespaces?</h3>
<p>Linux namespaces are a kernel feature that partitions system resources so that each group of processes sees its own isolated set of resources. Droidspaces uses five namespaces to create isolated containers:</p>
<div class="table-wrap"><table>
<thead>
<tr><th>Namespace</th><th>Flag</th><th>What It Isolates</th></tr>
</thead>
<tbody>
<tr><td><strong>PID</strong></td><td><code>CLONE_NEWPID</code></td><td>Process IDs. The container gets its own PID tree where init is PID 1.</td></tr>
<tr><td><strong>MNT</strong></td><td><code>CLONE_NEWNS</code></td><td>Mount points. The container has its own filesystem view via <code>pivot_root</code>.</td></tr>
<tr><td><strong>UTS</strong></td><td><code>CLONE_NEWUTS</code></td><td>Hostname and domain name. Each container can have its own hostname.</td></tr>
<tr><td><strong>IPC</strong></td><td><code>CLONE_NEWIPC</code></td><td>System V IPC and POSIX message queues. Prevents cross-container IPC leaks.</td></tr>
<tr><td><strong>Cgroup</strong></td><td><code>CLONE_NEWCGROUP</code></td><td>Cgroup root directory. Each container sees its own cgroup hierarchy.</td></tr>
<tr><td><strong>Network</strong></td><td><code>CLONE_NEWNET</code></td><td>Network stack. Isolated interfaces, routing, and firewall (NAT/None modes).</td></tr>
</tbody>
</table></div>
<h3 id="network-namespace-isolation-net">Network Namespace Isolation (<code>--net</code>)</h3>
<p>Droidspaces supports three networking modes that determine whether a network namespace (<code>CLONE_NEWNET</code>) is used:</p>
<ol>
<li><strong>Host Mode (<code>--net=host</code>) - Default</strong>: Droidspaces deliberately does <strong>not</strong> unshare the network namespace. The container shares the host's network stack. This greatly simplifies setup: containers get internet access immediately without virtual bridges, NAT, or firewall rules. On Android, where networking is already complex (cellular, Wi-Fi, VPN), this avoids a whole category of connectivity issues.
</li>
<li><strong>NAT Mode (<code>--net=nat</code>)</strong>: The container is placed in a private network namespace. It is connected to the host via a virtual bridge or veth pair, providing <strong>Pure Network Isolation</strong> while maintaining internet access through the host's upstream interfaces. Compatible with the vast majority of Android devices.
</li>
<li><strong>None Mode (<code>--net=none</code>)</strong>: The container is placed in a private, air-gapped network namespace with only the loopback interface enabled for maximum security.
</li>
</ol>
<h3 id="how-it-compares-to-chroot">How It Compares to Chroot</h3>
<p>A <code>chroot</code> only changes the apparent root directory for a process. It provides no process isolation, no mount isolation, no hostname isolation, and no IPC isolation. Any process inside a chroot shares the host's PID space, can see and signal other processes, and cannot run an init system like systemd.</p>
<p>Droidspaces uses <code>pivot_root</code> instead of <code>chroot</code>, which is a stronger isolation mechanism. Combined with private mount propagation (<code>MS_PRIVATE</code>), the container's mount events are completely invisible to the host.</p>
<hr>
<h2 id="init-system-support">Init System Support</h2>
<h3 id="why-init-systems-matter">Why Init Systems Matter</h3>
<p>Without an init system, you're running individual processes in a chroot. You can't manage services, you can't use <code>systemctl</code>, you don't have journald for logging, and you don't have proper session management. It's a glorified shell.</p>
<p>Droidspaces boots a real init system. When systemd starts as PID 1 inside the container:</p>
<ul>
<li>Services are managed via <code>systemctl start/stop/enable</code>
</li>
<li>Logs are available via <code>journalctl</code>
</li>
<li>User sessions work properly with <code>login</code>, <code>su</code>, and <code>sudo</code>
</li>
<li>Targets and dependencies are resolved correctly
</li>
<li>Timer units, socket activation, and all other systemd features work
</li>
</ul>
<h3 id="how-droidspaces-enables-it">How Droidspaces Enables It</h3>
<p>Three things are required for systemd to function inside a container:</p>
<ol>
<li><strong>PID 1:</strong> The init process must be PID 1. Droidspaces achieves this with a PID namespace (<code>CLONE_NEWPID</code>) followed by a fork, making the container's init the first process in its namespace.
</li>
<li><strong>Container detection:</strong> Systemd needs to know it's running inside a container. Droidspaces writes <code>droidspaces</code> to <code>/run/systemd/container</code> and sets the <code>container=droidspaces</code> environment variable.
</li>
<li><strong>Cgroup access:</strong> Systemd requires write access to its cgroup hierarchy to create scopes and slices. Droidspaces provides this through per-container cgroup trees (see <a href="#cgroup-isolation" rel="noopener noreferrer">Cgroup Isolation</a>).
</li>
</ol>
<h3 id="supported-init-systems">Supported Init Systems</h3>
<p>Droidspaces is theoretically compatible with <strong>any init system</strong> that can run as PID 1, including:</p>
<ul>
<li><strong>systemd</strong> (most Linux distributions)
</li>
<li><strong>OpenRC</strong> (Alpine Linux, Gentoo)
</li>
<li><strong>runit</strong> (Void Linux, Devuan)
</li>
<li><strong>s6-init</strong> (Alpine, various containers)
</li>
<li><strong>SysVinit</strong> (Debian, Devuan)
</li>
</ul>
<p>The init binary is strictly expected at <code>/sbin/init</code>. If this binary is missing or not executable, Droidspaces will fail to boot the container to ensure that services and session management function as expected.</p>
<hr>
<h2 id="volatile-mode">Volatile Mode</h2>
<h3 id="what-is-volatile-mode">What Is Volatile Mode?</h3>
<p>Volatile mode (<code>--volatile</code> or <code>-V</code>) creates an ephemeral container where all modifications are stored in RAM and discarded when the container stops. The original rootfs is never modified.</p>
<h3 id="how-it-works">How It Works</h3>
<p>Droidspaces uses <strong>OverlayFS</strong>, a union filesystem built into the Linux kernel:</p>
<ul>
<li><strong>Lower layer:</strong> The original rootfs (mounted read-only if using the rootfs.img mode)
</li>
<li><strong>Upper layer:</strong> A tmpfs-backed directory that captures all writes
</li>
<li><strong>Merged view:</strong> The container sees a unified filesystem where reads come from the lower layer and writes go to the upper layer
</li>
</ul>
<p>When the container stops, the upper layer (in RAM) is discarded. The original rootfs remains untouched.</p>
<h3 id="use-cases">Use Cases</h3>
<ul>
<li><strong>Testing:</strong> Install packages, modify configurations, and verify changes without committing anything
</li>
<li><strong>Development:</strong> Spin up a clean environment for each build
</li>
<li><strong>Security:</strong> Guaranteed clean state on every boot
</li>
<li><strong>Experimentation:</strong> Break things without consequences
</li>
</ul>
<h3 id="usage">Usage</h3>
<div class="code-block"><button class="copy-btn" onclick="copyCode(this)"><i class="fa-regular fa-copy"></i> Copy</button><pre><code># Volatile container from a directory
droidspaces --name=test --rootfs=/path/to/rootfs --volatile start
# Volatile container from an image
droidspaces --name=test --rootfs-img=/path/to/rootfs.img --volatile start
</code></pre></div>
<h3 id="known-limitation-f2fs-on-android">Known Limitation: f2fs on Android</h3>
<p>Most Android devices use f2fs for the <code>/data</code> partition. OverlayFS on many Android kernels does not support f2fs as a lower directory. This means <strong>volatile mode with a directory rootfs on f2fs will fail</strong>.</p>
<p><strong>Workaround:</strong> Use a rootfs image (<code>--rootfs-img</code>) instead. The ext4 loop mount provides a compatible lower directory for OverlayFS.</p>
<p>Droidspaces detects this incompatibility at runtime and provides a clear diagnostic message.</p>
<hr>
<h2 id="hardware-access-mode">Hardware Access Mode</h2>
<div class="callout callout-caution"><strong class="callout-title">CAUTION</strong> Enabling Hardware Access Mode (<code>--hw-access</code>) exposes all host devices, including raw block devices, directly to the container. If a malicious process or accidental command targets these devices, it could permanently destroy your partition table, wipe your SD card, or brick your device. The developer(s) of Droidspaces is not responsible for any data loss or hardware damage that occurs as a result of using this feature. <strong>Use at your own risk.</strong></div>
<h3 id="what-it-does">What It Does</h3>
<p>The <code>--hw-access</code> flag exposes the host's hardware devices to the container by mounting <code>devtmpfs</code> instead of a private <code>tmpfs</code> at <code>/dev</code>.</p>
<p>This gives the container access to: - <strong>GPU</strong> (for hardware-accelerated graphics via Turnip + Zink, Panfrost/Native GPU Acceleration in desktop for Intel and AMD) - <strong>Cameras</strong> - <strong>Sensors</strong> - <strong>USB devices</strong> - <strong>Block Devices</strong> (Partitions and physical disks)</p>
<h3 id="security-implications">Security Implications</h3>
<p>Hardware access mode grants the container visibility to <strong>all</strong> host devices. The container can interact with the GPU, USB controllers, and other hardware directly. Only use this mode when you trust the container's contents and need hardware access.</p>
<h3 id="the-systemd-258-fix">The systemd 258+ Fix</h3>
<p>Starting with systemd 258, the container detection logic was hardened. systemd now checks whether <code>/sys</code> is mounted read-only to determine if it's running in a container versus a physical machine. If <code>/sys</code> is read-write, systemd assumes it has full hardware authority and attempts to attach services (like <code>getty</code>) to physical TTYs (<code>tty1</code>-<code>tty6</code>). Since these do not exist in the isolated container environment, the services fail to start, leaving the console without a login prompt.</p>
<div class="callout callout-note"><strong class="callout-title">NOTE</strong> This information is based on current developer understanding of systemd's behavior in Droidspaces and may require further verification.</div>
<p>Droidspaces handles this with a "dynamic hole-punching" technique:</p>
<ol>
<li><strong>Pinning Subsystems</strong>: All <code>/sys</code> subdirectories are self-bind-mounted to preserve read-write access to individual hardware subsystems.
</li>
<li><strong>Read-Only Remount</strong>: The top-level <code>/sys</code> is remounted read-only.
</li>
<li><strong>Container Identification</strong>: systemd detects the read-only <code>/sys</code>, correctly identifies the container environment, and falls back to container-native console management.
</li>
<li><strong>Hardware Access</strong>: Individual hardware subsystems remain fully accessible via the pinned sub-mounts created in step 1.
</li>
</ol>
<h3 id="usage">Usage</h3>
<div class="code-block"><button class="copy-btn" onclick="copyCode(this)"><i class="fa-regular fa-copy"></i> Copy</button><pre><code>droidspaces --name=gpu-test --rootfs=/path/to/rootfs --hw-access start
</code></pre></div>
<h3 id="automatic-gpu-group-setup">Automatic GPU Group Setup</h3>
<p>When <code>--hw-access</code> is enabled, Droidspaces automatically:</p>
<ol>
<li><strong>Scans host GPU devices</strong> - Before <code>pivot_root</code>, it probes ~40 known GPU device paths (<code>/dev/dri/*</code>, <code>/dev/mali*</code>, <code>/dev/kgsl-3d0</code>, <code>/dev/nvidia*</code>, etc.) and collects their group IDs via <code>stat()</code>. <strong>Dangerous nodes like <code>/dev/dri/card*</code> are explicitly skipped</strong> to prevent host kernel panics, as these nodes are restricted to the host's display manager.
</li>
<li><strong>Creates matching groups</strong> - After <code>pivot_root</code>, it appends entries like <code>gpu_<GID>:x:<GID>:root</code> to the container's <code>/etc/group</code>. The container's root user is automatically added to each group.
</li>
<li><strong>Idempotent restarts</strong> - On container restart, existing groups are detected and skipped (no duplicate entries).
</li>
</ol>
<p>This eliminates the need for manual <code>groupadd</code>/<code>usermod</code> commands inside the container, while ensuring the host's kernel stability by avoiding restricted hardware paths.</p>
<h3 id="x11-socket-mounting">X11 Socket Mounting</h3>
<p>For GUI application support, Droidspaces automatically bind-mounts the X11 socket directory:</p>
<ul>
<li><strong>Android (Termux X11):</strong> Detects and mounts <code>/data/data/com.termux/files/usr/tmp/.X11-unix</code>
</li>
<li><strong>Desktop Linux:</strong> Mounts <code>/tmp/.X11-unix</code> via <code>/proc/1/root/tmp/.X11-unix</code>
</li>
</ul>
<div class="callout callout-tip"><strong class="callout-title">TIP</strong> X11 support can be enabled independently using the <code>--termux-x11</code> (<code>-X</code>) flag. This is the recommended way to use GUI applications on Android if you do not need full GPU/hardware access, as it preserves a higher level of isolation.</div>
<p>After starting the container, set <code>DISPLAY=:0</code> inside the container to use the X11 display.</p>
<h3 id="supported-gpu-families">Supported GPU Families</h3>
<div class="table-wrap"><table>
<thead>
<tr><th>Family</th><th>Device Paths</th></tr>
</thead>
<tbody>
<tr><td><strong>DRI</strong> (Intel, AMD, Mesa)</td><td><code>/dev/dri/renderD128-130</code>, <code>/dev/dri/card0-2</code></td></tr>
<tr><td><strong>NVIDIA</strong> (Proprietary)</td><td><code>/dev/nvidia*</code>, <code>/dev/nvidia-uvm*</code>, <code>/dev/nvidia-caps/*</code></td></tr>
<tr><td><strong>ARM Mali</strong></td><td><code>/dev/mali</code>, <code>/dev/mali0</code>, <code>/dev/mali1</code></td></tr>
<tr><td><strong>Qualcomm Adreno</strong></td><td><code>/dev/kgsl-3d0</code>, <code>/dev/kgsl</code>, <code>/dev/genlock</code></td></tr>
<tr><td><strong>AMD Compute</strong></td><td><code>/dev/kfd</code></td></tr>
<tr><td><strong>PowerVR</strong></td><td><code>/dev/pvr_sync</code></td></tr>
<tr><td><strong>NVIDIA Tegra</strong></td><td><code>/dev/nvhost-ctrl</code>, <code>/dev/nvhost-gpu</code>, <code>/dev/nvmap</code></td></tr>
<tr><td><strong>DMA Heaps</strong></td><td><code>/dev/dma_heap/system</code>, <code>/dev/dma_heap/linux,cma</code>, <code>/dev/dma_heap/reserved</code>, <code>/dev/dma_heap/qcom,system</code></td></tr>
<tr><td><strong>Sync</strong></td><td><code>/dev/sw_sync</code></td></tr>
</tbody>
</table></div>
<hr>
<h2 id="custom-bind-mounts">Custom Bind Mounts</h2>
<h3 id="what-are-bind-mounts">What Are Bind Mounts?</h3>
<p>Bind mounts allow you to map a directory from the host filesystem into the container at a specified location. The host directory becomes visible and writable inside the container.</p>
<h3 id="syntax">Syntax</h3>
<div class="code-block"><button class="copy-btn" onclick="copyCode(this)"><i class="fa-regular fa-copy"></i> Copy</button><pre><code># Single mount
--bind-mount=/host/path:/container/path
-B /host/path:/container/path
# Multiple mounts (comma-separated)
-B /src1:/dst1,/src2:/dst2,/src3:/dst3
# Multiple mounts (chained)
-B /src1:/dst1 -B /src2:/dst2
# Mix and match
-B /src1:/dst1,/src2:/dst2 -B /src3:/dst3
</code></pre></div>
<h3 id="limits">Limits</h3>
<ul>
<li>Destination must be an <strong>absolute path</strong>
</li>
<li>Path traversal (<code>..</code>) in destinations is <strong>rejected</strong> for security
</li>
</ul>
<h3 id="automatic-directory-creation">Automatic Directory Creation</h3>
<p>If the destination directory doesn't exist inside the rootfs, Droidspaces creates it automatically using <code>mkdir -p</code>.</p>
<h3 id="soft-fail-model">Soft-Fail Model</h3>
<p>If a host source path doesn't exist or a mount fails, Droidspaces issues a warning and skips the entry rather than failing the entire boot. This allows containers to start even if optional bind sources are temporarily unavailable.</p>
<h3 id="security">Security</h3>
<p>Droidspaces validates bind mount targets with two protections: 1. <strong>Pre-mount:</strong> Uses <code>lstat()</code> to ensure the target inside the rootfs is not a symlink 2. <strong>Post-mount:</strong> Uses <code>realpath()</code> via the <code>is_subpath()</code> helper to verify the mounted path cannot escape the container root</p>
<hr>
<h2 id="network-isolation-3-modes">Network Isolation (3 Modes)</h2>
<p>Droidspaces provides three distinct networking modes to balance ease-of-use with advanced isolation.</p>
<h3 id="1-host-mode-nethost-default">1. Host Mode (<code>--net=host</code>) - Default</h3>
<p>The container shares the host's network namespace. - <strong>Pros</strong>: Zero configuration, instant internet access, works with all Android VPNs/hotspots. - <strong>Cons</strong>: No port isolation; services inside the container bind to host ports directly.</p>
<h3 id="2-nat-mode-netnat">2. NAT Mode (<code>--net=nat</code>)</h3>
<p>The container is placed in a private network namespace (<code>CLONE_NEWNET</code>) and connected to the host via a virtual bridge (<code>ds-br0</code>) or a direct veth pair. - <strong>Deterministic IP</strong>: Each container is assigned a unique IP in the <code>172.28.0.0/16</code> range, derived from its PID. - <strong>Embedded DHCP</strong>: Droidspaces includes a minimal, built-in DHCP server to automatically configure the container's <code>eth0</code>. - <strong>Pure Isolation</strong>: The container cannot see or interact with the host's network interfaces directly. - <strong>Mandatory Upstream</strong>: You <strong>must</strong> specify which host interfaces provide internet access via <code>--upstream</code> (e.g., <code>--upstream wlan0,rmnet0</code>). Wildcards are also supported (e.g., <code>rmnet*</code>, <code>wlan0</code>, <code>v4-rmnet_data*</code>).</p>
<div class="callout callout-important"><strong class="callout-title">IMPORTANT</strong> NAT mode is <strong>IPv4 only</strong>. If your upstream interface lacks an IPv4 address (IPv6-only network), internet access will not work. See <a href="troubleshooting.html#ipv4-quirks" rel="noopener noreferrer">IPv4 NAT Quirks</a> for a workaround.</div>
<h3 id="3-none-mode-netnone">3. None Mode (<code>--net=none</code>)</h3>
<p>The container gets a private network namespace with only the loopback (<code>lo</code>) interface enabled. - <strong>Use Case</strong>: Maximum security for offline tasks.</p>
<h3 id="port-forwarding-nat-mode">Port Forwarding (NAT Mode)</h3>
<p>In NAT mode, you can expose container services to the host or local network using the <code>--port</code> flag. Supported formats:</p>
<div class="code-block"><button class="copy-btn" onclick="copyCode(this)"><i class="fa-regular fa-copy"></i> Copy</button><pre><code># Forward host port 8080 to container port 80
--port 8080:80
# Symmetric shorthand (host 8080 -> container 8080)
--port 8080
# Forward host range to container range (must be same size)
--port 1000-2000:1000-2000
# Mix and match with explicit protocols
--port 2222:22/tcp --port 5000-5050:5000-5050/udp
</code></pre></div>
<h3 id="upstream-interface-monitoring">Upstream Interface Monitoring</h3>
<p>On Android, the connection often hops between Wi-Fi and Mobile Data. Droidspaces includes a <strong>Route Monitor</strong> that tracks your declared <code>--upstream</code> interfaces. If your active interface changes (e.g., you walk out of Wi-Fi range), the monitor automatically updates the kernel's policy routing to keep the container connected without a restart.</p>
<hr>
<h2 id="rootfs-image-support">Rootfs Image Support</h2>
<h3 id="why-use-images">Why Use Images?</h3>
<p>Directory-based rootfs setups are simple but have limitations: - File permissions may not be preserved correctly on some filesystems (especially f2fs on Android) - OverlayFS may not be compatible with the underlying filesystem - <strong>Built-in Integrity Checking</strong>: Images can be verified with <code>e2fsck</code> at runtime. - <strong>Portability</strong>: Your entire container is encapsulated in a single <code>.img</code> file. This makes it incredibly easy to back up, share, or travel with across the world. Just copy the file to any device with Droidspaces, and it's ready to boot.</p>
<p>Ext4 images solve these problems. The image file contains a complete ext4 filesystem that's loop-mounted at runtime, providing consistent behavior regardless of the host filesystem.</p>
<h3 id="how-it-works">How It Works</h3>
<p>When you use <code>--rootfs-img</code>:</p>
<ol>
<li><strong>Filesystem check:</strong> Droidspaces runs <code>e2fsck -f -y</code> on the image to ensure integrity
</li>
<li><strong>SELinux context:</strong> On Android, applies the <code>vold_data_file</code> SELinux context to prevent silent I/O denials
</li>
<li><strong>Loop mount:</strong> The image is mounted at <code>/mnt/Droidspaces/<name></code>
</li>
<li><strong>Retry logic:</strong> On kernel 4.14, mounts may fail due to stale loop device state. Droidspaces retries up to 3 times with <code>sync()</code> and settle delays.
</li>
</ol>
<h3 id="usage">Usage</h3>
<div class="code-block"><button class="copy-btn" onclick="copyCode(this)"><i class="fa-regular fa-copy"></i> Copy</button><pre><code># Image-based container (--name is mandatory)
droidspaces --name=ubuntu --rootfs-img=/path/to/rootfs.img start
# Volatile mode with image (image mounted read-only)
droidspaces --name=ubuntu --rootfs-img=/path/to/rootfs.img --volatile start
</code></pre></div>
<hr>
<h2 id="cgroup-isolation">Cgroup Isolation</h2>
<h3 id="what-it-does">What It Does</h3>
<p>Droidspaces creates per-container cgroup trees at <code>/sys/fs/cgroup/droidspaces/<name></code> on the host. Combined with the cgroup namespace, each container sees its own clean cgroup hierarchy.</p>
<p><strong>Note:</strong> Cgroup isolation is not available in <code>--force-cgroupv1</code> mode.</p>
<h3 id="why-it-matters">Why It Matters</h3>
<p>systemd relies heavily on cgroups for: - Creating service scopes and slices - Resource accounting (CPU, memory per service) - Process tracking (knowing which processes belong to which service) - Clean shutdown (killing all processes in a service's cgroup)</p>
<p>Without proper cgroup isolation, systemd cannot function. Multiple containers would collide in the cgroup hierarchy, and service management would fail.</p>
<h3 id="the-jail-trick">The "Jail" Trick</h3>
<p>Before creating the cgroup namespace, Droidspaces moves the monitor process into the container-specific cgroup. This ensures that when <code>unshare(CLONE_NEWCGROUP)</code> is called, the new namespace's root maps to the container's subtree.</p>
<h3 id="cgroup-v1-and-v2-support">Cgroup v1 and v2 Support</h3>
<p>Droidspaces supports both cgroup versions:</p>
<ul>
<li><strong>Cgroup v2 (unified):</strong> Used by modern distributions. Mounted as a single hierarchy.
</li>
<li><strong>Cgroup v1 (legacy):</strong> Used by older distributions. Droidspaces handles comounted controllers (e.g., <code>cpu,cpuacct</code>) and creates symlinks for secondary names in older kernels or <code>--force-cgroupv1</code> mode.
</li>
</ul>
<h3 id="forcing-legacy-cgroup-v1-force-cgroupv1">Forcing Legacy Cgroup V1 (<code>--force-cgroupv1</code>)</h3>
<p>On legacy Android kernels (3.18, 4.4, or 4.9), the host system may either lack Cgroup v2 support entirely or provide a partial implementation without the essential controllers (CPU, memory, etc.) required by modern <code>systemd</code>. This inconsistency often causes <code>systemd</code> to misidentify the environment, leading to critical boot failures.</p>
<p>The <code>--force-cgroupv1</code> flag acts as an <strong>expert escape hatch</strong>. It instructs Droidspaces to strictly utilize the legacy v1 hierarchy even if v2 appears available on the host. This ensures maximum stability and compatibility for distributions using modern <code>systemd</code> versions on older kernel infrastructure.</p>
<h3 id="the-su-fix">The <code>su</code> Fix</h3>
<p>When entering a container with <code>enter</code> or <code>run</code>, the process must be in the container's host-side cgroup before joining namespaces. Otherwise, <code>systemd-logind</code> and <code>sd-pam</code> inside the container cannot map the process to a valid session, causing <code>su</code> and <code>sudo</code> to hang. Droidspaces handles this automatically by attaching to the container's cgroup before any <code>setns()</code> call.</p>
<hr>
<h2 id="adaptive-security-deadlock-shield">Adaptive Security & Deadlock Shield</h2>
<p>Droidspaces includes sophisticated BPF-based seccomp filters to resolve critical Android kernel conflicts:</p>
<h3 id="1-fbe-keyring-conflict-automatic">1. FBE Keyring Conflict (Automatic)</h3>
<p>Android's File-Based Encryption stores filesystem keys in the kernel's session keyring. When systemd attempts to create new session keyrings, the process loses access to the host's encryption keys, causing <code>ENOKEY</code> errors.</p>
<p><strong>Solution:</strong> On legacy kernels (< 5.0), Droidspaces <em>automatically</em> intercepts keyring syscalls (<code>keyctl</code>, <code>add_key</code>, <code>request_key</code>) returning <code>ENOSYS</code>, forcing systemd to use the existing keyring.</p>
<a id="vfs-deadlock"></a>
<h3 id="2-vfs-namespace-deadlock-manual-opt-in">2. VFS Namespace Deadlock (Manual Opt-in)</h3>
<p>On certain devices with legacy kernels (notably 4.14.113, common on 2019-2020 Android devices), systemd's service sandboxing triggers a race condition in the kernel's VFS layer (<code>grab_super()</code> bug). This causes systemd to hang, <code>systemctl</code> to freeze, and potential device lockups. 4.9 and 4.19 kernels are largely unaffected.</p>
<p><strong>The Fix:</strong> You can manually enable the <strong>Deadlock Shield</strong> (in the Android App config or via <code>--block-nested-namespaces</code> CLI). This intercepts <code>unshare</code> and <code>clone</code> namespace requests with <code>EPERM</code>, preventing systemd from triggering the deadlock.</p>
<h3 id="nested-containers-docker-podman-lxc">Nested Containers (Docker, Podman, LXC)</h3>
<p>Because the Deadlock Shield is now strictly an <strong>opt-in toggle</strong> rather than a hard-coded blanket ban: - <strong>Native Support:</strong> Users on all kernels can now run Docker, Podman, and LXC natively out-of-the-box. - <strong>The Trade-off:</strong> If your device requires the Deadlock Shield to boot systemd, enabling it will intentionally block the namespace creations required by Docker/Podman.</p>
<div class="callout callout-tip"><strong class="callout-title">TIP</strong> <strong>Legacy Kernel Networking:</strong> When running Docker/Podman inside Droidspaces on legacy kernels, modern <code>nftables</code> may fail to route traffic. We recommend using Droidspaces' NAT mode and switching your container's networking stack to <code>iptables-legacy</code> and <code>ip6tables-legacy</code>.</div>
<hr>
<h2 id="android-specific-tuning">Android-Specific Tuning</h2>
<p>To handle the "opinionated" nature of the Android Linux kernel and ensure container stability, network connectivity, and hardware access, several adjustments must be applied to the container's rootfs.</p>
<div class="callout callout-note"><strong class="callout-title">NOTE</strong> The Droidspaces backend itself does not alter the rootfs. These changes are applied automatically when the user installs a new rootfs tarball using the Android App's built-in installer, or are pre-baked when using our official rootfs tarball from the <a href="https://github.com/Droidspaces/Droidspaces-rootfs-builder" rel="noopener noreferrer">Droidspaces rootfs-builder</a>.</div>
<h3 id="1-android-network-hardware-groups">1. Android Network & Hardware Groups</h3>
<p>Older Android kernels restrict network socket creation and direct hardware access to specific, hardcoded Group IDs (GIDs). Droidspaces maps and configures these groups inside the container's rootfs:</p>
<ul>
<li><strong>GID Mapping</strong>: Appends Android-specific groups to <code>/etc/group</code>:
<ul>
<li><code>aid_inet</code> (3003): Allows internet access.
</li>
<li><code>aid_net_raw</code> (3004): Allows raw socket creation (e.g., for <code>ping</code>).
</li>
<li><code>aid_net_admin</code> (3005): Allows network administration.
</li>
</ul>
</li>
<li><strong>Permissions Assignment</strong>: Adds the container's <code>root</code> user to the <code>aid_inet</code>, <code>aid_net_raw</code>, <code>input</code>, <code>video</code>, and <code>tty</code> groups.
</li>
<li><strong>Package Manager Fix</strong>: Configures the Debian/Ubuntu <code>_apt</code> user to use <code>aid_inet</code> as its primary group, allowing packages to be installed and updated without permission errors.
</li>
<li><strong>User Automation</strong>: Modifies <code>/etc/adduser.conf</code> so any newly created user automatically inherits these groups.
</li>
</ul>
<h3 id="2-udev-trigger-service-overrides">2. Udev Trigger & Service Overrides</h3>
<p>Standard Linux distributions run <code>udevadm trigger</code> to coldplug hardware devices during boot. Triggering all subsystems simultaneously on an Android device can cause the kernel to panic.</p>
<ul>
<li><strong>Hardware Access Guards</strong>: Since udev services are only useful when hardware access is explicitly enabled, Droidspaces injects a drop-in <code>ExecCondition</code> override that prevents <code>systemd-udevd.service</code>, <code>systemd-udev-trigger.service</code>, and <code>systemd-udev-settle.service</code> from starting unless the container is configured with hardware access (<code>enable_hw_access=1</code>):
<div class="code-block"><button class="copy-btn" onclick="copyCode(this)"><i class="fa-regular fa-copy"></i> Copy</button><pre><code>[Service]
ExecCondition=
ExecCondition=/bin/sh -c "grep -q 'enable_hw_access=1' /run/droidspaces/container.config"
</code></pre></div>
</li>
<li><strong>Safe Udev Trigger</strong>: Instead of scanning everything, Droidspaces overrides the default <code>systemd-udev-trigger.service</code> using a drop-in configuration. If hardware access is enabled, this limits the trigger to a strictly defined, safe subset of subsystems:
<div class="code-block"><button class="copy-btn" onclick="copyCode(this)"><i class="fa-regular fa-copy"></i> Copy</button><pre><code>[Service]
ExecStart=
ExecStart=-/usr/bin/udevadm trigger --subsystem-match=usb --subsystem-match=block --subsystem-match=input --subsystem-match=tty --subsystem-match=net
</code></pre></div>
<p>This allows the container to dynamically detect new USB drives, keyboards, and network interfaces without risking a host crash.</p>
</li>
<li><strong>Read-Only Path Fix</strong>: Overrides <code>ConditionPathIsReadWrite</code> for all udev units to prevent failures in environments where key system directories are mounted read-only.
</li>
</ul>
<h3 id="3-optimizing-systemd-logging">3. Optimizing systemd & Logging</h3>
<p>The Android kernel is notoriously verbose. Without tuning, standard <code>journald</code> setups would read host kernel messages and generate gigabytes of logs, quickly filling up the device's internal storage:</p>
<ul>
<li><strong>Journald Adjustments</strong>: Disables reading kernel messages and system auditing (<code>ReadKMsg=no</code>, <code>Audit=no</code>) in <code>journald.conf</code> to prevent the container from hoarding system-wide kernel logs.
</li>
<li><strong>Volatile Storage</strong>: Configures systemd journal logs to store in-memory only (<code>Storage=volatile</code>) and enforces strict maximum size constraints (200MB) to prevent constant writes from wearing out and filling the device's physical internal flash storage.
</li>
<li><strong>Service Masking</strong>: Masks <code>systemd-networkd-wait-online.service</code> to prevent boot delays, and <code>systemd-journald-audit.socket</code> to prevent systemd deadlocks in old kernels like 4.9.
</li>
<li><strong>Power Key Handling</strong>: Instructs <code>systemd-logind</code> to ignore host power and suspend key events so the container does not attempt to handle host power state transitions.
</li>
</ul>
<h3 id="4-nat-mode-network-guards">4. NAT Mode Network Guards</h3>
<p>Under Host networking mode, running network managers like <code>NetworkManager</code> or <code>systemd-networkd</code> inside the container can conflict with the Android host's routing tables and break cellular/Wi-Fi connectivity.</p>
<p>Droidspaces injects a drop-in <code>ExecCondition</code> override for standard network services (such as <code>NetworkManager.service</code>, <code>systemd-networkd.service</code>, <code>dhcpcd.service</code>, and <code>systemd-resolved.service</code>). This ensures these services only execute if the container is explicitly configured in NAT mode:</p>
<div class="code-block"><button class="copy-btn" onclick="copyCode(this)"><i class="fa-regular fa-copy"></i> Copy</button><pre><code>[Service]
ExecCondition=
ExecCondition=/bin/sh -c "grep -q 'net_mode=nat' /run/droidspaces/container.config"
</code></pre></div>
<h3 id="5-storage-and-dhcp-configuration">5. Storage and DHCP Configuration</h3>
<ul>
<li><strong>systemd-networkd Config</strong>: Automatically configures <code>10-eth-dhcp.network</code> to enable DHCP and IPv6 route acceptance for any <code>eth*</code> interfaces.
</li>
<li><strong>Logrotate Limit</strong>: Enforces a <code>maxsize 50M</code> limit in <code>/etc/logrotate.conf</code> to prevent logs from consuming excessive disk space over time.
</li>
</ul>
<div class="doc-nav-buttons"><a href="installation-linux.html" class="doc-nav-btn doc-nav-prev">← Linux Installation</a><a href="gpu-acceleration.html" class="doc-nav-btn doc-nav-next">GPU Acceleration →</a></div>
<p class="doc-copyright">© 2026 Droidspaces · <a href="https://github.com/ravindu644/Droidspaces-OSS/blob/main/LICENSE" rel="noopener noreferrer">GPLv3</a> · by <a href="https://github.com/ravindu644" rel="noopener noreferrer">ravindu644</a> and <a href="https://github.com/ravindu644/Droidspaces-OSS/graphs/contributors" rel="noopener noreferrer">contributors</a>
</p>
</div>
</div>
<script>
(() => {
const themeToggle = document.getElementById('theme-toggle');
const sunIcon = themeToggle.querySelector('.sun-icon');
const moonIcon = themeToggle.querySelector('.moon-icon');
const mediaQuery = window.matchMedia('(prefers-color-scheme: light)');
function updateIcons(theme) {
sunIcon.style.display = theme === 'light' ? 'none' : 'block';
moonIcon.style.display = theme === 'light' ? 'block' : 'none';
}
function getEffectiveTheme() {
const saved = localStorage.getItem('theme');
if (saved) return saved;
return mediaQuery.matches ? 'light' : 'dark';
}
function applyTheme(theme) {
if (theme === 'system') {
document.documentElement.removeAttribute('data-theme');
updateIcons(mediaQuery.matches ? 'light' : 'dark');
} else {
document.documentElement.setAttribute('data-theme', theme);
updateIcons(theme);
}
}
applyTheme(getEffectiveTheme());
mediaQuery.addEventListener('change', (e) => {
if (!localStorage.getItem('theme')) applyTheme(e.matches ? 'light' : 'dark');
});
themeToggle.addEventListener('click', () => {
const currentTheme = getEffectiveTheme();
const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
localStorage.setItem('theme', newTheme);
applyTheme(newTheme);
});
// Docs sidebar toggle
const sidebarToggle = document.getElementById('sidebar-toggle');
const sidebar = document.getElementById('sidebar');
const sidebarOverlay = document.getElementById('sidebar-overlay');
function openSidebar() {
sidebar.classList.add('open');
sidebarOverlay.classList.add('active');
document.body.style.overflow = 'hidden';
}
function closeSidebar() {
sidebar.classList.remove('open');
sidebarOverlay.classList.remove('active');
document.body.style.overflow = '';
}
if (sidebarToggle) {
sidebarToggle.addEventListener('click', (e) => {
e.stopPropagation();
if (sidebar.classList.contains('open')) closeSidebar();
else openSidebar();
});
}
if (sidebarOverlay) {
sidebarOverlay.addEventListener('click', closeSidebar);
}
const sidebarClose = document.getElementById('sidebar-close');
if (sidebarClose) {
sidebarClose.addEventListener('click', closeSidebar);
}
if (sidebar) {
sidebar.querySelectorAll('a').forEach(link => {
link.addEventListener('click', closeSidebar);
});
}
})();
function copyCode(btn) {
const code = btn.parentElement.querySelector('pre code');
const text = code.textContent;
navigator.clipboard.writeText(text).then(() => {
const orig = btn.innerHTML;
btn.innerHTML = '<i class="fas fa-check"></i> Copied!';
setTimeout(() => { btn.innerHTML = orig; }, 1500);
}).catch(() => {});
}
</script>
</body>
</html>