tricks

3TB Disk

I bought an external 3TB disk and wanted to attach it to an old Airport Extreme. It wouldn’t see the disk. Turns out the disk is formatted for windows.

Okay, Diskutil to the rescue!

Not, I kept getting:

Running operation 1 of 1: Erase “Untitled”…
Unmounting disk
MediaKit reports not enough space on device for requested operation.
Operation failed…

A quick consultation of the Internet Oracle turned up:

MediaKit reports not enough space on device for requested operation.

Okay, but I wanted case sensitive, so:

loghyr:~ loghyr$ diskutil list
/dev/disk0 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *1.0 TB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_APFS Container disk3 1000.0 GB disk0s2

/dev/disk1 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *1.0 TB disk1
1: EFI EFI 209.7 MB disk1s1
2: Apple_APFS Container disk2 1000.0 GB disk1s2

/dev/disk2 (synthesized):
#: TYPE NAME SIZE IDENTIFIER
0: APFS Container Scheme – +1000.0 GB disk2
Physical Store disk1s2
1: APFS Volume EVO1 703.1 GB disk2s1

/dev/disk3 (synthesized):
#: TYPE NAME SIZE IDENTIFIER
0: APFS Container Scheme – +1000.0 GB disk3
Physical Store disk0s2
1: APFS Volume EVO2 157.6 GB disk3s1
2: APFS Volume Preboot 19.6 MB disk3s2
3: APFS Volume Recovery 506.6 MB disk3s3
4: APFS Volume VM 3.2 GB disk3s4

