Monday, December 7, 2020

Installing Darwin with QEMU

  1. Darwin 8.0.1 (corresponding to Mac OS X 10.4) seems to be the latest available full installer image, at least, until the PureDarwin project produces a new one.

  2. More recent versions of packages are available in source form:

Installing

  1. Download and extract installation CD image:

    • Darwin 8.0.1 (was under “Darwin 8.0.1 Installer CD” on old website)

      • MD5: dbd260dda994093a11c31afbe624aa34

      • SHA-256: a26f9f14795fe0687bd647d41b712464c9a61430736fae4aa0fdb89207e1a62a

    • $ gunzip darwinx86-801.iso.gz

  2. Set up QEMU VM:

    • $ qemu-img create -f qcow2 darwin.qcow2 10G

  3. Start VM:

    • $ qemu -net none -drive file=darwin.qcow2,cache=writeback -cdrom darwinx86-801.iso -boot d

    • Other useful qemu options: -m 512 and -enable-kqemu

  4. Installation steps:

    • First boot:

      • Select disk

      • "2" (manual partitioning)

      • "y" (initialize MBR)

      • In fdisk:

        • > auto hfs

        • Ignore the warning

        • > update

        • > write

        • > quit

      • Enter partition name

      • "yes" (clean install)

      • "darwin" (volume name)

      • Continue (reboot)

    • Second boot (make sure to boot from CD again):

      • Select disk

      • "3" (existing partition)

      • Enter partition name

      • "hfs" (HFS+ filesystem)

      • "yes" (clean install)

      • "darwin" (volume name)

      • Wait for installation to complete...

      • Enter root password

      • "darwin" (hostname)

      • "3" (spawn shell)

      • # halt

  5. Configure VM for normal startup:

    • Remove QEMU flags -cdrom darwinx86-801.iso -boot d

Basic configuration

Enable VM networking

  • Change QEMU flags: -net none → -net nic,model=rtl8139 -net user

SSH access

  1. Change QEMU flags: -net user → -net user,hostfwd=tcp:127.0.0.1:10022-:22 (pick any port instead of 10022)

  2. Log in to VM, enable SSH:

    • # service ssh start

  3. Connect to VM with

    • $ ssh -p 10022 root@localhost

  4. Optionally add an alias to host ~/.ssh/config to simplify connecting:

    • Host darwin-vm
      HostName localhost
      Port 10022
      User root
    • Connect to VM with

      • ssh darwin-vm

  5. Install public key to simplify logging in:

    • $ cat .ssh/id_rsa.pub | ssh darwin-vm 'mkdir .ssh; cat >>.ssh/authorized_keys'

  6. Add -nographic to QEMU flags to disable console window, which is no longer required

Some familiar aliases

  • # echo "alias ll='ls -l'" >>/etc/bashrc

  • # echo "alias la='ls -lA'" >>/etc/bashrc

Timezone

  • # ln -sf /usr/share/zoneinfo/UTC /etc/localtime

Temporary filesystem

Using a temporary disk image to build software helps keep the main disk image file smaller.

  1. $ qemu-img create -f qcow2 scratch.qcow2 10G

  2. Add QEMU flag: -drive file=scratch.qcow2,cache=writeback and boot

  3. Figure out which disk number corresponds to the scratch drive:

    • # mount

    • # ls /dev/rdisk*

    • It's the one that isn't mounted and doesn't have any partitions (sn-suffixed files)

    • It's usually, but not always, /dev/rdisk1

  4. # newfs_hfs -v scratch /dev/rdisk1

  5. # reboot

  6. Available as /Volumes/scratch on next boot

Notes

  1. The VM sometimes fails to boot with "panic(...): nfs_boot_init failed"; if this happens, restart it.

Updating the system

Kernel (xnu)

  • It breaks support for FAT (and thus the QEMU virtual FAT drive)

    • Support for FAT is in the msdosfs package which requires Xcode to build

    • An alternative to the virtual FAT drive for transferring files is writing tar archives directly to an unpartitioned drive

    • SSH scp is another alternative

  • Requires:

    • corresponding cctools (e.g. initially installed version or cctools-590.42.1, but not cctools-667.3)

    • gcc 3.3 (revert if changed with gcc_select 3.3)

  • Source package: xnu-792.6.76.tar.gz (update to version listed under “Mac OS X 10.4.3”)

    • MD5: 854f44519778e8bde4283e275ed154e6

    • SHA-256: 35c5ed2f1399c770583a229a733d064dc302ae6327a7fcb40996e1f3c474f568

  • Building:

    • # cd /Volumes/scratch

    • # tar xzf xnu-792.6.76.tar.gz

    • # cd xnu-792.6.76

    • Patch to help build gcc_42-5577:

      • # sed -i.tmp 's/defined *(__i386__)/& || defined(__x86_64__)/' bsd/{machine,sys}/*.h

    • # make DSTROOT= install

  • Reboot. uname -r is now 8.7.0.

