Strotmann.de

Wednesday May 08, 2013

Cloning MacOS X from Linux

I just finished to work out a way to clone a MacOS X installation from Linux (for automatic installation of MacOS X with fai -- fully automatic installation). All tools discussed in the article are available in Debian 7.x (wheezy).

Backup

First we save the GUID (Globally Unique Identifier) Partition Table (GPT), so that we can restore the same partition table on the target machine. We use the commandline version of gdisk for this, named sgdisk

sgdisk --backup=/srv/macos/parttable.gpt.sgdisk /dev/sda

The content of the partitions can be cloned using the partclone tool. A default MacOS X installation has three partitions:

  1. EFI system partiton
  2. MacOS X (named "Customer")
  3. Recovery partition

Model: ATA APPLE HDD HTS547 (scsi)
Disk /dev/sda: 976773168s
Sector size (logical/physical): 512B/4096B
Partition Table: gpt

Number  Start       End         Size        File system  Name                  Flags
 1      40s         409639s     409600s     fat32        EFI system partition  boot
 2      409640s     975503591s  975093952s  hfs+         Customer
 3      975503592s  976773127s  1269536s    hfs+         Recovery HD

First we create backup images of all partitions:

partclone.vfat -I -c -s /dev/sda1 | gzip > /srv/macos/sda1.partclone.gz
partclone.hfsplus -I -c -s /dev/sda2 | gzip > /srv/macos/sda2.partclone.gz
partclone.hfsplus -I -c -s /dev/sda3 | gzip > /srv/macos/sda3.partclone.gz

Restore

To restore the saved MacOS X installation, boot another Mac using Linux (a Knoppix live Linux DVD will work).

Next we restore the partition table (GPT) using sgdisk (/dev/sda is the target disk, all data on that disk will be erased, be warned!):

sgdisk --load-backup=/srv/macos/parttable.gpt.sgdisk /dev/sda
partprobe

as an alternative, the partitions can be created using parted and the GUID type codes set by sgdisk (important!):

sgdisk --zap /dev/sda
parted -s /dev/sda mklabel gpt
parted -s /dev/sda mkpart primary 40s 409639s
parted -s /dev/sda name 1 "'EFI system partition'"
parted -s /dev/sda set 1 boot on
parted -s /dev/sda mkpart primary 409640s 975503591s
parted -s /dev/sda name 2 "'MacOS X System'"
parted -s /dev/sda mkpart primary 975503592s 976773127s
parted -s /dev/sda name 3 "'Recovery HD'"
sgdisk -t 1:C12A7328-F81F-11D2-BA4B-00A0C93EC93B /dev/sda
sgdisk -t 2:48465300-0000-11AA-AA11-00306543ECAC /dev/sda
sgdisk -t 3:48465300-0000-11AA-AA11-00306543ECAC /dev/sda
partprobe

Restore the partition content:

zcat /srv/macos/sda1.partclone.gz | partclone.vfat -r -o /dev/sda1
zcat /srv/macos/sda2.partclone.gz | partclone.hfsplus -r -o /dev/sda2
zcat /srv/macos/sda3.partclone.gz | partclone.hfsplus -r -o /dev/sda3

If all went well, the new disk is ready to boot MacOS X.

For reference, here are the GUID details of a default MacOS X 10.8 MacBook Pro install:

root@(none):~# sgdisk -p /dev/sda
Disk /dev/sda: 976773168 sectors, 465.8 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 497736B0-7EA0-4C45-AB5F-8841CD773D24
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 976773134
Partitions will be aligned on 8-sector boundaries
Total free space is 262157 sectors (128.0 MiB)

root@(none):~# sgdisk -i1 /dev/sda
Partition GUID code: C12A7328-F81F-11D2-BA4B-00A0C93EC93B (EFI System)
Partition unique GUID: 6749C82F-02C9-4FF5-A889-F31A21726F8E
First sector: 40 (at 20.0 KiB)
Last sector: 409639 (at 200.0 MiB)
Partition size: 409600 sectors (200.0 MiB)
Attribute flags: 0000000000000000
Partition name: 'EFI system partition'

