• Hello MLAers! We've re-enabled auto-approval for accounts. If you are still waiting on account approval, please check this thread for more information.

Emulate Target Disk Mode PowerMac G4 PCI

Not harping, just having a little fun with the old saw about "if all you have is a hammer" on a weight class/misapplication of the many flavors of hammers theme.
Eh, sorry for being a bit of a grump. I think it was just reminding me of the times you end up having to explain the concept of "joke's over now" to the kids when they through hysterical tears throw out the same witticism for 20 minutes straight. ;)

Still downloading the bits to take a crack at this. I kind of wish I had a firewire-bootable Mac that can run OS 9 lying around, I'd love to see if it could boot the QEMU image I coincidentally just put together. Action plan is to try sharing a Tiger .iso and see if I can boot, and if it works share a 20GB-ish blank image and see if I can install to it over the same wire...

 
Harumph! The second jibe was an oblique compliment to G. What's non-trivial enough to be interesting for him to wield his sledge like powers to do something way cool is far beyond what I would think is a very large majority of us. Mine isn't even a tack hammer in his world, can't wait to see what happens. [:P]

 
In any case, the reason I think this is interesting, particularly if you *do* happen to have a laptop with a firewire port, is if it really works it potentially would make it possible to lug around a complete library of "rescue disks" you can use to start up any firewire bootable Mac in one little package... which at the same time can also remain usable as a computer.
I like this idea! I already have a USB/Firewire external drive that has different OS installs and CCC to blow them onto a computer, but this would add more flexibility.

 
So, after a lot of head-scratching about how to set things up if you want to offer more than one volume (there's basically no user-level documentation for the Firewire target module so I had to trial and error it a little) I think I totally have it working. I have my Linux machine sharing two virtual drive files; one is a Tiger 10.4.6 DVD image (the one that's on "The Garden", converted from a DMG to a raw image with dmg2img) and the other is a 24GB blank file I generated with DD. With this configuration I was able to boot the installation disk by holding down the option key and choosing it from the selector. Once booted up I was able to partition and format the blank image in Disk Utility (pardon the cruddy phone images):

Linux_Firewire_DU.jpg

And was able to sic the installer on the resulting drive:

Linux_Firewire_Inst.jpg