Standard library (Libc)

  • Requires updated xnu (xnu-792.6.761).

  • Source package: Libc-391.2.10.tar.gz (update to version listed under “Mac OS X 10.4.3”)

    • MD5: 7a1a08d1b68668fc41916d6cf39182a4

    • SHA-256: e90b78d310235544623f26c6f18e27b329b5bc778deab8e57332e8e90ab92f11

  • Building:

    • # cd /Volumes/scratch

    • # tar xzf Libc-391.2.10.tar.gz

    • # cd Libc-391.2.10

    • # sed -i.tmp s/NOTIFY_STATUS_OK/0/g gen/{asl.c,syslog.c}

    • Patch to help build gcc_42-5577:

      • # sed -i.tmp 's/defined *(__i386__)/& || defined(__x86_64__)/' include/machine/*.h

    • # make OBJROOT="$PWD"/obj install

Upgrading GCC

dyld

  • This is optional.

  • Source package: dyld-46.16.tar.gz (under “Mac OS X 10.4.11.x86”)

    • MD5: a97d4d2a77b3e5f2ff9757007cae0596

    • SHA-256: cf753c3a2cef239b1334c56603b36d206f54d613daa078ce0f2d73c3e2a0dd82

  • Makefile: dyld.mk

    • Darwin doesn't include Xcode, which is required to build this package. This makefile provides alternative build instructions.

  • Building:

    • # cd /Volumes/scratch

    • # tar xzf dyld-46.16.tar.gz

    • # cd dyld-46.16

    • # sed -i.tmp '/case CPU_TYPE_X86_64:/,/break;/d;/__pthread_tsd_first/d' src/dyld.cpp

    • # ln -s libstdc++.a /usr/lib/gcc/i686-apple-darwin8/4.0.0/libstdc++-static.a

    • # bsdmake -f dyld.mk VERSION_DYLD=46 install

cctools

  • Choice of version:

    • cctools-667.3

      • Too new to build xnu.

      • Source package: cctools-667.3.tar.gz (under “Mac OS X 10.5.8”)

        • MD5: 518166e6ddbd0287bebee3d00fddee7d

        • SHA-256: 1ba43a3d3bcf138a196e714666927c706857226adccf2e69db4f08e940631c0d

    • cctools-590.42.1

      • Too old to build gcc.

      • Source package: cctools-590.42.1.tar.gz (update to version listed under “Mac OS X 10.4.3”)

        • MD5: 6d875c5483699fd0f1e150facae35256

        • SHA-256: 61c86c4dc556daafbabebd8162bfbce8214843b218fefbd15c6c1ba03d225a10

  • Building:

    • # cd /Volumes/scratch

    • # tar xzf cctools-667.3.tar.gz

    • # cd cctools-667.3

    • # sed -i.tmp '/install.*strip/{h;s/strip/seg_hack/gp;g;s/ -s / /;}' misc/Makefile

    • # sed -i.tmp s/ld_classic/ld/ ld/Makefile

    • # make install

  • The new assembler will often show the warning "indirect jmp without '*'" on code generated by the old GCC.

gcc

  • Choice of version:

    • gcc_42-5577

      • Latests gcc_42 package (newer packages are named gcc). GCC 4.2.1. Requires patched system include files, which can be done when upgrading xnu and Libc (see above).

      • Source package: gcc_42-5577.tar.gz (update to version listed under “Mac OS X 10.5.8”)

        • MD5: dab7ad45f76919f058a6f1cf3a0e91d8

        • SHA-256: fd6459ab701b41dc1297cdbc27f302c558d766505cfe8dd1d6ec0d257fef0e81

    • gcc_42-5531

      • Slightly older version. Doesn't require any changes to include files.

      • Source package: gcc_42-5531.tar.gz (under “Mac OS X 10.5.8”)

        • MD5: 959ecd224cea2477d57b1c3026fe05ee

        • SHA-256: 924862e2092fa11754ec9226a0de4772d831c40500231728055d00d1bb3a632e

  • Requires cctools-667.3 and optionally dyld

    • Building:

      • # cd /Volumes/scratch

      • # tar xzf gcc_42-5577.tar.gz

      • # cd gcc_42-5577

      • If dyld isn't upgraded, patch to revert debugging format from DWARF to stabs:

        • # sed -i.tmp 's/\(#define PREFERRED_DEBUGGING_TYPE \).*/\1DBX_DEBUG/' gcc/config/darwin.h

        • # sed -i.tmp '/darwin_macho_att_stub/s/Init.*//' gcc/config/darwin.opt

      • # sed -i.tmp '/x86_64/s/|| exit 1//' build_gcc

      • # ln -s true /usr/bin/dsymutil

      • # gnumake RC_ARCHS=i386 install

        • Don't try to set DSTROOT=/, it deletes everything.

      • # cp -pR dst/* /

      • # cp -pR obj/dst-i686-i686/usr/lib/libgcc_s* /usr/lib/gcc/i686-apple-darwin8/4.2.1/

  • GCC is now installed as gcc-4.2.

    • It can be made default with gcc_select 4.2. 

       



       

       

       