/dev/disk4 (external, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *3.0 TB disk4
1: Apple_HFS 3.0 TB disk4s1

loghyr:~ loghyr$ diskutil unmountDisk force disk4
Forced unmount of all volumes on disk4 was successful

loghyr:~ loghyr$ sudo dd if=/dev/zero of=/dev/disk4 bs=1024 count=1024
1024+0 records in
1024+0 records out
1048576 bytes transferred in 0.452265 secs (2318499 bytes/sec)

Here is where I differ from the link:

loghyr:~ loghyr$ diskutil partitionDisk disk4 GPT JHFSX MacBackAttack 0g
Started partitioning on disk4
Unmounting disk
Creating the partition map
Waiting for partitions to activate
Formatting disk4s2 as Mac OS Extended (Case-sensitive, Journaled) with name MacBackAttack
Initialized /dev/rdisk4s2 as a 3 TB case-sensitive HFS Plus volume with a 229376k journal
Mounting disk
Finished partitioning on disk4
/dev/disk4 (external, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *3.0 TB disk4
1: EFI EFI 209.7 MB disk4s1
2: Apple_HFS MacBackAttack 3.0 TB disk4s2

 

Getting mail clients to work with domains at Gmail

My work email is Thomas.Haynes@example.org and is actually maintained at gmail.com.

Both Mail.app and mutt have had a hard time configuring for it.

For Mail.app:

  1. Set it up as normal for a Google IMAP account.
  2. Then go to Mail -> Preferences, select the account.
  3. Then on the “Outgoing Mail Server (SMTP):”, select by left click the server
  4. and then “Edit SMTP Server List …”.
  5. Now, select the server again
  6. First you’ll want to change the “Description” to be “Example.org” (this is in the “Account Information”)
  7. Second you will want to select Advanced
  8. Third, change the “User Name:” from “First.Last@gmail.com” to be “First.Last@example.org”

It should work now

For mutt, I followed the directions at Consolify your Gmail with MUTT with the exception of the following line:

set smtp_url = "smtp://yourusername@smtp.gmail.com:587/"

I modified it to be:

set smtp_url = "smtp://First.Last@example.org@smtp.gmail.com:587/"

 

Making a patch set

Get a clone and make a new branch:

290 21:08 git clone git://linux-nfs.org/~steved/cthon04.git
291 21:08 cd cthon04
292 21:08 git branch FreeBSD
293 21:08 git checkout FreeBSD
294 21:08 git branch

Edit your files and commit the changes:

299 21:09 git commit -a

Make the patch set:


303 21:15 git format-patch --cover-letter -s -n master..FreeBSD

Edit the cover letter to document your changes:

309 21:20 vi 0000-cover-letter.patch

Send the changes:


311 21:21 git send-email --smtp-encryption=tls --smtp-server=smtp.gmail.com --smtp-user=<user>@gmail.com --smtp-server-port=587 --to "<owner>" 000*

Note, while you might use a different email address inside the cover letter, it will still go out as from the user being referenced above. I.e., use the real smtp-server if you don’t want to expose your gmail account.

Note, you might have to install git-mail to do it this way. You can mail the patch set in many different ways.

Don’t whine about wget on OS X

OS X: Using curl instead of wget

Or:

loghyr:xdr thomas$ wget http://www.ietf.org/rfc/rfc1094.txt
-bash: wget: command not found
loghyr:xdr thomas$ curl -L http://www.ietf.org/rfc/rfc1094.txt > nfsv2.x
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 49940  100 49940    0     0  97348      0 --:--:-- --:--:-- --:--:--  140k

Building SlugOS 5.3-beta on Fedora Core 14

  102  yum install help2man
  104  yum install texi2html
  116  yum install glibc-static
  117  vi /kanigix/slugos/5.3/slugos-nslu2be.tmp/work/x86_64-linux/unifdef-native-2.6.18+git-r0/unifdef.c

The last was to change getline() to getline2() to avoid a conflict.

Very nasty one here for this message:

[tdh@wont 5.3]$ more /kanigix/slugos/5.3/slugos-nslu2be.tmp/work/armv5teb-linux-gnueabi/linux-libc-headers-2.6.23-r3/temp/log.do_configure.13663
NOTE: make -e MAKEFLAGS= allnoconfig ARCH=arm
Makefile:416: *** mixed implicit and normal rules.  Stop.
FATAL: oe_runmake failed

(Note: You could probably build easier against make-3.81 instead of make-3.82 !)

Edit these two files to apply this diff:

[tdh@wont 5.3]$ find . -name Makefile | grep glibc | grep  manual./slugos-nslu2be.tmp/work/armv5teb-linux-gnueabi/glibc-initial-2.6.1-r15/glibc-2.6.1/manual/Makefile
./slugos-nslu2be.tmp/work/armv5teb-linux-gnueabi/glibc-2.6.1-r15/glibc-2.6.1/manual/Makefile

And also apply this patch to

/kanigix/slugos/5.3/slugos-nslu2be.tmp/work/armv5teb-linux-gnueabi/linux-libc-headers-2.6.23-r3/linux-2.6.23/Makefile
[tdh@wont linux-2.6.23]$ diff -u Makefile Makefile.STOCK 
--- Makefile	2010-12-29 18:23:58.176755981 -0600
+++ Makefile.STOCK	2010-12-29 18:21:43.405298124 -0600
@@ -413,11 +413,7 @@
 include $(srctree)/arch/$(ARCH)/Makefile
 export KBUILD_DEFCONFIG
 
-config: scripts_basic outputmakefile FORCE
-	$(Q)mkdir -p include/linux include/config
-	$(Q)$(MAKE) $(build)=scripts/kconfig $@
-
-%config: scripts_basic outputmakefile FORCE
+config %config: scripts_basic outputmakefile FORCE
 	$(Q)mkdir -p include/linux include/config
 	$(Q)$(MAKE) $(build)=scripts/kconfig $@
 
@@ -1467,10 +1463,7 @@
 	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
 
 # Modules
-/: prepare scripts FORCE
-	$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
-	$(build)=$(build-dir)
-%/: prepare scripts FORCE
+/ %/: prepare scripts FORCE
 	$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
 	$(build)=$(build-dir)
 %.ko: prepare scripts FORCE

And do the getline2() trick here:

/kanigix/slugos/5.3/slugos-nslu2be.tmp/work/armv5teb-linux-gnueabi/linux-libc-headers-2.6.23-r3/linux-2.6.23/scripts/unifdef.c 

And more:


[tdh@wont busybox-1.13.2]$ pwd
/kanigix/slugos/5.3/slugos-nslu2be.tmp/work/armv5teb-linux-gnueabi/busybox-1.13.2-r16/busybox-1.13.2
[tdh@wont busybox-1.13.2]$ diff Makefile Makefile.STOCK 
421,425c421
< config: scripts_basic outputmakefile FORCE
< 	$(Q)mkdir -p include
< 	$(Q)$(MAKE) $(build)=scripts/kconfig $@
< 	$(Q)$(MAKE) -C $(srctree) KBUILD_SRC= .kernelrelease
< %config: scripts_basic outputmakefile FORCE
---
> config %config: scripts_basic outputmakefile FORCE
1273,1276c1269
< /: prepare scripts FORCE
< 	$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
< 	$(build)=$(build-dir)
< %/: prepare scripts FORCE
---
> / %/: prepare scripts FORCE

Keep on fixing these as you found they broke. Consider again trying make-3.81!

A recursive gdb script for Binary Trees

If we have a binary tree, how do we determine if a key is in the tree? Or another way, how do we know it was inserted correctly? We need to visit every node.

This is a recursive problem and hard to do in gdb. The convenience variables are very simple and we can not implement a stack with them. Since they are effectively global, we can not even hide them in stack frames. What we can do is use concatenation and a node-id to generate uniqe names.

Note that you have to do all variable name declarations before you do any recursion. That statement will make sense when you violate it and wonder why your output looks strange.

define indentby
        printf "%*c", $arg0+1, 0
end

define walk_btree
        set $node_$arg0 = ($arg1)
        set $fnum_$arg0 = ($arg2)
        set $branch_$arg0 = ($arg3)
        set $space_$arg0 = ($arg4)
        set $leftid_$arg0 = $arg0 + 1
        set $rightid_$arg0 = $arg0 + 2

        indentby $space_$arg0
        printf "%d %u (btree *)%p\n", $branch_$arg0, $node_$arg0->e_type[$fnum_$arg0].key, $node_$arg0

        set $space_$arg0 = $space_$arg0 + 1
        if $node_$arg0->e_type[$fnum_$arg0].left
                walk_btree $leftid_$arg0 $node_$arg0->e_type[$fnum_$arg0].left $fnum_$arg0 0 $space_$arg0
        end
        if $node_$arg0->e_type[$fnum_$arg0].right
                walk_btree $rightid_$arg0 $node_$arg0->e_type[$fnum_$arg0].right $fnum_$arg0 1 $space_$arg0
        end
end
document walk_btree
        NODE-ID NODE FNUM BRANCH INDENTBY
        Recursively walk the binary tree printing out the key for the fnum'ed entry
end

define start_walk_btree
        walk_btree 0 $arg0 $arg1 3 1
end
document start_walk_btree
        NODE FNUM
        Recursively walk the binary tree printing out the key for the fnum'ed entry
end

Contrast that against a very simple algorithm to find if the key is in the tree (with the assumption the tree is valid).

Recursion is not needed as we lop of a branch with each iteration.

define find_btree
        set $node = $arg0
        set $fnum = $arg1
        set $key = $arg2
        set $process = 1

        while $node && $process
                if $key == $node->e_type[$fnum].key
                        set $process = 0
                else

                        if $key < $node->e_type[$fnum].key
                                $node = $node->e_type[$fnum].left
                        else
                                $node = $node->e_type[$fnum].right
                        end
                end
        end

        if $node
                printf "Found match on (btree *)%p\n", $node
        else
                printf "No matching node in the binary tree\n"
        end
end