aboutsummaryrefslogtreecommitdiff
path: root/en_US.ISO8859-1/books/handbook/linuxemu/chapter.sgml
blob: 6eb6cd08d1fe9e0cd248f0bbc9351bb924c55142 (plain) (blame)
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
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
<!--
     The FreeBSD Documentation Project

     $FreeBSD: doc/en_US.ISO8859-1/books/handbook/linuxemu/chapter.sgml,v 1.55 2001/10/08 01:54:11 murray Exp $
-->

<chapter id="linuxemu">
  <chapterinfo>
    <authorgroup>
      <author>
	<firstname>Jim</firstname>
	<surname>Mock</surname>
	<contrib>Restructured and parts updated by </contrib>
      </author>
      <!-- 22 Mar 2000 -->
    </authorgroup>
    <authorgroup>
      <author>
	<firstname>Brian N.</firstname>
	<surname>Handy</surname>
	<contrib>Originally contributed by </contrib>
      </author>
      <author>
	<firstname>Rich</firstname>
	<surname>Murphey</surname>
      </author>
    </authorgroup>
  </chapterinfo>

  <title>Linux Binary Compatibility</title>

  <sect1>
    <title>Synopsis</title>
    <indexterm><primary>Linux binary compatibility</primary></indexterm>
    <indexterm>
      <primary>binary compatibility</primary>
      <secondary>Linux</secondary>
    </indexterm>

    <para>FreeBSD provides binary compatibility with several other
      Unix-like operating systems, including Linux.  At this point,
      you may be asking yourself why exactly, does
      FreeBSD need to be able to run Linux binaries?  The answer to that
      question is quite simple.  Many companies and developers develop
      only for Linux, since it is the latest <quote>hot thing</quote> in
      the computing world.  That leaves the rest of us FreeBSD users
      bugging these same companies and developers to put out native
      FreeBSD versions of their applications.  The problem is, that most
      of these companies do not really realize how many people would use
      their product if there were FreeBSD versions too, and most continue
      to only develop for Linux.  So what is a FreeBSD user to do?  This
      is where the Linux binary compatibility of FreeBSD comes into
      play.</para>

    <para>In a nutshell, the compatibility allows FreeBSD users to run
      about 90% of all Linux applications without modification.  This
      includes applications such as <application>Star Office</application>, 
      the Linux version of <application>Netscape</application>, 
      <application>Adobe Acrobat</application>, 
      <application>RealPlayer</application>
      5 and 7, <application>VMWare</application>, 
      <application>Oracle</application>,
      <application>WordPerfect</application>, <application>Doom</application>, 
      <application>Quake</application>, and more.  It is also reported
      that in some situations, Linux binaries perform better on FreeBSD 
      than they do under Linux.</para>
    <indexterm>
      <primary>Linux</primary>
      <secondary><filename>/proc</filename> filesystem</secondary>
    </indexterm>

    <para>There are, however, some Linux-specific operating system
      features that are not supported under FreeBSD.  Linux binaries will
      not work on FreeBSD if they overly use the Linux
      <filename>/proc</filename> filesystem (which is different from
      FreeBSD's <filename>/proc</filename> filesystem), or i386-specific
      calls, such as enabling virtual 8086 mode.</para>

    <para>After reading this chapter, you will know:</para>
    <itemizedlist>
      <listitem><para>How to enable Linux binary compatibility on your
        system.</para></listitem>
      <listitem><para>How to install additional Linux shared
        libraries.</para></listitem>
      <listitem><para>How to install Linux applications on your
        FreeBSD system.</para></listitem>
      <listitem><para>The implementation details of Linux
        compatibility in FreeBSD.</para></listitem>
    </itemizedlist>

    <para>Before reading this chapter, you should:</para>

    <itemizedlist>
      <listitem><para>Know how to install additional third-party
        software (<xref linkend="ports">).</para></listitem>
    </itemizedlist>

  </sect1>

  <sect1 id="linuxemu-lbc-install">
    <title>Installation</title>

    <indexterm><primary>KLD (kernel loadable object)</primary></indexterm>

    <para>Linux binary compatibility is not turned on by default.  The
      easiest way to enable this functionality is to load the
      <literal>linux</literal> KLD object (<quote>Kernel LoaDable
      object</quote>).  You can load this module by simply typing
      <command>linux</command> at the command prompt.</para>

    <para>If you would like Linux compatibility to always be enabled,
      then you should add the following line to
      <filename>/etc/rc.conf</filename>:</para>

    <programlisting>linux_enable=<quote>YES</quote></programlisting>

    <para>This, in turn, triggers the following action in
      <filename>/etc/rc.i386</filename>:</para>

    <programlisting># Start the Linux binary compatibility if requested.
#
case ${linux_enable} in
[Yy][Ee][Ss])
	echo -n ' linux';	linux &gt; /dev/null 2&gt;&amp;1
	;;
esac</programlisting>

    <para>The &man.kldstat.8; command can be used to verify that the
      KLD is loaded:</para>

    <screen>&prompt.user; <userinput>kldstat</userinput>
Id Refs Address    Size     Name
 1    2 0xc0100000 16bdb8   kernel
 7    1 0xc24db000 d000     linux.ko</screen>
    <indexterm>
      <primary>kernel options</primary>
      <secondary>LINUX</secondary>
    </indexterm>

    <para>If for some reason you do not want to or cannot load the KLD,
      then you may statically link Linux binary compatibility into the kernel
      by adding <literal>options LINUX</literal> to your kernel
      configuration file.  Then install your new kernel as described in
      <xref linkend="kernelconfig">.</para>
    
    <sect2>
      <title>Installing Linux Runtime Libraries</title>
      <indexterm>
        <primary>Linux</primary>
	<secondary>installing Linux libraries</secondary>
      </indexterm>

      <para>This can be done one of two ways, either by using the
        <link linkend="linuxemu-libs-port">linux_base</link> port, or
        by installing them <link
        linkend="linuxemu-libs-manually">manually</link>.</para>

      <sect3 id="linuxemu-libs-port">
	<title>Installing Using the linux_base Port</title>
	<indexterm><primary>ports collection</primary></indexterm>

	<para>This is by far the easiest method to use when installing the
	  runtime libraries.  It is just like installing any other port
	  from the <ulink url="/usr/ports/">ports collection</ulink>.
	  Simply do the following:</para>

	<screen>&prompt.root; <userinput>cd /usr/ports/emulators/linux_base</userinput>
&prompt.root; <userinput>make install distclean</userinput></screen>

	<para>You should now have working Linux binary compatibility.
	  Some programs may complain about incorrect minor versions of the
	  system libraries.  In general, however, this does not seem to be
	  a problem.</para>
      </sect3>

      <sect3 id="linuxemu-libs-manually">
	<title>Installing Libraries Manually</title>

	<para>If you do not have the <quote>ports</quote> collection
	  installed, you can install the libraries by hand instead.  You
	  will need the Linux shared libraries that the program depends on
	  and the runtime linker.  Also, you will need to create a
	  <quote>shadow root</quote> directory,
	  <filename>/compat/linux</filename>, for Linux libraries on your
	  FreeBSD system.  Any shared libraries opened by Linux programs
	  run under FreeBSD will look in this tree first.  So, if a Linux
	  program loads, for example, <filename>/lib/libc.so</filename>,
	  FreeBSD will first try to open
	  <filename>/compat/linux/lib/libc.so</filename>, and if that does
	  not exist, it will then try <filename>/lib/libc.so</filename>.
	  Shared libraries should be installed in the shadow tree
	  <filename>/compat/linux/lib</filename> rather than the paths
	  that the Linux <command>ld.so</command> reports.</para>

	<para>Generally, you will need to look for the shared libraries
	  that Linux binaries depend on only the first few times that you
	  install a Linux program on your FreeBSD system.  After a while,
	  you will have a sufficient set of Linux shared libraries on your
	  system to be able to run newly imported Linux binaries without
	  any extra work.</para>
      </sect3>

      <sect3>
	<title>How to Install Additional Shared Libraries</title>
	<indexterm><primary>shared libraries</primary></indexterm>

	<para>What if you install the <filename>linux_base</filename> port
	  and your application still complains about missing shared
	  libraries?  How do you know which shared libraries Linux
	  binaries need, and where to get them?  Basically, there are 2
	  possibilities (when following these instructions you will need
	  to be root on your FreeBSD system).</para>

	<para>If you have access to a Linux system, see what shared
	  libraries the application needs, and copy them to your FreeBSD
	  system.  Look at the following example:</para>
	  
	<informalexample>
	  <para>Let us assume you used FTP to get the Linux binary of
	    Doom, and put it on a Linux system you have access to.  You
	    then can check which shared libraries it needs by running
	    <command>ldd linuxdoom</command>, like so:</para>

	  <screen>&prompt.user; <userinput>ldd linuxdoom</userinput>
libXt.so.3 (DLL Jump 3.1) =&gt; /usr/X11/lib/libXt.so.3.1.0
libX11.so.3 (DLL Jump 3.1) =&gt; /usr/X11/lib/libX11.so.3.1.0
libc.so.4 (DLL Jump 4.5pl26) =&gt; /lib/libc.so.4.6.29</screen>

	  <indexterm><primary>symbolic links</primary></indexterm>
	  <para>You would need to get all the files from the last column,
	    and put them under <filename>/compat/linux</filename>, with
	    the names in the first column as symbolic links pointing to
	    them.  This means you eventually have these files on your
	    FreeBSD system:</para>

	  <screen>/compat/linux/usr/X11/lib/libXt.so.3.1.0
/compat/linux/usr/X11/lib/libXt.so.3 -&gt; libXt.so.3.1.0
/compat/linux/usr/X11/lib/libX11.so.3.1.0
/compat/linux/usr/X11/lib/libX11.so.3 -&gt; libX11.so.3.1.0
/compat/linux/lib/libc.so.4.6.29 /compat/linux/lib/libc.so.4 -&gt; libc.so.4.6.29</screen>

	  <blockquote>
	    <note>
	      <para>Note that if you already have a Linux shared library
		with a matching major revision number to the first column
		of the <command>ldd</command> output, you will not need to
		copy the file named in the last column to your system, the
		one you already have should work.  It is advisable to copy
		the shared library anyway if it is a newer version,
		though.  You can remove the old one, as long as you make
		the symbolic link point to the new one.  So, if you have
		these libraries on your system:</para>

	      <screen>/compat/linux/lib/libc.so.4.6.27
/compat/linux/lib/libc.so.4 -&gt; libc.so.4.6.27</screen>

	      <para>and you find a new binary that claims to require a
		later version according to the output of
		<command>ldd</command>:</para>

	      <screen>libc.so.4 (DLL Jump 4.5pl26) -&gt; libc.so.4.6.29</screen>

	      <para>If it is only one or two versions out of date in the
		in the trailing digit then do not worry about copying
		<filename>/lib/libc.so.4.6.29</filename> too, because the
		program should work fine with the slightly older version.
		However, if you like, you can decide to replace the
		<filename>libc.so</filename> anyway, and that should leave
		you with:</para>

	      <screen>/compat/linux/lib/libc.so.4.6.29
/compat/linux/lib/libc.so.4 -&gt; libc.so.4.6.29</screen>
	    </note>
	  </blockquote>

	  <blockquote>
	    <note>
	      <para>The symbolic link mechanism is
		<emphasis>only</emphasis> needed for Linux binaries.  The
		FreeBSD runtime linker takes care of looking for matching
		major revision numbers itself and you do not need to worry
		about it.</para>
	    </note>
	  </blockquote>
	</informalexample>
      </sect3>
    </sect2>

    <sect2>
      <title>Installing Linux ELF Binaries</title>
      <indexterm>
        <primary>Linux</primary>
	<secondary>ELF binaries</secondary>
      </indexterm>

      <para>ELF binaries sometimes require an extra step of
	<quote>branding</quote>.  If you attempt to run an unbranded ELF
	binary, you will get an error message like the following;</para>

      <screen>&prompt.user; <userinput>./my-linux-elf-binary</userinput>