Sunday, August 20, 2017

Installing Unidata Gempak on Debian.

To install gempak on Debian first download the Red Hat package from the Unidata website And then use Alien to install. I've only tested gempak-7.3.2-1.x86_64.rpm Or you can compile it from source. Here is some data And a tutorial More detailed directions later pretty self explanatory. And AWIPS

Adding the Kali archive keyring on Debian.

Here is the Debian package to add the Kali keyring to Debian. Here. Or the Kali Rolling repositories

Cretaing a Athena Machine with Debathena

On Debain Linux first install first install debathena as described at MIT 
Install MIT Kerberos:
 sudo apt-get install krb5-{admin-server,kdc}   
 
Make a backup of  /etc/krb5.conf and edit the krb5.conf
 [realms]  
   ATHENA.MIT.EDU = {  
     auth_to_local = RULE:[2:$1](johndoe)s/^.*$/guest/  
     auth_to_local = RULE:[2:$1;$2](^.*;admin$)s/;admin$//  
     auth_to_local = RULE:[2:$2](^.*;root)s/^.*$/root/  
     auto_to_local = DEFAULT
 } 

Next  create a KDC Database with:
 sudo kdb_util create -r ATHENA.MIT.EDU   

and enter a master password.
In your local state directory typically /var create krb5kdc/kadm5.acl
See and sample of a kadm5.acl file here.

Add the acl_file variable to krb5.conf file.
Next add administrators to the database:
 sudo kadmin.local  

 kadmin.local: addprinc admin/admin@ATHENA.MIT.EDU  

answer the prompts and add principals.
Lastley start the KDC with:

 sudo krb5kdc  
 sudo kadmind  

I still get an error on starting to the Raise Network interface but everything else  is up and running including your Athena lockers; might be an answer here and here.  And here Hope this helps. One other note here is LibX a Firefox add-on to search MIT Resources from anywhere

Saturday, July 29, 2017

My Custom Debian.

This morning I created my custom Debain distribution with 'simple-cdd' I still need to make my own package list. Follow these directions.

Monday, July 17, 2017

SELinux

After I installed Debian 9 I installed SELinux here is the Debian wiki on how to. Also here are the GUI tools. I first heard about SELinux about 10 years ago. Also here is article on anti-viris vs SELinux. And a little history Here is Sofos for Linux. And for Windows and Mac. Malwarebytes is good too for Mac and Windows.

Setting up my apt repository and build environment on Debian

I'm configuring my build environment on my new HP Debian machine here available on the wiki I also am outputing my installed packages on Debian using dpkg. And will write a script. I want to get working on KX Studio and some on my projects on github if I can find the extra time. And create my own PPA.

Tuesday, October 25, 2016

Desktop Environments

I'm trying the Gnome 3 desktop environment for Debian 8 and it really isn't that bad, reminds me of Windows 8/8.1. I'm using MATE in FreeBSD which is a for of Gnome 2. And starting with Vista Windows uses DWM I think or that might be like Xorg. They use Aero. Windows also uses the Windows bootloader and Linux GRUB. I really would like to be able to install the Windows desktop environment just like another environment like KDE or Gnome. I've forked the Budgie Desktop environment and made my own called Blueberry for Linux and Gnome Shell. I've also forked the Lumina desktop for BSD which is a low level C++ desktop environment. Fairly new.

Upgrade for Wheezy to Jessie

Yesterday I upgraded to Debian 8 "Jessie" which is now on the stable branch from "Wheezy" and my base image was "Squeeze". I also began reading about the systemd process and how it replaced "init". Also here is a source list generator from Switzerland.

Saturday, June 18, 2016

Microsoft Design Principles and Scenarios Star 2011

In 2011 I completed a course and in Microsoft's eyes became a design principles and scenarios star. More on this as I remember it, it was the design toolbox and I still have all of the files. And here was my avatar.

Friday, June 10, 2016

Building Singularity