root@(none):~# sgdisk -i2 /dev/sda
Partition GUID code: 48465300-0000-11AA-AA11-00306543ECAC (Apple HFS/HFS+)
Partition unique GUID: 60F7A3AA-69B3-4E59-87A0-3A47BB659255
First sector: 409640 (at 200.0 MiB)
Last sector: 975241447 (at 465.0 GiB)
Partition size: 974831808 sectors (464.8 GiB)
Attribute flags: 0000000000000000
Partition name: 'MacOS X System'

root@(none):~# sgdisk -i3 /dev/sda
Partition GUID code: 48465300-0000-11AA-AA11-00306543ECAC (Apple HFS/HFS+)
Partition unique GUID: FD007AA4-CF3A-42F6-BFC6-B3BC25521FC2
First sector: 975503592 (at 465.2 GiB)
Last sector: 976773127 (at 465.8 GiB)
Partition size: 1269536 sectors (619.9 MiB)
Attribute flags: 0000000000000000
Partition name: 'Recovery HD'

Tuesday Apr 02, 2013

One-Liner: dump screens from a Forth block file

I occasionally need to convert Forth block files (from VolksForth) to plain text files (to use diff or other tools). This one-liner using gforth does the trick:

#!/bin/sh
gforth -e "use ${1} : dump-blocks 0 do i list loop ; : blocks get-block-fid file-size drop d>s 1024 / ; blocks dump-blocks bye"
Save in a script file (dump-blocks), make it executable, and then you can use
# dump-blocks 6502f83.fb > 6502f83.fs

Thursday Jan 17, 2013

FireBee Diary 2: from MC68000 to ColdFire

To get volksForth running on the FireBee, the machine code instructions that are available on the MC68000, but not in the ColdFire CPU need to be replaced with a series of instructions that perform the same action.

I found the "Digger V8" dissassembler on Heenk Robbers webpage along with the AHCC C-Compiler. The Digger is able to disassemble both ColdFire and MC68000, and it can switch between the two CPU types with a simple switch. Finding instructions that cannot be executed on the ColdFire is now only a matter of switching the CPU type and watching the assembler code change.

The Digger package also contains a list of all M68000 assembler instructions, with information on the instructions available on each CPU type (MC68000, MC68020, MC68030, ColdFire …).

I made the table below as a quick look-up tool to find MC68000 instructions that need replacement on the ColdFire (this table is still work in progress, the column "workaround" will be filled while I work on the ColdFire porting project):

Opcodepossible workaroundDescription
ori -> ccrOR immediate to CCR
ori -> srOR immediate to Status Register
andi -> ccrAND immediate to CCR
andi -> srAND immediate to Status Register
eori -> ccrEOR immediate to CCR
eori -> srEOR immediate to Status Register
movepMove peripheral data
trapvTrap on Overflow
rtrReturn and restore condition codes
chk.wCheck register against bounds
dbccTest condition, decrement and branch
sbcd Dx,DySubtract decimal with extend
sbcd -(Ax),-(Ay)Subtract decimal with extend
suba.wSubtract address
subx -(Ax),-(Ay)Subtract extended
lineaLINE-A access
abcd Dx,DyAdd decimal with extend
abcd -(Ax),-(Ay)Exchange registers
exg Dx,DyExchange registers
exg Ax,AyExchange registers
exg Dx,AyExchange registers
adda.wAdd address
addx -(Ax),-(Ay)Add extended
roxlRotate left with extend
roxrRotate right with extend
rolRotate left
rorRotate right
aslArithmetic shift left
asrArithmetic shift right
lslLogical shift left
lsrLogical shoft right

Saturday Jan 05, 2013

Firebee Developer Diary 1

On the last day of 2012, Stefan (aka Beetle) brought me the FireBee machine that we both share. I've been programming Atari 8bit machines for over 25 years now, but this is the first time that I enter the realm of the Atari ST family with a 68K or now ColdFire. There is much to learn.

My FireBee Development setup

The FireBee is a modern incarnation of the Atari ST computer line, including Ethernet, USB, CF-Card and SD-Card interfaces. A modern computer. And it still runs Atari TOS programs.