(The built-in drive on the laptop decided to start showing up after the machine was power-cycled a few times, but it's very sad. Attempting to boot from it causes OS X to crash to the text console with repeated write_errors spamming the screen, and it also errors out if I put the machine in target disk mode and try to mount it from another box)

The installer is still running; performance is definitely nothing to write home about, but that's no doubt at least in part due to two factors: the iSCSI infrastructure defaults to and strongly recommends using unbuffered I/O when using disk files instead of block devices to lesson the risk of catastrophic corruption in the case of a host crash, and the old Mac Pro this is running off of has a *very, very, VERY* slow drive in it. I'll update when it's done as to whether I get a working OS install out of it.

 
What's non-trivial enough to be interesting for him to wield his sledge like powers to do something way cool is far beyond what I would think is a very large majority of us.
*snicker* I *do* like swinging around the old sledge. Especially at houseflies, which can sometimes be a problem...

Still installing. Offhand observation: seriously, if I'm going to keep using this Mac Pro I need to get it something that can handle more iops than the ancient WD5000AAKS that's still chugging along in this wreck. Serving the Mac busily running its installer off the firewire drags the whole thing to screeching halt.

 
Still installing.
And of course almost to the very second I hit submit on this post the installer finished and rebooted.

It worked! I got the usual user creation/registration dialog, and after that it even found some software updates.

Linux_Firewire_done.jpg

I'll post some data from the Linux box shortly about the details of the server setup in case anyone wants to try to replicate it.

 
Thank you, I imagine it will be very slow for me too :(. Oh well, still very interesting to know you can do such a thing. I love "hacks" like this. 

 
Server is Ubuntu Linux 16.04 LTS. Any recent Linux will probably work, although it looks like kernel version 3.5 or greater is more likely to have the full stack of driver modules. (It looks like *maybe* they were backported to some earlier kernels but, as noted, docs suck?) Make sure Linux is seeing your firewire interface before you start anything else.

After doing a "modprobe sbp_target" to enable the target code and the rest of the iscsi backend infrastructure I used the following code to share the CD image. (Disk images are in /home/disks/ in this case. The /sys/kernel/config" directory is a virtual filesystem that's created after you load the sbp_target module, unless you already had something else running that enabled it.)
 

Code:
#!/bin/bash
mkdir -p /sys/kernel/config/target/core/fileio_0/tigercd
echo "fd_dev_name=/home/disks/tigercd.img,fd_dev_size=3791523840" > /sys/kernel/config/target/core/fileio_0/tigercd/control
echo 1 > /sys/kernel/config/target/core/fileio_0/tigercd/enable
 
# Create and enable the sbp2 target
mkdir -p /sys/kernel/config/target/sbp/001b63fffe712bb4/tpgt_1
mkdir -p /sys/kernel/config/target/sbp/001b63fffe712bb4/tpgt_1/lun/lun_0
ln -s /sys/kernel/config/target/core/fileio_0/tigercd /sys/kernel/config/target/sbp/001b63fffe712bb4/tpgt_1/lun/lun_0/
echo 1 > /sys/kernel/config/target/sbp/001b63fffe712bb4/tpgt_1/enable
Note that I did a "chmod -w /home/disks/tigercd.img" to make sure it was read only. There may be another CTL for that but it seemed to work fine. Note the "dev_size" argument when creating the fileio object, I got that number from an "ls -al".

Here is the code for the blank disk, which I created with "dd if=/dev/zero of=/home/disks/24g.img" -bs=1G count=24":
 

Code:
#!/bin/bash
mkdir -p /sys/kernel/config/target/core/fileio_1/24g
echo "fd_dev_name=/home/disks/24g.img,fd_dev_size=25769803776" > /sys/kernel/config/target/core/fileio_1/24g/control
echo 1 > /sys/kernel/config/target/core/fileio_1/24g/enable
 
# Create and enable the sbp2 target
mkdir -p /sys/kernel/config/target/sbp/001b63fffe712bb5/tpgt_1
mkdir -p /sys/kernel/config/target/sbp/001b63fffe712bb5/tpgt_1/lun/lun_0
ln -s /sys/kernel/config/target/core/fileio_1/24g /sys/kernel/config/target/sbp/001b63fffe712bb5/tpgt_1/lun/lun_0/
echo 1 > /sys/kernel/config/target/sbp/001b63fffe712bb5/tpgt_1/enable
The part that confused me the most was whether if I wanted to share multiple devices if I had to do them as multiple LUNs off the same sbp target UUID or if I could create multiple UUIDs and they'd just all attach to the firewire bus. This confusion was in part because the example floating around used the system UUID Linux applied to the physical firewire controller at bootup, so I thought that might be necessary to tag the share to a given firewire controller. The answer appears to be no: UUIDs need to be in the correct format, but other than that seem like they can be arbitrary. So in this example you'll see I incremented the UUID for the emulated "hard disk" by one compared to the boot CD. So, yeah, it looks like the right way is to do that, not LUNs. (I got weird results with LUNs, IE, in the boot selector on the Mac I just got two icons for the contents of the first LUN, not the CD-ROM image and disk drive as separate units.)

Just for fun I installed "targetcli", which is the interactive shell for manipulating the iscsi LIO backend, and here's what it shows:
 

Code:
$ targetcli
targetcli 3.0.pre4.1~ga55d018 (rtslib 3.0.pre4.1~g1b33ceb)
Copyright (c) 2011-2014 by Datera, Inc.
All rights reserved.

/> ls
o- / ......................................................................................................................... [...]
  o- backstores .............................................................................................................. [...]
  | o- fileio .................................................................................................. [2 Storage Objects]
  | | o- 24g .................................................................................. [24.0G, /home/disks/24g.img, in use]
  | | o- tigercd ........................................................................... [3.5G, /home/disks/tigercd.img, in use]
  | o- iblock ................................................................................................... [0 Storage Object]
  | o- pscsi .................................................................................................... [0 Storage Object]
  | o- rd_mcp ................................................................................................... [0 Storage Object]
  o- ib_srpt ........................................................................................................... [0 Targets]
  o- iscsi ............................................................................................................. [0 Targets]
  o- loopback .......................................................................................................... [0 Targets]
  o- qla2xxx ........................................................................................................... [0 Targets]
  o- tcm_fc ............................................................................................................ [0 Targets]
  o- usb_gadget ........................................................................................................ [0 Targets]
  o- vhost ............................................................................................................. [0 Targets]
/>
It's "interesting" that it shows the backend file stores but doesn't seem to know about the sbp_target target bus. I don't know if there's a way to fix that or if it's just an ugly stepchild.

Performance seems to be "okay" now that it's installed if I don't do anything else at the same time. I guess making one old spindle pretend to be the installation CD, the target disk, *and* serve Linux's needs was a lot to ask. Installation of the updates went fine.

So, yes, you can emulate Target Disk Mode with an arbitrary computer, apparently. Now I really do wish I had a Classic OS-bootable Mac to play with...

 
Last edited by a moderator:
... FWIW, I've ordered a new 4-to-6 pin Firewire cable just for laughs to see if I can replicate this setup on the aforementioned Thinkpad. Granted its performance is likely to be even worse than the old Mac Pro with its laptop vs. desktop spindle, but it should work as a platform for replicating the results. SSDs are cheap these days, and I suspect that would solve a lot of the performance problems.

I also ordered another thing that might be interesting, but I'll talk about that when I get it...

 
.... Ye, gads, TenFourFox is painful on a machine with only 512MB of RAM. (And here comes another *sigh*: it's now official, every single 15" PowerBook G4 I've owned with a CPU speed between 1.33Ghz and 1.5Ghz has had a memory slot go bad. These things really were the pits. Time to crack it open and see if this had two 512s or, if I'm lucky, a 1GB and a 512MB that I can swap sockets.)

But, yes, it works from a Linux target drive. Mission accomplished.

 
Definitely update if anyone else has success with this. Again, I'm really interested to see if it works on an OS 9-bootable machine.

If anyone wants to thank me for testing this out I could use a 1GB PC2700 SO-DIMM for my broke-@ss Powerbook... ;)

 
Last edited by a moderator:
something that can handle more iops than the ancient WD5000AAKS that's still chugging along in this wreck
Wow! I remember when those were new!! (I bought one to *upgrade* a PC I'd built back in '08 or so because I was stuck with an 80 GB somethingorother, and it was feeling rather slow and cramped). Guess that shows how quickly things move in computer land....

c

 
Wow! I remember when those were new!!
I think it's one of the drives that came in the machine when it was new, so... yeah, it's probably seriously on borrowed time.

Just an offhand note, for fun I tried sharing a Linux .iso via firewire using the same technique I outlined above, and it also worked fine. (IE, was able to boot from it with no problems on the PowerBook just by holding option and selecting it from the boot manager.) All indications are this is a perfectly valid universal substitute for a Firewire disk or optical drive if you happen to have a Linux machine with an IEEE1394 port lying around.

(During the same session I also booted from the Tiger image I'd created on the server and used it to do a partial Carbon Copy Cloner restore of some files I had on an old disk image to the SSD in the PowerBook. Now I have Classic support and a pile of old games on it. Woot. Now I just need to find some @#$!ing RAM...)

 
Back
Top