ELF binary type not known
Abort</screen>

      <para>To help the FreeBSD kernel distinguish between a FreeBSD ELF
	binary from a Linux binary, use the &man.brandelf.1;
	utility.</para>

      <screen>&prompt.user; <userinput>brandelf -t Linux my-linux-elf-binary</userinput></screen>

      <indexterm><primary>GNU toolchain</primary></indexterm>
      <para>The GNU toolchain now places the appropriate branding
	information into ELF binaries automatically, so you this step
	should become increasingly more rare in the future.</para>
    </sect2>

    <sect2>
      <title>Configuring the Hostname Resolver</title>

      <para>If DNS does not work or you get this message:</para>

      <screen>resolv+: "bind" is an invalid keyword resolv+:
"hosts" is an invalid keyword</screen>

      <para>You will need to configure a
	<filename>/compat/linux/etc/host.conf</filename> file
	containing:</para>

      <programlisting>order hosts, bind
multi on</programlisting>
	  
      <para>The order here specifies that <filename>/etc/hosts</filename>
	is searched first and DNS is searched second.  When
	<filename>/compat/linux/etc/host.conf</filename> is not
	installed, Linux applications find FreeBSD's
	<filename>/etc/host.conf</filename> and complain about the
	incompatible FreeBSD syntax.  You should remove
	<literal>bind</literal> if you have not configured a name server
	using the <filename>/etc/resolv.conf</filename> file.</para>
    </sect2>
  </sect1>

  <sect1 id="linuxemu-mathematicau">
    <title>Installing Mathematica</title>

    <para><emphasis>Updated for <application>Mathematica</application>
      version 4.X by &a.murray
      and merged with work by Bojan Bistrovic
      <email>bojanb@physics.odu.edu</email>.</emphasis></para>
    <indexterm>
      <primary>applications</primary>
      <secondary><application>Mathematica</application></secondary>
    </indexterm>

    <para>This document describes the process of installing the Linux
      version of <application>Mathematica 4.X</application> onto
      a FreeBSD system.</para>

    <para>The Linux version of <application>Mathematica</application>
      runs perfectly under FreeBSD
      however the binaries shipped by Wolfram need to be branded so that
      FreeBSD knows to use the Linux ABI to execute them.</para>

    <para>The Linux version of <application>Mathematica</application>
      or <application>Mathematica for Students</application> can
      be ordered directly from Wolfram at <ulink
      url="http://www.wolfram.com/">http://www.wolfram.com/</ulink>.</para>

    <sect2>
      <title>Branding the Linux Binaries</title>

      <para>The Linux binaries are located in the <filename>Unix</filename>
	directory of the <application>Mathematica</application> CDROM 
	distributed by Wolfram.  You
	need to copy this directory tree to your local hard drive so that
	you can brand the Linux binaries with &man.brandelf.1; before
	running the installer:</para>

      <screen>&prompt.root; <userinput>mount /cdrom</userinput>