In 02010 I downloaded and read about a Microsoft research OS called Singularity. Now I'm going to tell you how to build it. First you can download it from Codeplex here. Next unzip the RDK and right click on the "configure.cmd" and run as administrator, accept the defaults and press enter. This should place a Singularity shortcut on your desktop. Next open the the shortcut placed on your desktop and type "msb Distro\World.proj" allow about 25-30 min depending on your machine to build. After it is built you should be able to run it in a VM. I might go into more detail later. If you really want to have fun read up on MSBuild and and how to add you own CLI projects to the Applications folder. The Singularity build requires .NET 3.5.You also might need to add "C:\Windows System32;" to your PATH environment variables. You also can find many of the build tools like boogie and the CLR Profiler on Codeplex. You might want to sandbox your modifications so if Microsoft releases another Singularity variant in the future it will be compatible. Again read up on MSBuild. You can turn on your virus protection after the build. Because many viruses are written in assembly.



Tuesday, May 24, 2016

Future of Concurrency and Parallelism

Here is a Joe Duffy interview. I first read Concurrent Programming on Windows in 2013. Here are the CHESS Tools There is also Midori which I haven't heard that much about lately but there is a C# OS called Cosmos and MOSA. I really haven't had much time to work with CHESS. Other than to write my own MSBuild wrapper.

Sunday, May 15, 2016

COM

I first learned about Microsoft's Component Object Model in 1999. I read and learned the model through MSDN libraries and magazines. I think my first was a MSJ. I have all of my DVD archives. About three or four years ago I bought Don Box's "Essential COM".I partly read this book in an old MSDN library. And used Microsoft's M Language.

Wednesday, May 11, 2016

How to luanch the old style Control Panel in Windows 10.

To launch the old style Control Panel in Windows 10. You could go into the system files and find "control.exe" and pin it to the start menu. One good improvement in Windows 10 was the improvement to the environment variable settings. You can also launch the old -sytle control panel following this article.

Friday, May 6, 2016

MATE desktop environment and Slim

To install the MATE desktop environment and Slim so you can design your own Slim themes. Please no baby picture themes please. First "pkg delete" all of your old desktop environment packages and settings and then remove and unwanted dependencies with "pkg autoremove". The installation of a new desktop envirnoment is usually done after a clean install of FreeBSD. If some of the packages names change over time be sure to look them up on the freshports website.


Step 1:

 #pkg install xf86-video-fbdev mate-desktop mate xorg  

Step 2:

Add the following lines to /etc/rc.conf

 moused_enable="YES"  
 dbus_enable="YES"  
 hald_enable="YES"  

Step 3:

 #pkg install slim  

Step 4:

Add the following line to /etc/rc.conf

 slim_enable="YES"  

Step 5:

Create the following .xinitrc file in the user’s home directory and add the following line.

 exec mate-session  

Step 6:

You might have to configure slim by enabling the following line in your slim.conf file. Or if you are using bash enable it for bash.

 login_cmd   exec /bin/sh - ~/.xinitrc %session  

Reboot

Wednesday, May 4, 2016

Building Sandcastle Documentation in Visual Studio

Here is a nice article on building MSDN style documentation with sandcastle from The Microsoft Gulf Technical Community.

Why FreeBSD?

Here is an IBM article on why I kept choosing FreeBSD. There are differences in the kernel. And there isn't as much support like Linux as there should be.

Tuesday, May 3, 2016

Building the Windows Research Kernel.

To build the Windows research kernel after to obtain it legally from your academic institution like I did. You may need to download some Visual C/C++ runtime libraries but after that the kernel should kinda be sandboxed and build on Windows XP or later. I'm building it on Windows 8.1. We will be building WRKv1.2.

So open a command prompt and enter:

 set wrk= "path to WRK1.2"  
 set arch=x86 [or amd64]  
 path %wrk%\tools\%arch%;%path%  
 cd %wrk%\base\ntos  
 nmake -nologo %arch%=  

This will produce kernel files in BASE\NTOS\BUILD\EXE\%arch%

I really don't recommend booting the kernel on anything other than XP, but you can try and there should be instructions that came with the WRK 1.2 on how to do that. Pius you can read David Cutler's original design notes. Also you might get like I did a project called "Project OZ" which you can use the kernel with.



Cairo Dock and Plugins

The Cairo Dock and it's plugins need to be compiled from source. They are available in the ports at:

 /usr/ports/deskutils/cairo-dock  

and

 /usr/ports/deskutils/cairo-dock-plugins  

a simple "make install clean" for both will work. It may take about 30 mins or so depending on your machine. For the 3d effect select the 3d plane in the docks configuration settings. To tweak and remove the bottom toolbar use the "dconf editor". Finally add add the dock to your startup programs.

My very first FreeBSD Toolkit (no not from ebay)