[Read More]

Monday Jul 30, 2012

XCode 4.4 update does not install command line tools (gcc, clang ...)

After upgrading to MacOS X 10.8 (Mountain Lion) and XCode 4.4 through the Apple App store, I found myself unable to compile software on the command line. Apple has split the command line tools in to a separate download, accessible via the MacOS Dev Center download page:

screen shot 2012-07-30 at 3.20.12 pm.png

Dashcode and auxiliary tools like PackageMaker are now also separate downloads and not in the main XCode install anymore.

Sunday Mar 18, 2012

CamelForth auf dem TI Launchpad MSP430 unter Linux

Dirk Brühl und Michael Kalus haben das CamelForth vom Brad Rodriguez für das TI Launchpad Board angepasst. Das 4€4th Projekt hat eine eigene Webseite auf http://www.4e4th.eu. Auf der Webseite der Forth-Gesellschaft e.V. gibt es Neuigkeiten zum TI Launchpad und CamelForth (aka 4€4th): http://www.forth-ev.de/index.php?topic=launchpad.

Die Quellen und die aktuelle HEX-Download Datei findet sich im SVN Repository der Forth-Gesellschaft unter http://forth-ev.de/repos/CF430G2553/ in der Datei CF430G2553.a43.

.

Unter Linux kann diese HEX-Datei mit dem Flasher-Programm mspdebug auf das Launchpad geladen werden (Version 0.19 oder später):

$ sudo /usr/local/bin/mspdebug rf2500 "prog CF430G2553.a43"

Unter Linux meldet sich das TI Launchpad meist unter /dev/ttyACM0, jedoch kann es sein das bei modernen Linux Systemen Hintergrundprogramme (wie der ModemManager) sofort diese Schnittstelle belegen und versuchen das LaunchPad als Modem anzusprechen (Siehe Linux today: too much plug and play).

Das CamelForth auf dem TI Launchpad kann mit einem Terminal-Programm abgesprochen werden.

Anleitung zum Bauen des CamelForth aus den Quellen, und die Programmierung des TI Launchpad unter MacOS X oder Windows befinden sich im Wiki der Forth Gesellschaft unter http://www.forth-ev.de/wiki/doku.php/projects:4e4th:start.

Das CamelForth für das LaunchPad befindet sich derzeit (März 2012) in aktiver Entwicklung, es sind in den kommenden Wochen noch Verbesserungen und Änderungen zu erwarten.

Hilfe zum CamelForth auf dem Launchpad und zu Forth allgemein gibt es in deutscher Sprache im Usenet unter de.comp.lang.forth.

Monday Mar 05, 2012

Ein durchschnittlicher Font für diese Webseite ...

Gibt es etwas besseres als den echten Durchschnitt? Der Zeichensatz Averia zeigt, das auch der Durchschnitt interessant sein kann.

Wednesday Dec 28, 2011

amForth Hex-Dateien für Arduino Boards

Eine komplette Toolchain zum Kompilieren von amForth aufzubauen ist eine grosse Einstiegshürde (wine, AvrStudio ...), speziell wenn, wie im Falle von amForth, nicht-freie Bestandteile aus dem ATMEL SDK besorgt werden müssen. Dies ist speziell unter Linux und MacOS X doch recht aufwendig.

Ich stelle die von mir erstellten Hex-Dateien des amForth für Arduino Duemilanove (und Uno) zur Verfügung. Diese Hex-Dateien können direkt per Programmer auf einen Arduino aufgespielt werden (siehe vorherige Posts zum Thema amForth).

Download: amForth Hexfiles für Arduino

Wednesday Dec 14, 2011

Terminal Emulatoren für Forth Systeme über serielle USB-Schnittstellen (amForth)

Eine Übersicht von Terminal-Programmen unter Unix/Linux für echte serielle Schnittstellen oder für USB-serielle Verbindungen. Damit kann man wunderbar Verbindungen zu amForth oder anderen Mikrokontroller-Forth-Systemen herstellen ...[Read More]