&prompt.root; <userinput>cp -rp /cdrom/Unix/ /localdir/</userinput>
&prompt.root; <userinput>brandelf -t Linux /localdir/Files/SystemFiles/Kernel/Binaries/Linux/*</userinput>
&prompt.root; <userinput>brandelf -t Linux /localdir/Files/SystemFiles/FrontEnd/Binaries/Linux/*</userinput>
&prompt.root; <userinput>brandelf -t Linux /localdir/Files/SystemFiles/Installation/Binaries/Linux/*</userinput>
&prompt.root; <userinput>brandelf -t Linux /localdir/Files/SystemFiles/Graphics/Binaries/Linux/*</userinput>
&prompt.root; <userinput>brandelf -t Linux /localdir/Files/SystemFiles/Converters/Binaries/Linux/*</userinput>
&prompt.root; <userinput>brandelf -t Linux /localdir/Files/SystemFiles/LicenseManager/Binaries/Linux/mathlm</userinput>
&prompt.root; <userinput>cd /localdir/Installers/Linux/</userinput>
&prompt.root; <userinput>./MathInstaller</userinput></screen>

       <para>Alternatively, you can simply set the default ELF brand
         to Linux for all unbranded binaries with the command:</para>
       <screen>&prompt.root; <userinput>sysctl -w kern.fallback_elf_brand=3</userinput></screen>
       <para>This will make FreeBSD assume that unbranded ELF binaries
         use the Linux ABI and so you should be able to run the
         installer straight from the CDROM.</para>
    </sect2>

    <sect2>
      <title>Obtaining Your Mathematica Password</title>

      <para>Before you can run <application>Mathematica</application>
	you will have to obtain a
	password from Wolfram that corresponds to your <quote>machine
	ID</quote>.</para>
      <indexterm>
        <primary>Ethernet</primary>
        <secondary>MAC address</secondary>
      </indexterm>

      <para>Once you have installed the Linux compatibility runtime
	libraries and unpacked <application>Mathematica</application>
	you can obtain the
	<quote>machine ID</quote> by running the program
	<command>mathinfo</command> in the Install directory.  This
	machine ID is based solely on the MAC address of your first
	Ethernet card.</para>

      <screen>&prompt.root; <userinput>cd /localdir/Files/SystemFiles/Installation/Binaries/Linux</userinput>
&prompt.root; <userinput>mathinfo</userinput>
disco.example.com 7115-70839-20412</screen>

      <para>When you register with Wolfram, either by email, phone or fax,
	you will give them the <quote>machine ID</quote> and they will
	respond with a corresponding password consisting of groups of
	numbers.  You can then enter this information when you attempt to
	run <application>Mathematica</application> for the first time
	exactly as you would for any other 
	<application>Mathematica</application> platform.</para>
    </sect2>

    <sect2>
      <title>Running the Mathematica Frontend over a Network</title>

      <para><application>Mathematica</application> uses some special 
	fonts to display characters not
	present in any of the standard font sets (integrals, sums, Greek
	letters, etc.).  The X protocol requires these fonts to be install
	<emphasis>locally</emphasis>.  This means you will have to copy
	these fonts from the CDROM or from a host with 
	<application>Mathematica</application>
	installed to your local machine.  These fonts are normally stored
	in <filename>/cdrom/Unix/Files/SystemFiles/Fonts</filename> on the
	CDROM, or
	<filename>/usr/local/mathematica/SystemFiles/Fonts</filename> on
	your hard drive.  The actual fonts are in the subdirectories
	<filename>Type1</filename> and <filename>X</filename>.  There are
	several ways to use them, as described below.</para>

      <para>The first way is to copy them into one of the existing font
	directories in <filename>/usr/X11R6/lib/X11/fonts</filename>.
	This will require editing the <filename>fonts.dir</filename> file,
	adding the font names to it, and changing the number of fonts on
	the first line.  Alternatively, you should also just be able to
	run <command>mkfontdir</command> in the directory you have copied
	them to.</para>

      <para>The second way to do this is to copy the directories to
	<filename>/usr/X11R6/lib/X11/fonts</filename>:</para>

      <screen>&prompt.root; <userinput>cd /usr/X11R6/lib/X11/fonts</userinput>
&prompt.root; <userinput>mkdir X</userinput>
&prompt.root; <userinput>mkdir MathType1</userinput>
&prompt.root; <userinput>cd /cdrom/Unix/Files/SystemFiles/Fonts</userinput>
&prompt.root; <userinput>cp X/* /usr/X11R6/lib/X11/fonts/X</userinput>
&prompt.root; <userinput>cp Type1/* /usr/X11R6/lib/X11/fonts/MathType1</userinput>
&prompt.root; <userinput>cd /usr/X11R6/lib/X11/fonts/X</userinput>
&prompt.root; <userinput>mkfontdir</userinput>
&prompt.root; <userinput>cd ../MathType1</userinput>
&prompt.root; <userinput>mkfontdir</userinput</screen>

      <para>Now add the new font directories to your font path:</para>

      <screen>&prompt.root; <userinput>xset fp+ /usr/X11R6/lib/X11/fonts/X</userinput>
&prompt.root; <userinput>xset fp+ /usr/X11R6/lib/X11/fonts/MathType1</userinput>
&prompt.root; <userinput>xset fp rehash</userinput></screen>

      <para>If you are using the XFree86 server, you can have these font
	directories loaded automatically by adding them to your
	<filename>XF86Config</filename> file.</para>
      <indexterm><primary>fonts</primary></indexterm>

      <para>If you <emphasis>do not</emphasis> already have a directory
	called <filename>/usr/X11R6/lib/X11/fonts/Type1</filename>, you
	can change the name of the <filename>MathType1</filename>
	directory in the example above to
	<filename>Type1</filename>.</para>
    </sect2>
  </sect1>

  <sect1 id="linuxemu-maple">
    <sect1info>
      <authorgroup>
	<author>
	  <firstname>Aaron</firstname>
	  <surname>Kaplan</surname>
<!--	  <address><email>aaron@lo-res.org</email></address>-->
	  <contrib>Contributed by </contrib>
	</author>
      </authorgroup>
      <authorgroup>
	<author>
	  <firstname>Robert</firstname>
	  <surname>Getschmann</surname>
<!--	  <address><email>rob@getschmann.org</email></address>-->
	  <contrib>Thanks to </contrib>
	</author>
      </authorgroup>
    </sect1info>
    <title>Installing Maple</title>

    <indexterm>
      <primary>applications</primary>
      <secondary><application>Maple</application></secondary>
    </indexterm>

    <para>Maple is a commercial mathematics program similar to
      Mathematica.  You must purchase this software from <ulink
      url="http://www.maplesoft.com/"></ulink> and then register there
      for a license file.  To install this software on FreeBSD, please
      follow these simple steps.</para>

      <procedure>
	<step><para>Execute the <filename>INSTALL</filename> shell
	  script from the product distribution.  Choose the
	  <quote>RedHat</quote> option when prompted by the
	  installation program.  A typical installation directory
	  might be <filename
	  class="directory">/usr/local/maple</filename></para></step>

        <step><para>If you have not done so, order a license for Maple
	  from Maple Waterloo Software (http://register.maplesoft.com)
	  and copy it to
	  <filename>/usr/local/maple/license/license.dat</filename></step>

        <step><para>Install the <application>FLEXlm</application>
	  license manager by running the
	  <filename>INSTALL_LIC</filename> install shell script that
	  comes with <application>Maple</application>.  Specify the
	  primary hostname for your machine for the license
	  server.</para>

        <step><para>Patch the
          <filename>usr/local/maple/bin/maple.system.type</filename>
          file with the following :</para>
<programlisting>   ----- snip ------------------
*** maple.system.type.orig      Sun Jul  8 16:35:33 2001
--- maple.system.type   Sun Jul  8 16:35:51 2001
***************
*** 72,77 ****
--- 72,78 ----
          # the IBM RS/6000 AIX case
          MAPLE_BIN="bin.IBM_RISC_UNIX"
          ;;
+     "FreeBSD"|\
      "Linux")
          # the Linux/x86 case
        # We have two Linux implementations, one for Red Hat and
   ----- snip end of patch -----</programlisting>

	<para>Please note that after the "FreeBSD"|\ no other
	  whitespace should be present.</para>

	<para>This patch instructs <application>Maple</application> to
	  recognize <quote>FreeBSD</quote> as a type of Linux system.
	  The <filename>bin/maple</filename> shell script calls the
	  <filename>bin/maple.system.type</filename> shell script
	  which in turn calls uname -a to find out the operating
	  system name. Depending on the OS name it will find out which
	  binaries to use.</para></step>

      <step><para>Start the license server.</para>

	<para>The following script, installed as
	  <filename>/usr/local/etc/rc.d/lmgrd.sh</filename> is a
	  convenient way to start up lmgrd:</para>

	<programlisting>   ----- snip ------------

#! /bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin
PATH=${PATH}:/usr/local/maple/bin:/usr/local/maple/FLEXlm/UNIX/LINUX
export PATH

LICENSE_FILE=/usr/local/maple/license/license.dat
LOG=/var/log/lmgrd.log

case "$1" in
start)
	lmgrd -c ${LICENSE_FILE} 2>> ${LOG} 1>&2
	echo -n " lmgrd"
	;;
stop)
	lmgrd -c ${LICENSE_FILE} -x lmdown 2>> ${LOG} 1>&2
	;;
*)
	echo "Usage: `basename $0` {start|stop}" 1>&2
	exit 64
	;;
esac

exit 0
   ----- snip ------------</programlisting></step>


      <step><para>Test-start maple:</para>
	<screen>&prompt.user; cd /usr/local/maple/bin
&prompt.user ./xmaple</screen>

	<para>You should be up and running. Make sure to write
	  Maplesoft to let them know you would like a native FreeBSD
	  version!</para></step>
    </procedure>

    <sect2>
      <title>Common Pitfalls</title>

      <itemizedlist>
	<listitem><para>The FLEXlm license manager can be a difficult
	  tool to work with.  Additional documentation on the subject
	  can be found at <ulink
	  url="http://www.globetrotter.com/"></ulink>.</para></listitem>

	<listitem><para><command>lmgrd</command> is known to be very picky
	  about the license file and to core dump if there are any
	  problems.  A correct license file should look like this
	  :</para>

<programlisting># =======================================================
# License File for UNIX Installations ("Pointer File")
# =======================================================
SERVER chillig ANY
#USE_SERVER
VENDOR maplelmg

FEATURE Maple maplelmg 2000.0831 permanent 1 XXXXXXXXXXXX \
         PLATFORMS=i86_r ISSUER="Waterloo Maple Inc." \
         ISSUED=11-may-2000 NOTICE=" Technische Universitat Wien" \
         SN=XXXXXXXXX</programlisting>
 
	  <note><para>Serial number and key 'X''ed out. "chillig" is a
	    hostname.</para></note>

  	  <para>Editing the license file works as long as you don't
 	    touch the "FEATURE" line (which is protected by the
 	    license key).</para></listitem>
      </itemizedlist>
    </sect2>
  </sect1>

  <sect1 id="linuxemu-oracle">
    <sect1info>
      <authorgroup>
	<author>
	  <firstname>Marcel</firstname>
	  <surname>Moolenaar</surname>
	  <contrib>Contributed by </contrib>
	</author>
	<!-- marcel@cup.hp.com -->
      </authorgroup>
    </sect1info>
    <title>Installing Oracle</title>

    <indexterm>
      <primary>applications</primary>
      <secondary><application>Oracle</application></secondary>
    </indexterm>

    <sect2>
      <title>Preface</title>
      <para>This document describes the process of installing Oracle 8.0.5 and
	Oracle 8.0.5.1 Enterprise Edition for Linux onto a FreeBSD
	machine</para>
    </sect2>
    
    <sect2>
      <title>Installing the Linux Environment</title>
      
      <para>Make sure you have both <filename>linux_base</filename> and
	<filename>linux_devtools</filename> from the ports collection
	installed.  These ports are added to the collection after the release
	of FreeBSD 3.2.  If you are using FreeBSD 3.2 or an older version for
	that matter, update your ports collection.  You may want to consider
	updating your FreeBSD version too.  If you run into difficulties with
	<filename>linux_base-6.1</filename> or
	<filename>linux_devtools-6.1</filename> you may have to use version
	5.2 of these packages.</para>

      <para>If you want to run the intelligent agent, you will
	also need to install the Red Hat Tcl package:
	<filename>tcl-8.0.3-20.i386.rpm</filename>.  The general command
	for installing packages with the official RPM port is :</para>
      
      <screen>&prompt.root; <userinput>rpm -i --ignoreos --root /compat/linux --dbpath /var/lib/rpm <replaceable>package</replaceable></userinput></screen>

      <para>Installation of the package should not generate any errors.</para>
    </sect2>

    <sect2>
      <title>Creating the Oracle Environment</title>
      
      <para>Before you can install Oracle, you need to set up a proper
	environment.  This document only describes what to do
	<emphasis>specially</emphasis> to run Oracle for Linux on FreeBSD, not
	what has been described in the Oracle installation guide.</para>

      <sect3 id="linuxemu-kernel-tuning">
        <title>Kernel Tuning</title>
	<indexterm><primary>kernel tuning</primary></indexterm>
	
	<para>As described in the Oracle installation guide, you need to set
	  the maximum size of shared memory.  Do not use
	  <literal>SHMMAX</literal> under FreeBSD. <literal>SHMMAX</literal>
	  is merely calculated out of <literal>SHMMAXPGS</literal> and
	  <literal>PGSIZE</literal>.  Therefore define
	  <literal>SHMMAXPGS</literal>.  All other options can be used as
	  described in the guide.  For example:</para>

	<programlisting>options SHMMAXPGS=10000
options SHMMNI=100
options SHMSEG=10
options SEMMNS=200
options SEMMNI=70
options SEMMSL=61</programlisting>
	
        <para>Set these options to suit your intended use of Oracle.</para>

	<para>Also, make sure you have the following options in your kernel
	  config-file:</para>

<programlisting>options SYSVSHM #SysV shared memory
options SYSVSEM #SysV semaphores
options SYSVMSG #SysV interprocess communication</programlisting>
      </sect3>

      <sect3 id="linuxemu-oracle-account">
	
        <title>Oracle Account</title>

	<para>Create an Oracle account just as you would create any other
	  account. The  Oracle account is special only that you need to give
	  it a Linux shell.  Add <literal>/compat/linux/bin/bash</literal> to
	  <filename>/etc/shells</filename> and set the shell for the Oracle
	  account to <filename>/compat/linux/bin/bash</filename>.</para>
      </sect3>

      <sect3 id="linuxemu-environment">
        <title>Environment</title>

	<para>Besides the normal Oracle variables, such as
	  <envar>ORACLE_HOME</envar> and <envar>ORACLE_SID</envar> you must
	  set the following environment variables:</para>

	<informaltable frame="none">
	  <tgroup cols="2">
	    <thead>
	      <row>
		<entry>Variable</entry>

		<entry>Value</entry>
	      </row>
	    </thead>
	    <tbody>
	      <row>
		<entry><envar>LD_LIBRARY_PATH</envar></entry>

		<entry><literal>$ORACLE_HOME/lib</literal></entry>
	      </row>

	      <row>
		<entry><envar>CLASSPATH</envar></entry>

		<entry><literal>$ORACLE_HOME/jdbc/lib/classes111.zip</literal></entry>
	      </row>

	      <row>
		<entry><envar>PATH</envar></entry>

		<entry><literal>/compat/linux/bin
/compat/linux/sbin
/compat/linux/usr/bin
/compat/linux/usr/sbin
/bin
/sbin
/usr/bin
/usr/sbin
/usr/local/bin
$ORACLE_HOME/bin</literal></entry>
	      </row>
	    </tbody>
	  </tgroup>
	</informaltable>

        <para>It is advised to set all the environment variables in
	  <filename>.profile</filename>.  A complete example is:</para>

<programlisting>ORACLE_BASE=/oracle; export ORACLE_BASE
ORACLE_HOME=/oracle; export ORACLE_HOME
LD_LIBRARY_PATH=$ORACLE_HOME/lib
export LD_LIBRARY_PATH
ORACLE_SID=ORCL; export ORACLE_SID
ORACLE_TERM=386x; export ORACLE_TERM
CLASSPATH=$ORACLE_HOME/jdbc/lib/classes111.zip
export CLASSPATH
PATH=/compat/linux/bin:/compat/linux/sbin:/compat/linux/usr/bin:/compat/linux/usr/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:$ORACLE_HOME/bin
export PATH</programlisting>
      </sect3>
    </sect2>

    <sect2>
      <title>Installing Oracle</title> 
      
      <para>Due to a slight inconsistency in the Linux emulator, you need to
	create a directory named <filename>.oracle</filename> in
	<filename>/var/tmp</filename> before you start the installer.  Either
	make it world writable or let it be owner by the oracle user.  You
	should be able to install Oracle without any problems.  If you have
	problems, check your Oracle distribution and/or configuration first!
	After you have installed Oracle, apply the patches described in the
	next two subsections.</para>

      <para>A frequent problem is that the TCP protocol adapter is not
	installed right. As a consequence, you cannot start any TCP listeners.
	The following actions help solve this problem:</para>

      <screen>&prompt.root; <userinput>cd $ORACLE_HOME/network/lib</userinput>
&prompt.root; <userinput>make -f ins_network.mk ntcontab.o</userinput>
&prompt.root; <userinput>cd $ORACLE_HOME/lib</userinput>
&prompt.root; <userinput>ar r libnetwork.a ntcontab.o</userinput>
&prompt.root; <userinput>cd $ORACLE_HOME/network/lib</userinput>
&prompt.root; <userinput>make -f ins_network.mk install</userinput></screen>

      <para>Do not forget to run <filename>root.sh</filename> again!</para>

    <sect3 id="linuxemu-patch-root">
      <title>Patching root.sh</title>
    
	<para>When installing Oracle, some actions, which need to be performed
	  as <username>root</username>, are recorded in a shell script called
	  <filename>root.sh</filename>.  <filename>root.sh</filename> is
	  written in the <filename>orainst</filename> directory.  Apply the
	  following patch to root.sh, to have it use to proper location of
	  <command>chown</command> or alternatively run the script under a 
	  Linux native shell.</para>

	<programlisting>*** orainst/root.sh.orig Tue Oct 6 21:57:33 1998
--- orainst/root.sh Mon Dec 28 15:58:53 1998
***************
*** 31,37 ****
# This is the default value for CHOWN
# It will redefined later in this script for those ports
# which have it conditionally defined in ss_install.h
! CHOWN=/bin/chown
#
# Define variables to be used in this script
--- 31,37 ----
# This is the default value for CHOWN
# It will redefined later in this script for those ports
# which have it conditionally defined in ss_install.h
! CHOWN=/usr/sbin/chown
#
# Define variables to be used in this script</programlisting>

	<para>When you do not install Oracle from CD, you can patch the source
	  for <filename>root.sh</filename>.  It is called
	  <filename>rthd.sh</filename> and is located in the
	  <filename>orainst</filename> directory in the source tree.</para>
      </sect3>

      <sect3 id="linuxemu-patch-tcl">
	<title>Patching genclntsh</title>
	
	<para>The script <command>genclntsh</command> is used to create 
	  a single shared client
	  library.  It is used when building the demos.  Apply the following
	  patch to comment out the definition of PATH:</para>

	<programlisting>*** bin/genclntsh.orig Wed Sep 30 07:37:19 1998
--- bin/genclntsh Tue Dec 22 15:36:49 1998
***************
*** 32,38 ****
#
# Explicit path to ensure that we're using the correct commands
#PATH=/usr/bin:/usr/ccs/bin export PATH
! PATH=/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin export PATH
#
# each product MUST provide a $PRODUCT/admin/shrept.lst
--- 32,38 ----
#
# Explicit path to ensure that we're using the correct commands
#PATH=/usr/bin:/usr/ccs/bin export PATH
! #PATH=/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin export PATH
#
# each product MUST provide a $PRODUCT/admin/shrept.lst</programlisting>
      </sect3>
    </sect2>

    <sect2>
      <title>Running Oracle</title>
      
      <para>When you have followed the instructions, you should be able to run
	<application>Oracle</application> as if it was run on Linux 
	itself.</para>
    </sect2>
  </sect1>
  




  <sect1 id="sapr3">
    <sect1info>
      <authorgroup>
	<author>
	  <firstname>Holger</firstname>
	  <surname>Kipp</surname>
	  <contrib>Contributed by </contrib>
	</author>
      </authorgroup>
      <!-- holger.kipp@alogis.com -->
      <authorgroup>
	<author>
	  <firstname>Valentino</firstname>
	  <surname>Vaschetto</surname>
	  <contrib>Converted to SGML by </contrib>
	</author>
      </authorgroup>
    </sect1info>

    <title>Installing SAP R/3 (4.6B - IDES)</title>

    <indexterm>
      <primary>applications</primary>
      <secondary><application>SAP R/3</application></secondary>
    </indexterm>

    <para>Installations of SAP Systems using FreeBSD will not be
      supported by the SAP support team &mdash; they only offer support
      for certified platforms.</para>

    <sect2 id="preface">
      <title>Preface</title>

      <para>This document describes a possible way of installing a 
	<application>SAP R/3 4.6B IDES-System</application>
	with <application>Oracle 8.0.5</application>
	for Linux onto a FreeBSD 4.3 machine, including the installation
	of FreeBSD 4.3-STABLE and 
	<application>Oracle 8.0.5</application>.</para>

      <para>Even though this document tries to describe all important
        steps in a greater detail, it is not intended as a replacement
        for the <application>Oracle</application> and 
	<application>SAP R/3</application> installation guides.</para>

      <para>Please see the documentation that comes with the 
	<application>SAP R/3</application>
        Linux edition for <application>SAP-</application> and 
	<application>Oracle</application>-specific questions, as well
        as resources from <application>Oracle</application> and 
	<application>SAP OSS</application>.</para>
    </sect2>

    <sect2 id="software">
      <title>Software</title>

      <para>The following CDROMs have been used for
        SAP-installation:</para>
      <informaltable>
        <tgroup cols=3>
        <thead>
        <row>
          <entry>Name</entry> <entry>Number</entry> <entry>Description</entry>
        </row>
        </thead>
        <tbody>
        <row>
          <entry>KERNEL</entry> <entry>51009113</entry> <entry>SAP Kernel Oracle /
          Installation / AIX, Linux, Solaris</entry>
        </row>
        <row>
          <entry>RDBMS</entry> <entry>51007558</entry> <entry>Oracle / RDBMS 8.0.5.X /
          Linux</entry>
        </row>
        <row>
          <entry>EXPORT1</entry> <entry>51010208</entry> <entry>IDES / DB-Export / Disc
          1 of 6</entry>
        </row>
        <row>
          <entry>EXPORT2</entry> <entry>51010209</entry> <entry>IDES / DB-Export / Disc
          2 of 6</entry>
        </row>
        <row>
          <entry>EXPORT3</entry> <entry>51010210</entry> <entry>IDES / DB-Export /
          Disc3 of 6</entry>
        </row>
        <row>
          <entry>EXPORT4</entry> <entry>51010211</entry> <entry>IDES / DB-Export /
          Disc4 of 6</entry>
        </row>
        <row>
          <entry>EXPORT5</entry> <entry>51010212</entry> <entry>IDES / DB-Export /
          Disc5 of 6</entry>
        </row>
        <row>
          <entry>EXPORT6</entry> <entry>51010213</entry> <entry>IDES / DB-Export /
          Disc6 of 6</entry>
        </row>
        </tbody>
        </tgroup>
      </informaltable>

      <para>Additionally, I used the <application>Oracle 8
        Server</application> (Pre-production version 8.0.5 for Linux,
        Kernel Version 2.0.33) CD which is not really necessary, and
        of course FreeBSD 4.3 stable (it was only a few days past 4.3
        RELEASE).</para>
    </sect2>

    <sect2 id="sap-notes">
      <title>SAP-Notes</title>

      <para>The following notes should be read before installing
        <application>SAP R/3</application> or proved to be useful
        during installation:</para>

      <informaltable>
        <tgroup cols="2">
        <thead>
        <row>
          <entry>Number</entry>
          <entry>Title</entry>
        </row>
        </thead>
        <tbody>
        <row>
          <entry>0171356</entry> <entry>SAP Software auf Linux: grundlegenden
          Anmerkungen</entry>
        </row>
        <row>
          <entry>0201147</entry> <entry>INST: 4.6C R/3 Inst. on UNIX -
          Oracle</entry>
        </row>
        <row>
          <entry>0373203</entry> <entry>Update / Migration Oracle 8.0.5 -->
          8.0.6/8.1.6 LINUX</entry>
        </row>
        <row>
          <entry>0072984</entry> <entry>Release of Digital UNIX 4.0B for
          Oracle</entry>
        </row>
        <row>
          <entry>0130581</entry> <entry>R3SETUP step DIPGNTAB terminates</entry>
        </row>
        <row>
          <entry>0144978</entry> <entry>Your system has not been installed
          correctly</entry>
        </row>
        <row>
          <entry>0162266</entry> <entry>Questions and tips for R3SETUP on Windows
          NT / W2K</entry>
        </row>
        </tbody>
        </tgroup>
      </informaltable>

    </sect2>

    <sect2 id="hardware-requirements">
      <title>Hardware-Requirements</title>

      <para>The following equipment is sufficient for a
        <application>SAP R/3 System</application> (4.6B):</para>

      <informaltable>
        <tgroup cols="3">
        <thead>
        <row>
          <entry>Component</entry>
          <entry>4.6B</entry>
          <entry>4.6C</entry>
        </row>
        </thead>
        <tbody>
        <row>
          <entry>Processor</entry>
          <entry>2 x 800MHz Pentium III</entry>
          <entry>2 x 800MHz Pentium III</entry>
        </row>
        <row>
          <entry>Memory</entry>
          <entry>1GB ECC</entry>
          <entry>2GB ECC</entry>
        </row>
        <row>
          <entry>Hard Disc Space</entry>
          <entry>50-60GB (IDES)</entry>
          <entry>50-60GB (IDES)</entry>
        </row>
        </tbody>
	</tgroup>
      </informaltable>

      <para>For use in production, Xeon-Processors with large cache,
        high-speed disc access (SCSI, RAID hardware controller), USV
        and ECC-RAM is recommended.  The large amount of Hard disc
        space is due to the preconfigured IDES System, which creates
        27 GB of database files during installation.  Usually after
        installation it is then necessary to extend some
        tablespaces.</para>

      <para>I used a dual processor board with 2 800MHz Pentium III
        processors, Adaptec 29160 Ultra160 SCSI adapter (for accessing
        a 40/80 GB DLT tape drive and CDROM), Mylex AcelleRAID (2
        channels, firmware 6.00-1-00 with 32MB RAM).  To the Mylex
        Raid-controller are attached two 17GB hard discs (mirrored)
        and four 36GB hard discs (RAID level 5).</para>

    </sect2>

    <sect2 id="installation">
      <title>Installation of FreeBSD 4.3-STABLE</title>

      <para>First I installed FreeBSD 4.3 stable. I did the
        default-installation via FTP.</para>

      <sect3 id="install-via-ftp">
        <title>Installation via FTP</title> <para>Get the diskimages
        kern.flp and mfsroot.flp and put them on floppy disks (I got
        mine from ftp7.de.freebsd.org. Please choose the appropriate
        mirror).</para>

        <screen>&prompt.root; <userinput>dd if=kern.flp of=/dev/fd0</userinput> 
&prompt.root; <userinput>dd if=mfsroot.flp of=/dev/fd0</userinput> </screen>

        <para>Do not forget to use different disks for the two images,
          then boot from the floppy with the kern.flp-image on it
          and follow instructions.  I used the following disk
          layout:</para>

        <informaltable>
          <tgroup cols="4">
          <thead>
          <row>
            <entry>Filesystem</entry>
            <entry>Size (1k-blocks)</entry>
            <entry>Size (GB)</entry>
            <entry>Mounted on</entry>
          </row>
          </thead>
          <tbody>
          <row>
            <entry>/dev/da0s1a</entry>
            <entry>1.016.303</entry>
            <entry>1</entry>
            <entry>/</entry>
          </row>
          <row>
            <entry>/dev/da0s1b</entry>
            <entry> </entry>
            <entry>6</entry>
            <entry>&lt;swap&gt;</entry>
          </row>
          <row>
            <entry>/dev/da0s1e</entry>
            <entry>2.032.623</entry>
            <entry>2</entry>
            <entry>/var</entry>
          </row>
          <row>
            <entry>/dev/da0s1f</entry>
            <entry>8.205.339</entry>
            <entry>8</entry>
            <entry>/usr</entry>
          </row>
          <row>
            <entry>/dev/da1s1e</entry>
            <entry>45.734.361</entry>
            <entry>45</entry>
            <entry>/compat/linux/oracle</entry>
          </row>
          <row>
            <entry>/dev/da1s1f</entry>
            <entry>2.032.623</entry>
            <entry>2</entry>
            <entry>/compat/linux/sapmnt</entry>
          </row>
          <row>
            <entry>/dev/da1s1g</entry>
            <entry>2.032.623</entry>
            <entry>2</entry>
            <entry>/compat/linux/usr/sap</entry>
          </row>
          </tbody>
          </tgroup>
        </informaltable>

        <para>I had to configure and initialize the two logical drives
          with the Mylex software beforehand. It is located on the
          board itself and can be started during the boot phase of the
          PC.</para>
  
        <para> Please note that this disk layout differs slightly from
          the SAP recommendations, as SAP suggests mounting the
          oracle-subdirectories (and some others) separately - I
          decided to just create them as real subdirectories for
          simplicity.</para>

      </sect3>

      <sect3 id="getlatestsources">
        <title>Get the Latest STABLE Sources</title>

        <para>For FreeBSD 4.3 stable onwards, it is quite easy to get
          the latest stable sources. With the older versions of
          FreeBSD, I had my own script located in /etc/cvsup. Setting
          up <application>CVSup</application> for FreeBSD 4.3 is quite
	  easy. As user
          <username>root</username> do the following:</para>

        <screen>&prompt.root; <userinput>cp /etc/defaults/make.conf /etc/make.conf</userinput>
&prompt.root; <userinput>vi /etc/make.conf</userinput> </screen>

        <para>The file <filename>/etc/make.conf</filename> requires the
        following entries to be active:</para>

        <programlisting>SUP_UPDATE=    yes
SUP=           /usr/local/bin/cvsup
SUPFLAGS=      -g -L 2
SUPHOST=       cvsup8.FreeBSD.org
SUPFILE=       /usr/share/examples/cvsup/stable-supfile 
PORTSSUPFILE=  /usr/share/examples/cvsup/ports-supfile 
DOCSUPFILE=    /usr/share/examples/cvsup/doc-supfile</programlisting>

        <para>Change the <emphasis>SUPHOST</emphasis>-value
          appropriately.  The supfiles in
          <filename>/usr/share/examples/cvsup</filename> should be
          fine. If you do not want to load all the docfiles, leave the
          corresponding <emphasis>DOCSUPFILE</emphasis>-entry
          inactive.  Starting <application>cvsup</application>
	  to get the latest stable-sources is then very easy:</para>

        <screen>&prompt.root; <userinput>cd /usr/src</userinput>
&prompt.root; <userinput>make update</userinput> </screen>

      </sect3>


      <sect3 id="makeworldandnewkernel">
        <title><command>make world</command> and a New Kernel</title>

        <para>The first thing to do is to install the sources.
          As user root, do the following:</para>

        <screen>&prompt.root; <userinput>cd /usr/src</userinput>
&prompt.root; <userinput>make world</userinput> </screen>

        <para>If this goes through, one can then continue creating and
          configuring the new kernel. Usually this is where to
          customize the kernel configuration file.  As the computer is
          named <hostid>troubadix</hostid>, the natural name for the 
	  config file also is <filename>troubadix</filename>:</para>

        <screen>&prompt.root; <userinput>cd /usr/src/sys/i386/conf</userinput>
&prompt.root; <userinput>cp GENERIC TROUBADIX</userinput>
&prompt.root; <userinput>vi TROUBADIX</userinput> </screen>

        <para>At this stage one can define the drivers to use and not
          to use, etc.  See the appropriate documentation or have a
          look at file <filename>LINT</filename> for some additional
          explanations.</para>

        <para>One can then also include the parameters as described
          below Creating the new kernel then requires:</para>

        <screen>&prompt.root; <userinput>cd /usr/src/sys/i386/conf</userinput>
&prompt.root; <userinput>config TROUBADIX</userinput>
&prompt.root; <userinput>cd /usr/src/sys/compile/TROUBADIX</userinput>
&prompt.root; <userinput>make depend</userinput>
&prompt.root; <userinput>make</userinput>
&prompt.root; <userinput>make install</userinput> </screen>


        <para>After <command>make install</command> finished
          successfully, one should reboot the computer to have the new
          kernel available.</para>

      </sect3>
    </sect2>

    <sect2 id="installingthelinuxenviornment">
      <title>Installing the Linux Environment</title>

      <para>I had some trouble downloading the required RPM-files (for
        4.3 stable, 2nd May 2001), so you might try one of the
        following locations (if all the others fail and the following
        are not out of date):</para>

      <itemizedlist>
        <listitem><para>ftp7.de.freebsd.org/pub/FreeBSD/distfiles/rpm</para></listitem>
        <listitem><para>ftp.redhat.com/pub/redhat/linux/6.1/en/os/i386/RedHat/RPMS</para></listitem>
      </itemizedlist>

      <sect3 id="installinglinuxbase-system">
        <title>Installing Linux Base-system</title>
        <para>First the Linux base-system needs to be installed (as root):
        <screen>&prompt.root; <userinput>cd /usr/ports/emulators/linux_base</userinput>
&prompt.root; <userinput>make package</userinput> </screen></para>
      </sect3>


      <sect3 id="installinglinuxdevelopment">
        <title>Installing Linux Development</title>

        <para>Next, the Linux development is needed:</para>

        <screen>&prompt.root; <userinput>cd /usr/ports/devel/linux_devtools</userinput>
&prompt.root; <userinput>make package</userinput> </screen>

      </sect3>


      <sect3 id="installingnecessaryrpms">
        <title>Installing Necessary RPMs</title>
	<indexterm><primary>RPMs</primary></indexterm>

        <para>To start the R3SETUP-Program, pam support is needed.  As
          this also requires some other packages, I ended up
          installing several packages. After that, pam still
          complained about a missing package, so I forced the
          installation and it worked. I wonder if the other packages
          are really needed or if it would have been sufficient to
          install the pam-package.</para>

        <para>Anyway, here is the list of packages I installed:</para>

        <itemizedlist>
          <listitem><para>cracklib-2.7-5.i386.rpm</para></listitem>
          <listitem><para>cracklib-dicts-2.7-5.i386.rpm</para></listitem>
          <listitem><para>pwdb-0.60-1.i386.rpm</para></listitem>
          <listitem><para>pam-0.68-7.i386.rpm</para></listitem>
        </itemizedlist>

        <para>I installed these packages with the following
          command:</para>

        <screen>&prompt.root; <userinput>rpm -i --ignoreos --root /compat/linux --dbpath /var/lib/rpm &lt;package_name&gt;</userinput> </screen>

        <para>except for the pam package, which I forced with</para>

        <screen>&prompt.root; <userinput>rpm -i --ignoreos --nodeps --root /compat/linux --dbpath /var/lib/rpm pam-0.68-7.i386.rpm</userinput> </screen>

        <para>For <application>Oracle</application> to run the
          intelligent agent, I also had to install the following
          RedHat Tcl package (as is stated in the FreeBSD Handbook):
          <filename>tcl-8.0.5-30.i386.rpm</filename> (otherwise the
          relinking during <application>Oracle</application> install
          will not work).  There are some other issues regarding
          relinking of <application>Oracle</application>, but that is
          a Oracle-Linux issue, not FreeBSD specific as far as I
          understand it.</para>

      </sect3>
    </sect2>

    <sect2 id="creatingsapr3env">
      <title>Creating the SAP/R3 Environment</title>

      <sect3 id="filesystemsandmountpoints">
        <title>Creating the Necessary Filesystems and Mountpoints</title>

        <para>For a simple installation, it is sufficient to create the
          following filesystems:</para>

        <informaltable>
          <tgroup cols="2">
          <thead>
          <row>
            <entry>mountpoint</entry>
            <entry>size in GB</entry>
          </row>
          </thead>
          <tbody>
          <row>
            <entry>/compat/linux/oracle</entry>
            <entry>45 GB</entry>
          </row>
          <row>
            <entry>/compat/linux/sapmnt</entry>
            <entry>2 GB</entry>
          </row>
          <row>
            <entry>/compat/linux/usr/sap</entry>
            <entry>2 GB</entry>
          </row>
          </tbody>
          </tgroup>
        </informaltable>

        <para>I also created some links, so FreeBSD will also find the
          correct path:</para>

        <screen>&prompt.root; <userinput>ln -s /compat/linux/oracle /oracle</userinput>
&prompt.root; <userinput>ln -s /compat/linux/sapmnt /sapmnt</userinput>
&prompt.root; <userinput>ln -s /compat/linux/usr/sap /usr/sap</userinput> </screen>
      </sect3>

      <sect3 id="creatingusersanddirectories">
        <title>Creating Users and Directories</title>

        <para><application>SAP R/3</application> needs two users and
	  three groups. The usernames depend on the
	  <application>SAP</application> system id (SID) which consists
	  of three letters. Some of these SIDs are reserved
	  by <application>SAP</application> (for example
	  <emphasis>SAP</emphasis> and <emphasis>NIX</emphasis>. For a
	  complete list please see the SAP documentation).  For the IDES
	  installation I used <emphasis>IDS</emphasis>.  We have
	  therefore the following groups (group ids might differ, these
	  are just the values I used with my installation):</para>

        <informaltable>
          <tgroup cols="3">
          <thead>
          <row>
            <entry>group id</entry>
            <entry>group name</entry>
            <entry>description</entry>
          </row>
          </thead>
          <tbody>
          <row>
            <entry>100</entry>
            <entry>dba</entry>
            <entry>Data Base Administrator</entry>
          </row>
          <row>
            <entry>101</entry>
            <entry>sapsys</entry>
            <entry>SAP System</entry>
          </row>
          <row>
            <entry>102</entry>
            <entry>oper</entry>
            <entry>Data Base Operator</entry>
          </row>
          </tbody>
          </tgroup>
        </informaltable>

        <para>For a default Oracle-Installation, only group
          <groupname>dba</groupname> is used. As
          <groupname>oper</groupname>-group, one also uses group
          <groupname>dba</groupname> (see Oracle- and
          SAP-documentation for further information).</para>

        <para>We also need the following users:</para>

        <informaltable>
          <tgroup cols="6">
          <thead>
          <row>
            <entry>user id</entry>
            <entry>username</entry>
            <entry>generic name</entry>
            <entry>group</entry>
            <entry>additional groups</entry>
            <entry>description</entry>
          </row>
          </thead>
          <tbody>
          <row>
            <entry>1000</entry>
            <entry>idsadm</entry>
            <entry>&lt;sid&gt;adm</entry>
            <entry>sapsys</entry>
            <entry>oper</entry>
            <entry>SAP Administrator</entry>
          </row>
          <row>
            <entry>1002</entry>
            <entry>oraids</entry>
            <entry>ora&lt;sid&gt;</entry>
            <entry>dba</entry>
            <entry>oper</entry>
            <entry>DB Administrator</entry>
          </row>
          </tbody>
          </tgroup>
        </informaltable>

        <para>Adding the users with <command>adduser</command>
          requires the following (please note shell and home
          directory) entries for SAP-Administrator:</para>

        <programlisting>Name: idsadm            &lt;sid&gt;adm
Password: ******
Fullname: SAP IDES Administrator
Uid: 1000
Gid: 101 (sapsys)
Class:
Groups: sapsys dba
HOME: /home/idsadm      /home/&lt;sid&gt;adm
Shell: /bin/sh</programlisting>

        <para>and for Database-Administrator:</para>

        <programlisting>Name: oraids          ora&lt;sid&gt; 
Password: ****** 
Fullname: Oracle IDES Administrator 
Uid: 1002 
Gid: 100 (dba) 
Class: 
Groups: dba 
HOME: /oracle/IDS     /oracle/&lt;sid&gt; 
Shell: /bin/sh</programlisting>

        <para>This should also include group
          <groupname>oper</groupname> in case you are using both
          groups <groupname>dba</groupname> and
          <groupname>oper</groupname>.</para>

      </sect3>

      <sect3 id="creatingdirectories">
        <title>Creating Directories</title>

        <para>These directories are usually created as separate
          filesystems.  This depends entirely on your requirements.  I
          choose to create them as simple directories, as they are all
          located on the same RAID 5 anyway:</para>

        <para>First we will set owners and right of some directories (as
          user <username>root</username>):</para>

        <screen>&prompt.root; <userinput>chmod 775 /oracle</userinput>
&prompt.root; <userinput>chmod 777 /sapmnt</userinput>
&prompt.root; <userinput>chown root:dba /oracle</userinput>
&prompt.root; <userinput>chown idsadm:sapsys /compat/linux/usr/sap</userinput>
&prompt.root; <userinput>chmow 775 /compat/linux/usr/sap</userinput> </screen>

        <para>Second we will create directories as user ora&lt;sid&gt;. These
        will all be subdirectories of /oracle/IDS:</para>

        <screen>&prompt.root; <userinput>su - oraids</userinput>
&prompt.root; <userinput>mkdir mirrlogA mirrlogB origlogA origlogB</userinput>
&prompt.root; <userinput>mkdir sapdata1 sapdata2 sapdata3 sapdata4 sapdata5 sapdata6</userinput>
&prompt.root; <userinput>mkdir saparch sapreorg</userinput>
&prompt.root; <userinput>exit</userinput> </screen>

        <para>In the third step we create directories as user 
	  <username>idsadm</username> (&lt;sid&gt;adm):</para>

        <screen>&prompt.root; <userinput>su - idsadm</userinput>
&prompt.root; <userinput>cd /usr/sap</userinput>
&prompt.root; <userinput>mkdir IDS</userinput>
&prompt.root; <userinput>mkdir trans</userinput>
&prompt.root; <userinput>exit</userinput> </screen>
      </sect3>

      <sect3 id="entriesinslashetcslashservices">
        <title>Entries in /etc/services</title>

        <para>SAP R/3 requires some entries in file
          <filename>/etc/services</filename> , which will not be set
          correctly during installation under FreeBSD.  Please add the
          following entries (you need at least those entries
          corresponding to the instance number - in this case,
          <emphasis>00</emphasis>.  It'll do no harm adding all
          entries from <emphasis>00</emphasis> to
          <emphasis>99</emphasis> for <emphasis>dp</emphasis>,
          <emphasis>gw</emphasis>, <emphasis>sp</emphasis> and
          <emphasis>ms</emphasis>);</para>

        <programlisting>sapdp00  3200/tcp # SAP Dispatcher.      3200 + Instance-Number
sapgw00  3300/tcp # SAP Gateway.         3300 + Instance-Number
sapsp00  3400/tcp #                      3400 + Instance-Number
sapms00  3500/tcp #                      3500 + Instance-Number
sapmsIDS 3600/tcp # SAP Message Server.  3600 + Instance-Number</programlisting>
      </sect3>

      <sect3 id="necessarylocales">
        <title>Necessary Locales</title>
	<indexterm><primary>locale</primary></indexterm>

        <para>SAP requires at least two locales that are not part of
          the default RedHat installation. SAP offers the required
          RPMs as download from their FTP-server (which is only
          accessible if you are a customer with OSS-access).  See note
          0171356 for a list of RPMs you need.</para>

        <para>It is also possible to just create appropriate links
          (for example from <emphasis>de_DE</emphasis> and
          <emphasis>en_US</emphasis> ), but I would not recommend this
          for a production system (so far it worked with the IDES
          system without any problems, though).  The following locales
          are needed:</para>

        <programlisting>de_DE.ISO-8859-1
en_US.ISO-8859-1</programlisting>

        <para>If they are not present, there will be some problems
          during the installation.  If these are then subsequently
          ignored (eg by setting the status of the offending steps to
          OK in file CENTRDB.R3S), it will be impossible to log onto
          the SAP-system without some additional effort.</para>
      </sect3>

      <sect3 id="kerneltuning">
        <title>Kernel Tuning</title>
	<indexterm><primary>kernel tuning</primary></indexterm>

        <para>SAP R/3 Systems need a lot of resources.  I therefore
        added the following parameters to my kernel config-file:

        <programlisting># Set these for memory pigs (SAP and Oracle):
options MAXDSIZ="(1024*1024*1024)"
options DFLDSIZ="(1024*1024*1024)" # System V options needed.
options SYSVSHM #SYSV-style shared memory
options SHMMAXPGS=262144 #max amount of shared mem. pages
options SHMMNI=256 #max number of shared memory ident if.
options SHMSEG=100 #max shared mem.segs per process
options SYSVMSG #SYSV-style message queues 
options MSGSEG=32767 #max num. of mes.segments in system 
options MSGSSZ=32 #size of msg-seg. MUST be power of 2
options MSGMNB=65535 #max char. per message queue
options MSGTQL=2046 #max amount of msgs in system
options SYSVSEM #SYSV-style semaphores 
options SEMMNU=256 #number of semaphore UNDO structures
options SEMMNS=1024 #number of semaphores in system
options SEMMNI=520 #number of semaphore indentifiers
options SEMUME=100 #number of UNDO keys</programlisting></para>

        <para>The minimum values are specified in the documentation that
          comes from SAP.  As there is no description for Linux, see the
          HP-UX-section (32-bit) for further information.
        </para>
      </sect3>
    </sect2>

    <sect2 id="installingsapr3">
      <title>Installing SAP R/3</title>

      <sect3 id="preparingsapcdroms">
        <title>Preparing SAP CDROMs</title>

        <para>There are lots of CDROMs to mount and unmount during
          installation.  Assuming you have enough CDROM-drives, you
          can just mount them all.  I decided to copy the CDROM
          contents to corresponding directories:</para>

        <programlisting>/oracle/IDS/sapreorg/&lt;cd-name&gt;</programlisting>

        <para>where &lt;cd-name&gt; was one of <filename>KERNEL</filename>, 
	  <filename>RDBMS</filename>, <filename>EXPORT1</filename>,
	  <filename>EXPORT2</filename>, <filename>EXPORT3</filename>,
	  <filename>EXPORT4</filename>, <filename>EXPORT5</filename> and 
	  <filename>EXPORT6</filename>. All the
	  filenames should be in capital letters, otherwise use the -g
	  option for mounting. So use the following commands:</para>

        <screen>&prompt.root; <userinput>mount_cd9660 -g /dev/cd0a /mnt</userinput>
&prompt.root; <userinput>cp -R /mnt/* /oracle/IDS/sapreorg/&lt;cd-name&gt;</userinput>
&prompt.root; <userinput>umount /mnt</userinput> </screen>
      </sect3>

      <sect3 id="runningtheinstall-script">
        <title>Running the install-script</title>

        <para>First we need to prepare an install-directory:</para>

        <screen>&prompt.root; <userinput>cd /oracle/IDS/sapreorg</userinput>
&prompt.root; <userinput>mkdir install</userinput>
&prompt.root; <userinput>cd install</userinput> </screen>

        <para>Then the install-script is started, which will copy nearly
          all the relevant files into the install-directory:</para>

        <para><filename>/oracle/IDS/sapreorg/KERNEL/UNIX/INSTTOOL.SH</filename></para>

        <para>As this is an IDES-Installation with a fully customized
          SAP R/3 Demo-System, we have six instead of just three
          EXPORT-CDs.  At this point the installation template
          CENTRDB.R3S is for installing a standard central instance
          (R/3 and Database), not an IDES central instance, so copy
          the corresponding CENTRDB.R3S from the EXPORT1 directory,
          otherwise R3SETUP will only ask for three EXPORT-CDs.</para>
      </sect3>

      <sect3 id="startr3setup">
        <title>Start R3SETUP</title>

        <para>Make sure LD_LIBRARY_PATH is set correctly:</para>

        <screen>&prompt.root; <userinput>export LD_LIBRARY_PATH=/oracle/IDS/lib:/sapmnt/IDS/exe:/oracle/805_32/lib</userinput> </screen>

        <para>Start R3SETUP as user root from installation
        directory:</para>

        <screen>&prompt.root; <userinput>cd /oracle/IDS/sapreorg/install</userinput>
&prompt.root; <userinput>./R3SETUP -f CENTRDB.R3S</userinput> </screen>

        <para>The script then asks some questions (defaults in brackets,
        followed by actual input):</para>

        <informaltable>
          <tgroup cols="3">
          <thead>
          <row>
            <entry>Question</entry>
            <entry>Default</entry>
            <entry>Input</entry>
          </row>
          </thead>
          <tbody>
          <row>
            <entry>Enter SAP System ID</entry>
            <entry>[C11]</entry>
            <entry>IDS&lt;ret&gt;</entry>
          </row>
          <row>
            <entry>Enter SAP Instance Number</entry>
            <entry>[00]</entry>
            <entry>&lt;ret&gt;</entry>
          </row>
          <row>
            <entry>Enter SAPMOUNT Directory</entry>
            <entry>[/sapmnt]</entry>
            <entry>&lt;ret&gt;</entry>
          </row>
          <row>
            <entry>Enter name of SAP central host</entry>
            <entry>[troubadix.domain.de]</entry>
            <entry>&lt;ret&gt;</entry>
          </row>
          <row>
            <entry>Enter name of SAP db host</entry>
            <entry>[troubadix]</entry>
            <entry>&lt;ret&gt;</entry>
          </row>
          <row>
            <entry>Select character set</entry>
            <entry>[1] (WE8DEC)</entry>
            <entry>&lt;ret&gt;</entry>
          </row>
          <row>
            <entry>Enter Oracle server version (1) Oracle 8.0.5, (2) Oracle 8.0.6, (3) Oracle 8.1.5, (4) Oracle 8.1.6</entry>
            <entry> </entry>
            <entry>1&lt;ret&gt;</entry>
          </row>
          <row>
            <entry>Extract Oracle Client archive</entry>
            <entry>[1] (Yes, extract)</entry>
            <entry>&lt;ret&gt;</entry>
          </row>
          <row>
            <entry>Enter path to KERNEL CD</entry>
            <entry>[/sapcd]</entry>
            <entry>/oracle/IDS/sapreorg/KERNEL</entry>
          </row>
          <row>
            <entry>Enter path to RDBMS CD</entry>
            <entry>[/sapcd]</entry>
            <entry>/oracle/IDS/sapreorg/RDBMS</entry>
          </row>
          <row>
            <entry>Enter path to EXPORT1 CD</entry>
            <entry>[/sapcd]</entry>
            <entry>/oracle/IDS/sapreorg/EXPORT1</entry>
          </row>
          <row>
            <entry>Directory to copy EXPORT1 CD</entry>
            <entry>[/oracle/IDS/sapreorg/CD4_DIR]</entry>
            <entry>&lt;ret&gt;</entry>
          </row>
          <row>
            <entry>Enter path to EXPORT2 CD</entry>
            <entry>[/sapcd]</entry>
            <entry>/oracle/IDS/sapreorg/EXPORT2</entry>
          </row>
          <row>
            <entry>Directory to copy EXPORT2 CD</entry>
            <entry>[/oracle/IDS/sapreorg/CD5_DIR]</entry>
            <entry>&lt;ret&gt;</entry>
          </row>
          <row>
            <entry>Enter path to EXPORT3 CD</entry>
            <entry>[/sapcd]</entry>
            <entry>/oracle/IDS/sapreorg/EXPORT3</entry>
          </row>
          <row>
            <entry>Directory to copy EXPORT3 CD</entry>
            <entry>[/oracle/IDS/sapreorg/CD6_DIR]</entry>
            <entry>&lt;ret&gt;</entry>
          </row>
          <row>
            <entry>Enter path to EXPORT4 CD</entry>
            <entry>[/sapcd]</entry>
            <entry>/oracle/IDS/sapreorg/EXPORT4</entry>
          </row>
          <row>
            <entry>Directory to copy EXPORT4 CD</entry>
            <entry>[/oracle/IDS/sapreorg/CD7_DIR]</entry>
            <entry>&lt;ret&gt;</entry>
          </row>
          <row>
            <entry>Enter path to EXPORT5 CD</entry>
            <entry>[/sapcd]</entry>
            <entry>/oracle/IDS/sapreorg/EXPORT5</entry>
          </row>
          <row>
            <entry>Directory to copy EXPORT5 CD</entry>
            <entry>[/oracle/IDS/sapreorg/CD8_DIR]</entry>
            <entry>&lt;ret&gt;</entry>
          </row>
          <row>
            <entry>Enter path to EXPORT6 CD</entry>
            <entry>[/sapcd]</entry>
            <entry>/oracle/IDS/sapreorg/EXPORT6</entry>
          </row>
          <row>
            <entry>Directory to copy EXPORT6 CD</entry>
            <entry>[/oracle/IDS/sapreorg/CD9_DIR]</entry>
            <entry>&lt;ret&gt;</entry>
          </row>
          <row>
            <entry>Enter amount of RAM for SAP + DB</entry>
            <entry> </entry>
            <entry>850&lt;ret&gt; (in Megabytes)</entry>
          </row>
          <row>
            <entry>Service Entry Message Server</entry>
            <entry>[3600]</entry>
            <entry>&lt;ret&gt;</entry>
          </row>
          <row>
            <entry>Enter Group-ID of sapsys</entry>
            <entry>[101]</entry>
            <entry>&lt;ret&gt;</entry>
          </row>
          <row>
            <entry>Enter Group-ID of oper</entry>
            <entry>[102]</entry>
            <entry>&lt;ret&gt;</entry>
          </row>
          <row>
            <entry>Enter Group-ID of dba</entry>
            <entry>[100]</entry>
            <entry>&lt;ret&gt;</entry>
          </row>
          <row>
            <entry>Enter User-ID of &lt;sid&gt;adm</entry>
            <entry>[1000]</entry>
            <entry>&lt;ret&gt;</entry>
          </row>
          <row>
            <entry>Enter User-ID of ora&lt;sid&gt;</entry>
            <entry>[1002]</entry>
            <entry>&lt;ret&gt;</entry>
          </row>
          <row>
            <entry>Number of parallel procs</entry>
            <entry>[2]</entry>
            <entry>&lt;ret&gt;</entry>
          </row>
          </tbody>
          </tgroup>
        </informaltable>
      
        <para>If I had not copied the CDs to the different locations,
          then the SAP-Installer cannot find the CD needed (identified
          by the <filename>LABEL.ASC</filename>-File on CD) and would
          then ask you to insert / mount the CD and confirm or enter
          the mount path.</para>
   
        <para>The <filename>CENTRDB.R3S</filename> might not be
          error-free. In my case, it requested EXPORT4 again (but
          indicated the correct key (6_LOCATI ON, then 7_LOCATION
          etc.), so one can just continue with entering the correct
          values. Do not get irritated.</para>

        <para>Apart from some problems mentioned below, everything
          should go straight through up to the point where the Oracle
          database software needs to be installed.</para>
      </sect3>
    </sect2>

    <sect2 id="installingoracle805">
      <title>Installing Oracle 8.0.5</title>

      <para>Please see the corresponding SAP-Notes and Oracle Readmes
        regarding Linux and Oracle DB for possible problems. Most if
        not all problems stem from incompatible libraries</para>

      <para>For more information on installing Oracle, refer to <ulink
        url="linuxemu-oracle.html">the Installing Oracle
        chapter.</ulink></para>

      <sect3 id="installingtheoracle805withorainst">
        <title>Installing the Oracle 8.0.5 with orainst</title>

        <para>If <application>Oracle 8.0.5</application> is to be
          used, some additional libraries are needed for successfully
          relinking, as Oracle 8.0.5 was linked with an old glibc
          (RedHat 6.0), but RedHat 6.1 already uses a new glibc. So
          you have to install the following additional packages to
          ensure that linking will work:</para>

        <para><filename>compat-libs-5.2-2.i386.rpm</filename></para>
        <para><filename>compat-glibc-5.2-2.0.7.2.i386.rpm</filename></para>
        <para><filename>compat-egcs-5.2-1.0.3a.1.i386.rpm</filename></para>
        <para><filename>compat-egcs-c++-5.2-1.0.3a.1.i386.rpm</filename></para>
        <para><filename>compat-binutils-5.2-2.9.1.0.23.1.i386.rpm</filename></para>

        <para>See the corresponding SAP-Notes or Oracle Readmes for
          further information.  If this is no option (at the time of
          installation I did not have enough time to check this), one
          could use the original binaries, or use the relinked
          binaries from an original RedHat System.</para>

        <para>For compiling the intelligent agent, the RedHat Tcl
          package must be installed.  If you cannot get
          <filename>tcl-8.0.3-20.i386.rpm</filename>, a newer one like
          <filename>tcl-8.0.5-30.i386.rpm</filename> for RedHat 6.1
          should also do.</para>

        <para>Apart from relinking, the installation is
          straightforward:</para>

        <screen>&prompt.root; <userinput>su - oraids</userinput>
&prompt.root; <userinput>export TERM=xterm</userinput>
&prompt.root; <userinput>export ORACLE_TERM=xterm</userinput>
&prompt.root; <userinput>export ORACLE_HOME=/oracle/IDS</userinput>
&prompt.root; <userinput>cd /ORACLE_HOME/orainst_sap</userinput>
&prompt.root; <userinput>./orainst</userinput> </screen>

        <para>Confirm all Screens with Enter until the software is
          installed, except that one has to deselect the
          <emphasis>Oracle On-Line Text Viewer</emphasis> , as this is
          not currently available for Linux. Oracle then wants to
          relink with <command>i386-glibc20-linux-gcc</command>
          instead of the available <command>gcc</command>,
          <command>egcs</command> or <command>i386-redhat-linux-gcc
          </command>.</para>

        <para>Due to time constrains I decided to use the binaries
          from an <application>Oracle 8.0.5 PreProduction</application>
	  release, after the first
          attempt at getting the version from the RDBMS-CD working,
          failed, and finding / accessing the correct RPMs was a
          nightmare at that time.</para>

      </sect3>

      <sect3 id="installingtheoracle805preproduction">
        <title>Installing the Oracle 8.0.5 Pre-Production release for
          Linux (Kernel 2.0.33)</title>

        <para>This installation is quite easy. Mount the CD, start the
          installer.  It will then ask for the location of the Oracle
          home directory, and copy all binaries there. I did not
          delete the remains of my previous RDBMS-installation tries,
          though.</para>

        <para>Afterwards, Oracle Database could be started with no
          problems.</para>
      </sect3>
    </sect2>

    <sect2 id="continuewithsapr4installation">
      <title>Continue with SAP R/3 Installation</title>

      <para>First check the environment settings of users 
	<username>idsamd</username>
        (&lt;sid&gt;adm) and 
	<username>oraids</username> (ora&lt;sid&gt;). They should now
        both have the files <filename>.profile</filename> ,
        <filename>.login</filename> and <filename>.cshrc</filename>
        which are all using <command>hostname</command>. In case the
        system's hostname is the fully qualified name, you need to
        change <command>hostname</command> to <command>hostname
        -s</command> within all three files.</para>

      <sect3 id="databaseload">
        <title>Database Load</title>

        <para>Afterwards, R3SETUP can either be restarted or continued
          (depending on whether exit was chosen or not). R3SETUP then
          creates the tablespaces and loads the data from EXPORT1 to
          EXPORT6 (remember, it is an IDES system, otherwise it would
          only be EXPORT1 to EXPORT3) with R3load into the
          database.</para>

        <para>When the database load is finished (might take a few
          hours), some passwords are requested. For test
          installations, one can use the well known default passwords
          (use different ones if security is an issue!):</para>

        <informaltable>
          <tgroup cols="2">
          <thead>
          <row>
            <entry>Question</entry>
            <entry>Input</entry>
          </row>
          </thead>
          <tbody>
          <row>
            <entry>Enter Password for sapr3</entry>
            <entry>sap&lt;ret&gt;</entry>
          </row>
          <row>
            <entry>Confirum Password for sapr3</entry>
            <entry>sap&lt;ret&gt;</entry>
          </row>
          <row>
            <entry>Enter Password for sys</entry>
            <entry>change_on_install&lt;ret&gt;</entry>
          </row>
          <row>
            <entry>Confirm Password for sys</entry>
            <entry>change_on_install&lt;ret&gt;</entry>
          </row>
          <row>
            <entry>Enter Password for system</entry>
            <entry>manager&lt;ret&gt;</entry>
          </row>
          <row>
            <entry>Confirm Password for system</entry>
            <entry>manager&lt;ret&gt;</entry>
          </row>
          </tbody>
          </tgroup>
        </informaltable>

        <para>At this point I had a few problems with 
	  <literal>dipgntab</literal>.</para>
      </sect3>

      <sect3 id="listener">
        <title>Listener</title>

        <para>Start the Oracle-Listener as user 
	  <username>oraids</username> (ora&lt;sid&gt;) as follows:</para>

        <programlisting>umask 0; lsnrctl start</programlisting>

        <para>Otherwise you might get ORA-12546 as the sockets will not
        have the correct permissions. See SAP note 072984.</para>
      </sect3>
    </sect2>

    <sect2 id="postinstallationsteps">
      <title>Post-installation Steps</title>

      <sect3 id="requestsapr3licensekey">
        <title>Request SAP R/3 License Key</title>

        <para>This is needed, as the temporary license is only valid for
        four weeks.  Do not forget to enter the correct Operating System:
        (X) Other: <emphasis>FreeBSD 4.3 Stable</emphasis>. First get
        the hardware key.  Log on as user <username>idsadm</username> and
        call <command>saplicense</command>:</para>

        <screen>&prompt.root; <userinput>/sapmnt/IDS/exe/saplicense -get</userinput></screen>

        <para>Calling <command>saplicense</command> without options
        gives a list of options.  Upon receiving the license key, it can
        be installed using</para>

        <screen>&prompt.root; <userinput>/sapmnt/IDS/exe/saplicense -install</userinput></screen>

        <para>You are then required to enter the following
        values:</para>

        <programlisting>SAP SYSTEM ID   = &lt;SID, 3 chars&gt;
CUSTOMER KEY    = &lt;hardware key, 11 chars&gt;
INSTALLATION NO = &lt;installation, 10 digits&gt;
EXPIRATION DATE = &lt;yyyymmdd, usually "99991231"&gt;
LICENSE KEY     = &lt;license key, 24 chars&gt;</programlisting>
      </sect3>

      <sect3 id="creatingusers">
        <title>Creating Users</title>

        <para>Create a user within client 000 (for some tasks required
        to be done within client 000, but with a user different from
        users <username>sap*</username> and
        <username>ddic</username>). As a username, I usually choose
        <replaceable>wartung</replaceable> (or
        <replaceable>service</replaceable> in English).  Profiles
        required are <emphasis>sap_new</emphasis> and
        <emphasis>sap_all</emphasis>. For additional safety the
        passwords of default users within all clients should be
        changed (this includes users <username>sap*</username> and
        <username>ddic</username>).</para>
      </sect3>

      <sect3 id="configtranssysprofileopermodesetc">
        <title>Configure Transport System, Profile, Operation Modes, Etc.</title>

        <para>Within client 000, user different from <username>ddic</username>
	  and sap*, do at least the following:</para>

        <informaltable>
          <tgroup cols="2">
          <thead>
          <row>
            <entry>Task</entry>
            <entry>Transaction</entry>
          </row>
          </thead>
          <tbody>
          <row>
            <entry>Configure Transport System, eg as <emphasis>Stand-Alone
            Transport Domain Entity</emphasis></entry>
	    <entry>STMS</entry>
          </row>
          <row>
            <entry>Create / Edit Profile for System</entry>
            <entry>RZ10</entry>
          </row>
          <row>
            <entry>Maintain Operation Modes and Instances</entry>
            <entry>RZ04</entry>
          </row>
          </tbody>
          </tgroup>
        </informaltable>

        <para>These and all the other post-installation steps are
          thoroughly described in SAP installation guides.</para>
      </sect3>

      <sect3 id="editintsidsap">
        <title>Edit init&lt;sid&gt;.sap (initIDS.sap)</title>

        <para>The file
          <filename>/oracle/IDS/dbs/initIDS.sap</filename> contains
          the SAP backup profile.  Here the size of the tape to be
          used, type of compression and so on need to be defined. To
          get this running with <command>sapdba</command> /
          <command>brbackup</command>, I changed the following
          values:</para>

        <programlisting>compress = hardware
archive_function = copy_delete_save
cpio_flags = "-ov --format=newc --block-size=128 --quiet"
cpio_in_flags = "-iuv --block-size=128 --quiet"
tape_size = 38000M
tape_address = /dev/nsa0
tape_address_rew = /dev/sa0</programlisting>

        <para>Explanations:</para>

        <para><emphasis>compress</emphasis> The tape I use is a HP DLT1
        which does hardware compression.</para>

        <para><emphasis>archive_function</emphasis> This defines the
        default behavior for saving Oracle archive logs: New logfiles
        are saved to tape, already saved logfiles are saved again and
        are then deleted.  This prevents lots of trouble if one needs to
        recover the database, and one of the archive-tapes has gone
        bad.</para>

        <para><emphasis>cpio_flags</emphasis> Default is to use -B which
        sets blocksize to 5120 Bytes. For DLT-Tapes, HP recommends at
        least 32K blocksize, so I used --block-size=128 for
        64K. --format=newc is needed I have inode numbers greater than
        65535. The last option --quiet is needed as otherwise 
	<command>brbackup</command>
        complains as soon as <command>cpio</command> outputs the 
	numbers of blocks saved.</para>

        <para><emphasis>cpio_in_flags</emphasis> Flags needed for
        loading data back from tape. Format is recognized
        automagically.</para>

        <para><emphasis>tape_size</emphasis> This usually gives the raw
        storage capability of the tape. For security reason (we use
        hardware compression), the</para>

        <para><emphasis>value</emphasis> is slightly lower than the
        actual value.</para>

        <para><emphasis>tape_address</emphasis> The non-rewindable
        device to be used with <command>cpio</command>.</para>

        <para><emphasis>tape_address_rew The rewindable device to be
        used with cpio.</emphasis></para>
      </sect3>

      <sect3>
	<title>Configuration Issues after Installation</title>

	<para>The following SAP-parameters should be tuned after
	  installation:</para>

	<informaltable frame="none">
	  <tgroup cols="2">
	    <thead>
	      <row>
		<entry>Name</entry>
		<entry>Value</entry>
	      </row>
	    </thead>
	    <tbody>
	      <row>
		<entry>ztta/roll_extension</entry>
		<entry>250000000</entry>
	      </row>
	      <row>
		<entry>abap/heap_area_dia</entry>
                <entry>300000000</entry>
	      </row>
	      <row>
		<entry>abap/heap_area_nondia</entry>
		<entry>400000000</entry>
	      </row>
	      <row>
		<entry>em/initial_size_MB</entry>
		<entry>256</entry>
	      </row>
	      <row>
		<entry>em/blocksize_kB</entry>
		<entry>1024</entry>
	      </row>
	      <row>
		<entry>ipc/shm_psize_40</entry>
		<entry>70000000</entry>
	      </row>
	    </tbody>
	  </tgroup>
	</informaltable>

	<para>SAP-Note 0013026:</para>

	<informaltable frame="none">
	  <tgroup cols="2">
	    <thead>
	      <row>
		<entry>Name</entry>
		<entry>Value</entry>
	      </row>
	    <tbody>
	      <row>
		<entry>ztta/dynpro_area</entry>
		<entry>2500000</entry>
	      </row>
	    </tbody>
	  </tgroup>
	</informaltable>

	<para>SAP-Note 0157246:</para>

	<informaltable frame="none">
	  <tgroup cols="2">
	    <thead>
	      <row>
		<entry>Name</entry>
		<entry>Value</entry>
	      </row>
	    <tbody>
	      <row>
		<entry>rdisp/ROLL_MAXFS</entry>
		<entry>16000</entry>
	      </row>
	      <row>
		<entry>rdisp/PG_MAXFS</entry>
		<entry>30000</entry>
	      </row>
	    </tbody>
	  </tgroup>
	</informaltable>

	<note>
	  <para>With the above parameters, on a system with 1 gigabyte
	    of memory, one may find memory consuption similar to:

	  <programlisting>Mem: 547M Active, 305M Inact, 109M Wired, 40M Cache, 112M Buf, 3492K Free</programlisting></para>
	</note>
      </sect3>
    </sect2>

    <sect2 id="problemsduringinstallation">
      <title>Problems During Installation</title>

      <sect3 id="indoraduringduringr3setup">
        <title>OSUSERSIDADM_IND_ORA During R3SETUP</title>

        <para>If R3SETUP complains at this stage, edit file
          CENTRDB.R3S.  Locate [OSUSERSIDADM_IND_ORA] and edit the
          following values:</para>

        <programlisting>HOME=/home/idsadm (was empty)
STATUS=OK (had status ERROR)
        </programlisting>

        <para>Then you can restart R3SETUP with:</para>

        <screen>&prompt.root; <userinput>./R3SETUP -f CENTRDB.R3S</userinput></screen>
      </sect3>

      <sect3 id="indoraduringr3setup">
        <title>OSUSERDBSID_IND_ORA During R3SETUP</title>

        <para>Possibly R3SETUP also complains at this stage. Just edit
          CENTRDB.R3S.  Locate [OSUSERDBSID_IND_ORA] and edit the
          following value in that section:</para>

        <programlisting>STATUS=OK</programlisting>

        <para>Then just restart R3SETUP again:</para>

        <screen>&prompt.root; <userinput>./R3SETUP -f CENTRDB.R3S</userinput></screen>
      </sect3>

      <sect3 id="oraviewvrffilenotfound">
        <title>oraview.vrf FILE NOT FOUND During Oracle Installation</title>

        <para>You have not deselected <emphasis>Oracle On-Line Text Viewer</emphasis>
          before starting the installation. This is marked for installation even
          though this option is currently not available for Linux. Deselect this
          product inside the Oracle installation menu and restart installation.</para>
      </sect3>

      <sect3 id="textenvincalid">
        <title>TEXTENV_INVALID During R3SETUP, RFC or SAPGUI Start</title>

        <para>If this error is encountered, the correct locale is
	  missing.  SAP note 0171356 lists the necessary RPMs that need
	  be installed (eg <emphasis>saplocales-1.0-3</emphasis>,
	  <emphasis>saposcheck-1.0-1</emphasis> for RedHat 6.1). In case
	  you ignored all the related errors and set the corresponding
	  status from ERROR to OK (in CENTRDB.R3S) every time R3SETUP
	  complained and just restarted R3SETUP, the SAP-System will not
	  be properly configured and you will then not be able to
	  connect to the system with a
	  <literal>sapgui</literal>, even though the system
	  can be started. Trying to connect with the old Linux
	  <literal>sapgui</literal> gave the following
	  messages:</para>

        <programlisting>Sat May 5 14:23:14 2001
*** ERROR => no valid userarea given [trgmsgo. 0401]
Sat May 5 14:23:22 2001
*** ERROR => ERROR NR 24 occured [trgmsgi. 0410]
*** ERROR => Error when generating text environment. [trgmsgi. 0435]
*** ERROR => function failed [trgmsgi. 0447]
*** ERROR => no socket operation allowed [trxio.c 3363]
Speicherzugriffsfehler</programlisting>

        <para>This behavior is due to SAP R/3 being unable to
          correctly assign a locale and also not being properly
          configured itself (missing entries in some database
          tables). To be able to connect to SAP, add the following
          entries to file DEFAULT.PFL (see note 0043288):</para>

        <programlisting>abap/set_etct_env_at_new_mode =0
install/collate/active =0
rscp/TCP0B =TCP0B
        </programlisting>

        <para>Restart the SAP system. Now one can connect to the
          system, even though country-specific language settings might
          not work as expected.  After correcting country-settings
          (and providing the correct locales), these entries can be
          removed from DEFAULT.PFL and the SAP system can be
          restarted.</para>

      </sect3>

      <sect3 id="ora-12546">
        <title>ORA-12546. Start Listener with Correct Permissions</title>

        <para>Start the Oracle Listener as user
          <username>oraids</username> with the following commands:</para>

        <screen>&prompt.root; <userinput>umask 0; lsnrctl start</userinput></screen>

        <para>Otherwise one might get ORA-12546 as the sockets will not
          have the correct permissions. See SAP note 0072984.</para>
      </sect3>

      <sect3 id="dipgntabindind">
        <title>[DIPGNTAB_IND_IND] During R3SETUP</title>

        <para>In general, see SAP note 0130581 (R3SETUP step 
	  <literal>DIPGNTAB</literal>
          terminates).  During this specific installation, for some
          reasons the installation process was not using the proper
          SAP system name "IDS", but the empty string "" instead. This
          lead to some minor problems with accessing directories, as
          the paths are generated dynamically using &lt;sid&gt; (in
          this case IDS).  So instead of accessing:</para>

        <programlisting>/usr/sap/IDS/SYS/...
/usr/sap/IDS/DVMGS00</programlisting>

        <para>the following path were used:</para>

        <programlisting>/usr/sap//SYS/...
/usr/sap/D00i</programlisting>

        <para>To continue with the installation, I created a link and an
          additional directory:</para>

        <screen>&prompt.root; pwd
/compat/linux/usr/sap
&prompt.root; ls -l
total 4
drwxr-xr-x 3  idsadm sapsys 512 May 5 11:20 D00
drwxr-x--x 5  idsadm sapsys 512 May 5 11:35 IDS
lrwxr-xr-x 1  root   sapsys 7 May 5 11:35 SYS -> IDS/SYS
drwxrwxr-x 2  idsadm sapsys 512 May 5 13:00 tmp
drwxrwxr-x 11 idsadm sapsys 512 May 4 14:20 trans </screen>
   
        <para>I also found SAP notes (0029227 and 0008401) describing
        this behavior.</para>
      </sect3>

      <sect3 id="rfcrswboiniindind">
        <title>[RFCRSWBOINI_IND_IND] During R3SETUP</title>

        <para>Set STATUS of the offending step from ERROR to OK (file
	  <filename>CENTRDB.R3S</filename>) and restart R3SETUP. After
	  installation, you have to execute the report
	  <literal>RSWBOINS</literal> from transaction SE38. See SAP
	  note 0162266 for additional information about phase
	  <literal>RFCRSWBOINI</literal> and
	  <literal>RFCRADDBDIF</literal>.</para>
      </sect3>

      <sect3 id="rfcraddbdifindind">
        <title>[RFCRADDBDIF_IND_IND] During R3SETUP</title>

        <para>Set STATUS of the offending step from ERROR to OK (file
	  <filename>CENTRDB.R3S</filename>) and restart R3SETUP. After
	  installation, you have to execute the report
	  <literal>RADDBDIF</literal> from transaction SE38.
	  See SAP note 0162266 for further information.</para>
      </sect3>
    </sect2>
  </sect1>

  <sect1>
    <title>Advanced Topics</title>

    <para>If you are curious as to how the Linux binary compatibility
      works, this is the section you want to read.  Most of what follows
      is based heavily on an email written to &a.chat; by Terry Lambert
      <email>tlambert@primenet.com</email> (Message ID:
      <literal>&lt;199906020108.SAA07001@usr09.primenet.com&gt;</literal>).</para>

    <sect2>
      <title>How Does It Work?</title>
      <indexterm><primary>execution class loader</primary></indexterm>

      <para>FreeBSD has an abstraction called an <quote>execution class
	loader</quote>.  This is a wedge into the &man.execve.2; system
	call.</para>

      <para>What happens is that FreeBSD has a list of loaders, instead of
	a single loader with a fallback to the <literal>#!</literal>
	loader for running any shell interpreters or shell scripts.</para>

      <para>Historically, the only loader on the Unix platform examined
	the magic number (generally the first 4 or 8 bytes of the file) to
	see if it was a binary known to the system, and if so, invoked the
	binary loader.</para>

      <para>If it was not the binary type for the system, the
	&man.execve.2; call returned a failure, and the shell attempted to
	start executing it as shell commands.</para>

      <para>The assumption was a default of <quote>whatever the current
	shell is</quote>.</para>

      <para>Later, a hack was made for &man.sh.1; to examine the first two
	characters, and if they were <literal>:\n</literal>, then it
	invoked the &man.csh.1; shell instead (we believe SCO first made
	this hack).</para>

      <para>What FreeBSD does now is go through a list of loaders, with a
	generic <literal>#!</literal> loader that knows about interpreters
	as the characters which follow to the next whitespace next to
	last, followed by a fallback to
	<filename>/bin/sh</filename>.</para>
      <indexterm><primary>ELF</primary></indexterm>

      <para>For the Linux ABI support, FreeBSD sees the magic number as an
	ELF binary (it makes no distinction between FreeBSD, Solaris,
	Linux, or any other OS which has an ELF image type, at this
	point).</para>
      <indexterm><primary>Solaris</primary></indexterm>

      <para>The ELF loader looks for a specialized
	<emphasis>brand</emphasis>, which is a comment section in the ELF
	image, and which is not present on SVR4/Solaris ELF
	binaries.</para>

      <para>For Linux binaries to function, they must be
	<emphasis>branded</emphasis> as type <literal>Linux</literal>;
	from &man.brandelf.1;:</para>

      <screen>&prompt.root; <userinput>brandelf -t Linux file</userinput></screen>

      <para>When this is done, the ELF loader will see the
	<literal>Linux</literal> brand on the file.</para>
      <indexterm>
        <primary>ELF</primary>
	<secondary>branding</secondary>
      </indexterm>

      <para>When the ELF loader sees the <literal>Linux</literal> brand,
	the loader replaces a pointer in the <literal>proc</literal>
	structure.  All system calls are indexed through this pointer (in
	a traditional Unix system, this would be the
	<literal>sysent[]</literal> structure array, containing the system
	calls).  In addition, the process flagged for special handling of
	the trap vector for the signal trampoline code, and sever other
	(minor) fix-ups that are handled by the Linux kernel
	module.</para>

      <para>The Linux system call vector contains, among other things, a
	list of <literal>sysent[]</literal> entries whose addresses reside
	in the kernel module.</para>

      <para>When a system call is called by the Linux binary, the trap
	code dereferences the system call function pointer off the
	<literal>proc</literal> structure, and gets the Linux, not the
	FreeBSD, system call entry points.</para>

      <para>In addition, the Linux mode dynamically
	<emphasis>reroots</emphasis> lookups; this is, in effect, what the
	<literal>union</literal> option to FS mounts
	(<emphasis>not</emphasis> the unionfs!) does.  First, an attempt
	is made to lookup the file in the
	<filename>/compat/linux/<replaceable>original-path</replaceable></filename>
	directory, <emphasis>then</emphasis> only if that fails, the
	lookup is done in the
	<filename>/<replaceable>original-path</replaceable></filename>
	directory.  This makes sure that binaries that require other
	binaries can run (e.g., the Linux toolchain can all run under
	Linux ABI support).  It also means that the Linux binaries can
	load and exec FreeBSD binaries, if there are no corresponding
	Linux binaries present, and that you could place a &man.uname.1;
	command in the <filename>/compat/linux</filename> directory tree
	to ensure that the Linux binaries could not tell they were not
	running on Linux.</para>

      <para>In effect, there is a Linux kernel in the FreeBSD kernel; the
	various underlying functions that implement all of the services
	provided by the kernel are identical to both the FreeBSD system
	call table entries, and the Linux system call table entries: file
	system operations, virtual memory operations, signal delivery,
	System V IPC, etc&hellip;  The only difference is that FreeBSD
	binaries get the FreeBSD <emphasis>glue</emphasis> functions, and
	Linux binaries get the Linux <emphasis>glue</emphasis> functions
	(most older OS's only had their own <emphasis>glue</emphasis>
	functions: addresses of functions in a static global
	<literal>sysent[]</literal> structure array, instead of addresses
	of functions dereferenced off a dynamically initialized pointer in
	the <literal>proc</literal> structure of the process making the
	call).</para>

      <para>Which one is the native FreeBSD ABI?  It does not matter.
	Basically the only difference is that (currently; this could
	easily be changed in a future release, and probably will be after
	this) the FreeBSD <emphasis>glue</emphasis> functions are
	statically linked into the kernel, and the Linux glue functions
	can be statically linked, or they can be accessed via a kernel
	module.</para>

      <para>Yeah, but is this really emulation?  No.  It is an ABI
	implementation, not an emulation.  There is no emulator (or
	simulator, to cut off the next question) involved.</para>

      <para>So why is it sometimes called <quote>Linux emulation</quote>?
	To make it hard to sell FreeBSD!  Really, it
	is because the historical implementation was done at a time when
	there was really no word other than that to describe what was
	going on; saying that FreeBSD ran Linux binaries was not true, if
	you did not compile the code in or load a module, and there needed
	to be a word to describe what was being loaded&mdash;hence
	<quote>the Linux emulator</quote>.</para>
    </sect2>
  </sect1>
</chapter>

<!-- 
     Local Variables:
     mode: sgml
     sgml-declaration: "../chapter.decl"
     sgml-indent-data: t
     sgml-omittag: nil
     sgml-always-quote-attributes: t
     sgml-parent-document: ("../book.sgml" "part" "chapter")
     End:
-->