Monday Dec 12, 2011

amForth auf den Arduino Duemilanove aufspielen

Wie bekommt man das amForth auf den Arduino Duemilanove um das Morse-Programm laufen zu lassen. Dies sind die Schritte die ich für jedes Arduino-Board vor Beginn eines Workshops durchführe ...[Read More]

Sunday Nov 06, 2011

amForth Morse Code

Der Quellcode des Morse-Programms auf dem Arduino mit dem Spark-Fun Dangershield[Read More]

Saturday Nov 05, 2011

Vortrag BLIT Potsdam November 2011: amForth auf dem Arduino - Ausbruch aus dem Edit-Compile-Upload Kreislauf

Mein Vortrag vom 5. November 2011 auf den Brandenburger Linux Info Tagen 2011 zum Thema "amForth auf dem Arduino - Ausbruch aus dem Edit-Compile-Upload Kreislauf". Der komplette Quellcode findet sich im Posting vom Sonntag.[Read More]

Monday Oct 10, 2011

42 - there are no questions only answers ... ?

[...]
There are no answers, only questions
And we're all strangers to the truth
But in my mind's eye
I have found the reason why
And I carry the burden of the proof.
No Answers Only Questions/Alan Parsons Project

Tuesday Sep 13, 2011

Server on the road...

Have moved my servers from Frankfurt to Münster the last two days. All seems well so far, E-Mail is coming in and the blog is online again.

Thanks to the nice people from st-oneline the move has been smooth experience.

Tuesday Aug 16, 2011

Recovering Atari ST 1st Word+ Documents

I've been asked to recover some 1st Word+ Documents from 3½" disk drives. Before starting up one of my old Atari ST machines, I was trying to get the job done using Linux. And it worked quite well. Here is how:

Atari ST disk are formatted using a flavor of the FAT file system. Most of the time, it is possible to read this disks under Linux. The 'mtools' package contains tools to read and write FAT formatted floppy disks, without the need to rely on a file-system driver (the 'mtools' package is available in most Linux distributions. For Ubuntu Linux, execute "sudo apt-get install mtools" to install).

For reading old floppy disks, I recommended to use old style floppy disks, no modern USB-Floppy disks which can often only read standard PC formats. I've used a build-in 3½" floppy drive inside a trusty old IBM ThinkPad T20 running Ubuntu 11.04.

Before reading the files from an Atari ST disk, I configure 'mtools' to skip the check for the floppy format. The FAT format on Atari ST disks is somewhat non-standard, which can trick the 'mtools':

Add to /etc/mtools.conf

MTOOLS_SKIP_CHECK=1

The mtools manual page documents:

MTOOLS_SKIP_CHECK: If this is set to 1, mtools skips most of its sanity checks. This is needed to read some Atari disks which have been made with the earlier ROMs, and which would not be recognized otherwise.

Next, make sure that the floppy kernel driver module is loaded. It seems that modern Linux systems do not load the driver for floppy disk anymore:

# sudo lsmod | grep floppy
# sudo modprobe floppy
# sudo lsmod | grep floppy
floppy                 60032  0 

Then I set the floppy drive parameters fixed for a 720kb floppy. The 'setfdprm' command is part of the 'fdutils' package:

# sudo setfdprm /dev/fd0 "720/720"

The command "mdir a:" should now show the directory content of the floppy disk. The floppy disk files can now be copies over to the Linux harddrive using 'mcopy':

# mkdir atari-st-floppy
# cd atari-st-floppy
# mcopy a:*.* .

Converting 1st Word+ documents into RTF

Rich Text Format (RTF) is a standard format for text documents. Using tools like UnRTF, RTF documents can be easly converted into other formats. RTF can be read my most modern text-processing packages such like LibreOffice and AbiWord.

'wpls2rtf' is a small commandline tools that can translate 1st Word+ files into RTF documents. The original source can be found at ftp://ftp.funet.fi/pub/atari/util/wpls2rtf.zip. Using this tool, I was able to convert the old Atari ST documents into files that can be read and edited on modern systems.

Calendar

Feeds

Search

Links

Navigation

Info