start

Disk Arbitration Frameworkでディスクのマウントを抑制する

物理HDDをVirtualBoxのVMに割り当てて使用中、Mac OSからそのHDDをマウントされると非常に不味いので、マウントを抑制するコマンドを作ってみた。

引数にBSDデバイス名(/dev/disk5とか)を渡してコマンドを実行すると、Mac OS側からのマウントをブロックする。デバイス名は前方一致で検索しているので、/dev/disk5と書けばdisk5全体が、/dev/disk5s1と書けばdisk5のスライス1がブロック対象となる。終了はCtrl-Cで。

どこか処理が不味いようで、何かの拍子にコマンドを終了してもFinderからはマウント不能?と認識されてしまうことがある(実際はマウントされているのでopenコマンドを使えば開ける)。こうなると再起動するしかなくなる…。AS ISでおながいします。

blockMount.c
// -*- coding: utf-8-unix -*-
// ---------------------------------------------------------
//  Block Mount Utility
//  Copyright (c) 2013 Decomo
// ---------------------------------------------------------
//  License:
//      2-clause BSD license
//  Reference:
//      https://github.com/nanoant/mountblockd
//      http://stackoverflow.com/questions/3720503/how-can-i-prevent-ejection-of-a-disk-during-an-operation-on-mac-os-x
//      http://superuser.com/questions/336455/mac-lion-fstab-is-deprecated-so-what-replaces-it-to-prevent-a-partition-from-m
//      http://www.geekpage.jp/blog/?id=2011/10/4/3
//      http://developer.apple.com/library/mac/#documentation/Darwin/Reference/DiscArbitrationFramework/
//  Compile:
//      cc BlockMount.c -g -o BlockMount -framework CoreFoundation -framework DiskArbitration
// ---------------------------------------------------------
 
#include <CoreFoundation/CoreFoundation.h>
#include <DiskArbitration/DiskArbitration.h>
#include <stdio.h>
#include <stdlib.h>
 
const char **g_blockDeviceList = NULL;
int g_blockDeviceListCount = 0;
int g_verbose = 0;
int g_run = 1;
 
DADissenterRef diskWillMount(DADiskRef disk, void *context)
{
    const char *devName = DADiskGetBSDName(disk);
    DADissenterRef dissenter = NULL;
 
    if (devName)
    {
        int block=0;
        for (int i=0; i<g_blockDeviceListCount; i++)
        {
            if (strstr(devName, g_blockDeviceList[i]))
                block=1;
        }
        if (block)
        {
            if (g_verbose)
                fprintf(stderr, "BLOCKED mount `%s'\n", devName);
            dissenter = DADissenterCreate(kCFAllocatorDefault, kDAReturnNotPermitted, NULL);
        }
    }
 
    return dissenter;
}
 
void signalHandler(int sig)
{
    switch (sig) {
    case SIGHUP:
        if (g_verbose)
            fprintf(stderr, "received SIGHUP, terminating...\n");
        CFRunLoopStop(CFRunLoopGetCurrent());
        g_run=0;
        break;
    case SIGTERM:
        if (g_verbose)
            fprintf(stderr, "received SIGTERM, terminating...\n");
        CFRunLoopStop(CFRunLoopGetCurrent());
        g_run=0;
        break;
    case SIGINT:
        if (g_verbose)
            fprintf(stderr, "received SIGINT, terminating...\n");
        CFRunLoopStop(CFRunLoopGetCurrent());
        g_run=0;
        break;
    case SIGQUIT:
        if (g_verbose)
            fprintf(stderr, "received SIGQUIT, terminating...\n");
        CFRunLoopStop(CFRunLoopGetCurrent());
        g_run=0;
        break;
    default:
        fprintf(stderr, "unhandled signal (%d) %s\n", sig, strsignal(sig));
        break;
    }
}
 
int main(int argc, const char *argv[])
{
    int usage=1;
    if (argc >= 2)
    {
        usage=0;
        if (strcmp(argv[1], "-v") == 0)
        {
            g_verbose=1;
            g_blockDeviceList = &argv[2];
            g_blockDeviceListCount = argc-2;
            if (argc == 2)
            {
                usage=1;
            }
        }
        else
        {
            g_blockDeviceList = &argv[1];
            g_blockDeviceListCount = argc-1;
        }
    }
 
    if (usage)
    {
        fprintf(stderr, "usage: %s [-v] deviceName1 [deviceName2] [deviceName3] [...] \n", argv[0]);
        return EXIT_FAILURE;
    }
 
    fprintf(stderr, "blocking mount device(s) : ");
    for (int i=0; i<g_blockDeviceListCount; i++)
    {
        fprintf(stderr, "%s ", g_blockDeviceList[i]);
    }
    fprintf(stderr, "\n");
 
    signal(SIGHUP,  signalHandler);
    signal(SIGTERM, signalHandler);
    signal(SIGINT,  signalHandler);
    signal(SIGQUIT, signalHandler);
 
    DAApprovalSessionRef session = DAApprovalSessionCreate(kCFAllocatorDefault);
    if (!session)
    {
        fprintf(stderr, "failed to create DAApprovalSession.\n");
        return EXIT_FAILURE;
    }
    else
    {
        DARegisterDiskMountApprovalCallback(session, NULL, diskWillMount, NULL);
        DAApprovalSessionScheduleWithRunLoop(session, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
 
        while (g_run)
        {
            CFRunLoopRun();
        }
 
        DAApprovalSessionUnscheduleFromRunLoop(session, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
        DAUnregisterApprovalCallback(session, diskWillMount, NULL);
        CFRelease(session);
    }
 
    return 0;
}

とまぁ、とりあえず作ってはみたものの、結局仮想マシンはVMware Fusionを常用してるので出番がないっていう。何だかんだでVirtualBoxは不安定なんだよねぇ。8 CPU以上使えるのは魅力的なんだけど。

NSArrayをFinder風の並び順でソートする

こんなファイルがあったとする。

file-a
file-1
file-01
file-2
file-10
file-b
file-ab

辞書式(普通の昇順ソート)で並べ替えると

file-01
file-1
file-10
file-2
file-a
file-ab
file-b

となるわけだが、Finderでソートすると

file-1
file-01
file-2
file-10
file-a
file-ab
file-b

となる。連続した数字部分を数値と見なし、数値順で並べてくれる。個人的にはこの方が分かりやすくて好きだ。

で、この数値順ソートをCocoaで実現するにはどーしたらいいのかなー?と思って調べていたら、Technical Q&A QA1159: Sorting Like the Finderという、そのまんまの記事がADCにあった。流石林檎様、分かっていらっしゃる。

上記Q&Aのコードを改造してNSMutableArrayのカテゴリメソッドにするとスマートに使えて良い感じ。

NSString配列のソートはもちろん、任意のオブジェクトの場合はソートに使うNSStringインスタンス変数名をsortByFinderOrderWithStringObjectKey:に渡せばおk。

#include <CoreServices/CoreServices.h>
#include <sys/param.h>
 
static CFComparisonResult CompareLikeTheFinder(const void *val1, const void *val2, void *context)
{
    SInt32          compareResult;
    CFStringRef     lhsStr;
    CFStringRef     rhsStr;
    CFIndex         lhsLen;
    CFIndex         rhsLen;
    UniChar         lhsBuf[MAXPATHLEN];
    UniChar         rhsBuf[MAXPATHLEN];
 
    // val1 is the left-hand side CFString.
    // val2 is the right-hand side CFString.
    if (context)
    {
        NSString *key = (NSString *)context;
        lhsStr = (CFStringRef)[(NSObject *)val1 valueForKey:key];
        rhsStr = (CFStringRef)[(NSObject *)val2 valueForKey:key];
    }
    else
    {
        lhsStr = (CFStringRef)val1;
        rhsStr = (CFStringRef)val2;
    }
    lhsLen = CFStringGetLength(lhsStr);
    rhsLen = CFStringGetLength(rhsStr);
 
    // Get the actual Unicode characters (UTF-16) for each string.
    CFStringGetCharacters(lhsStr, CFRangeMake(0, lhsLen), lhsBuf);
    CFStringGetCharacters(rhsStr, CFRangeMake(0, rhsLen), rhsBuf);
 
    // Do the comparison.
    UCCompareTextDefault(
                         kUCCollateComposeInsensitiveMask
                         | kUCCollateWidthInsensitiveMask
                         | kUCCollateCaseInsensitiveMask
                         | kUCCollateDigitsOverrideMask
                         | kUCCollateDigitsAsNumberMask
                         | kUCCollatePunctuationSignificantMask,
                         lhsBuf,
                         lhsLen,
                         rhsBuf,
                         rhsLen,
                         NULL,
                         &compareResult
                         );
 
    // Return the result. Conveniently, UCCompareTextDefault 
    // returns -1, 0, or +1, which matches the values for 
    // CFComparisonResult exactly.
    return (CFComparisonResult)compareResult;
}
 
static void SortCFMutableArrayLikeTheFinder(CFMutableArrayRef array, CFStringRef key)
{
    CFArraySortValues(
                      array, 
                      CFRangeMake(0, CFArrayGetCount(array)),
                      CompareLikeTheFinder,
                      key
                      );
}
 
@interface NSMutableArray (PKAdditions)
- (void)sortByFinderOrder;
- (void)sortByFinderOrderWithStringObjectKey:(NSString *)key;
@end
 
@implementation NSMutableArray (PKAdditions)
- (void)sortByFinderOrder
{
    [self sortByFinderOrderWithStringObjectKey:nil];
}
 
- (void)sortByFinderOrderWithStringObjectKey:(NSString *)key
{
    SortCFMutableArrayLikeTheFinder(self, key);
}
@end

実際のファイル名やディレクトリ名をソートする場合は、- [NSFileManager displayNameAtPath:(NSString *)path]で得られる名前をソートしないとFinder順にはならない。なぜかというと、Finderから見えるディレクトリ名はローカライズ(~/Documents → 書類 みたいなの)された物なので。

Portsにnetatalk 3.0.2がキタ━━━(゚∀゚)━━━ !!!!!

早速インスコ。portupgradeだと、なぜか「too few arguments to function 'load_volumes'」とビルドエラーになってしまうので、3.0.1を一旦アンインストールしたらすんなり入った(make cleanしても3.0.1のヘッダを見に行ってしまうっぽい?)。

3.0.1まではパスの扱いがおかしく、FreeBSDで[Homes]が実質機能しなかった訳だが3.0.2で無事に解決した。ありがとうHATさん。パスの扱いについては、今も検討が続いている模様

これでafp.confもスッキリした。

;
; Netatalk 3.x configuration file
;
 
[Global]
; Global server settings
vol preset = _DEFAULT
log file = /var/log/netatalk.log
 
[_DEFAULT]
file perm = 0600
directory perm = 0700
 
[Homes]
basedir regex = /usr/home
home name = $u
 
[Time Machine]
path = /Volumes/TimeMachine
time machine = yes
vol size limit = 2097152
 
[Data]
path = /Volumes/Data
 
[Public]
path = /usr/home/PUBLIC
file perm = 0660
directory perm = 0770

basedir regexにはシンボリックリンクではなく、実リンクで書くのがミソ。

大事なことなのでもう一度。ありがとうHATさん。

ESXi 5.1のLACPでリンクアグリゲーションしようとして出来なかった

「HDD3台を2セットでRAID-Zのストライピングしてて、折角書き込み235MiB/s、読み込み356MiB/s出てるのにギガビットイーサで律速されるのは勿体ないなぁ……と思っていたら、あれ?どこからともなくBS-G2016MRとNetXtreme II 5709デュアルポートイーサネットカードが出てきましたよ?(白々しい)。よし、これでリンクアグリゲーションして帯域を2Gbpsにするぞ!」と思って試してみたけど、単純な増速は無理っぽかったorz

先に結論を書いておくと、ESXi配下の物理NICを束ねて1セッションあたりの論理リンク速度を上げるのは基本的に無理。VMの通信速度はNIC1枚の物理リンク速度が上限で、束ねたNICは負荷分散動作にしかならない(一応VM側に細工を施せば限界突破出来るようだが、OSを選んだり負荷が高くなったり、何より設定が面倒なので却下。)

また、タイトルで「ESXi 5.1のLACPで」と書いたが、LACPの設定はWebClientからじゃないと出来ない模様。

LAGまわりは用語が混在してて訳が分からん……ちゃんと勉強しないとダメだなorz

稼働中のvSphere Hypervisorは5.0U1なので5.1に更新する。

~ # esxcli network firewall ruleset set -e true -r httpClient
~ # esxcli software sources profile list -d https://hostupdate.vmware.com/software/VUM/PRODUCTION/main/vmw-depot-index.xml
Name                              Vendor        Acceptance Level
--------------------------------  ------------  ----------------
ESXi-5.0.0-20120904001-no-tools   VMware, Inc.  PartnerSupported
ESXi-5.0.0-20121202001-no-tools   VMware, Inc.  PartnerSupported
ESXi-5.0.0-20120904001-standard   VMware, Inc.  PartnerSupported
ESXi-5.0.0-20121201001s-standard  VMware, Inc.  PartnerSupported
ESXi-5.1.0-799733-no-tools        VMware, Inc.  PartnerSupported
ESXi-5.0.0-20120604001-no-tools   VMware, Inc.  PartnerSupported
ESXi-5.0.0-20120704001-standard   VMware, Inc.  PartnerSupported
ESXi-5.1.0-20121204001-standard   VMware, Inc.  PartnerSupported
ESXi-5.0.0-20120701001s-standard  VMware, Inc.  PartnerSupported
ESXi-5.1.0-799733-standard        VMware, Inc.  PartnerSupported
ESXi-5.0.0-20120404001-no-tools   VMware, Inc.  PartnerSupported
ESXi-5.0.0-469512-no-tools        VMware, Inc.  PartnerSupported
ESXi-5.0.0-20120604001-standard   VMware, Inc.  PartnerSupported
ESXi-5.0.0-20111104001-no-tools   VMware, Inc.  PartnerSupported
ESXi-5.0.0-20120301001s-no-tools  VMware, Inc.  PartnerSupported
ESXi-5.0.0-20110904001-standard   VMware, Inc.  PartnerSupported
ESXi-5.0.0-20120901001s-standard  VMware, Inc.  PartnerSupported
ESXi-5.0.0-20120701001s-no-tools  VMware, Inc.  PartnerSupported
ESXi-5.1.0-20121201001s-no-tools  VMware, Inc.  PartnerSupported
ESXi-5.0.0-20120504001-standard   VMware, Inc.  PartnerSupported
ESXi-5.1.0-20121204001-no-tools   VMware, Inc.  PartnerSupported
ESXi-5.0.0-20120704001-no-tools   VMware, Inc.  PartnerSupported
ESXi-5.1.0-20121004001-standard   VMware, Inc.  PartnerSupported
ESXi-5.0.0-20110904001-notools    VMware, Inc.  PartnerSupported
ESXi-5.0.0-20120404001-standard   VMware, Inc.  PartnerSupported
ESXi-5.0.0-20111104001-standard   VMware, Inc.  PartnerSupported
ESXi-5.0.0-20121202001-standard   VMware, Inc.  PartnerSupported
ESXi-5.0.0-20111204001-no-tools   VMware, Inc.  PartnerSupported
ESXi-5.0.0-20121201001s-no-tools  VMware, Inc.  PartnerSupported
ESXi-5.0.0-469512-standard        VMware, Inc.  PartnerSupported
ESXi-5.0.0-20120302001-standard   VMware, Inc.  PartnerSupported
ESXi-5.0.0-20120504001-no-tools   VMware, Inc.  PartnerSupported
ESXi-5.0.0-20111204001-standard   VMware, Inc.  PartnerSupported
ESXi-5.0.0-20120302001-no-tools   VMware, Inc.  PartnerSupported
ESXi-5.1.0-20121201001s-standard  VMware, Inc.  PartnerSupported
ESXi-5.0.0-20120901001s-no-tools  VMware, Inc.  PartnerSupported
ESXi-5.1.0-20121004001-no-tools   VMware, Inc.  PartnerSupported
ESXi-5.0.0-20120301001s-standard  VMware, Inc.  PartnerSupported
 
~ # vmware -vl
VMware ESXi 5.0.0 build-623860
VMware ESXi 5.0.0 Update 1
 
~ # esxcli software profile install -d https://hostupdate.vmware.com/software/VUM/PRODUCTION/main/vmw-depot-index.xml -p ESXi-5.1.0-799733-standard
Installation Result
   Message: The update completed successfully, but the system needs to be rebooted for the changes to be effective.
   Reboot Required: true
   VIBs Installed: VMware_bootbank_ata-pata-amd_0.3.10-3vmw.510.0.0.799733, VMware_bootbank_ata-pata-atiixp_0.4.6-4vmw.510.0.0.799733, VMware_bootbank_ata-pata-cmd64x_0.2.5-3vmw.510.0.0.799733, VMware_bootbank_ata-pata-hpt3x2n_0.3.4-3vmw.510.0.0.799733, VMware_bootbank_ata-pata-pdc2027x_1.0-3vmw.510.0.0.799733, VMware_bootbank_ata-pata-serverworks_0.4.3-3vmw.510.0.0.799733, VMware_bootbank_ata-pata-sil680_0.4.8-3vmw.510.0.0.799733, VMware_bootbank_ata-pata-via_0.3.3-2vmw.510.0.0.799733, VMware_bootbank_block-cciss_3.6.14-10vmw.510.0.0.799733, VMware_bootbank_ehci-ehci-hcd_1.0-3vmw.510.0.0.799733, VMware_bootbank_esx-base_5.1.0-0.0.799733, VMware_bootbank_esx-dvfilter-generic-fastpath_5.1.0-0.0.799733, VMware_bootbank_esx-tboot_5.1.0-0.0.799733, VMware_bootbank_esx-xlibs_5.1.0-0.0.799733, VMware_bootbank_esx-xserver_5.1.0-0.0.799733, VMware_bootbank_ima-qla4xxx_2.01.31-1vmw.510.0.0.799733, VMware_bootbank_ipmi-ipmi-devintf_39.1-4vmw.510.0.0.799733, VMware_bootbank_ipmi-ipmi-msghandler_39.1-4vmw.510.0.0.799733, VMware_bootbank_ipmi-ipmi-si-drv_39.1-4vmw.510.0.0.799733, VMware_bootbank_misc-cnic-register_1.1-1vmw.510.0.0.799733, VMware_bootbank_misc-drivers_5.1.0-0.0.799733, VMware_bootbank_net-be2net_4.1.255.11-1vmw.510.0.0.799733, VMware_bootbank_net-bnx2_2.0.15g.v50.11-7vmw.510.0.0.799733, VMware_bootbank_net-bnx2x_1.61.15.v50.3-1vmw.510.0.0.799733, VMware_bootbank_net-cnic_1.10.2j.v50.7-3vmw.510.0.0.799733, VMware_bootbank_net-e1000_8.0.3.1-2vmw.510.0.0.799733, VMware_bootbank_net-e1000e_1.1.2-3vmw.510.0.0.799733, VMware_bootbank_net-enic_1.4.2.15a-1vmw.510.0.0.799733, VMware_bootbank_net-forcedeth_0.61-2vmw.510.0.0.799733, VMware_bootbank_net-igb_2.1.11.1-3vmw.510.0.0.799733, VMware_bootbank_net-ixgbe_3.7.13.6iov-10vmw.510.0.0.799733, VMware_bootbank_net-nx-nic_4.0.558-3vmw.510.0.0.799733, VMware_bootbank_net-r8168_8.013.00-3vmw.510.0.0.799733, VMware_bootbank_net-r8169_6.011.00-2vmw.510.0.0.799733, VMware_bootbank_net-s2io_2.1.4.13427-3vmw.510.0.0.799733, VMware_bootbank_net-sky2_1.20-2vmw.510.0.0.799733, VMware_bootbank_net-tg3_3.110h.v50.4-4vmw.510.0.0.799733, VMware_bootbank_net-vmxnet3_1.1.3.0-3vmw.510.0.0.799733, VMware_bootbank_ohci-usb-ohci_1.0-3vmw.510.0.0.799733, VMware_bootbank_sata-ahci_3.0-13vmw.510.0.0.799733, VMware_bootbank_sata-ata-piix_2.12-6vmw.510.0.0.799733, VMware_bootbank_sata-sata-nv_3.5-4vmw.510.0.0.799733, VMware_bootbank_sata-sata-promise_2.12-3vmw.510.0.0.799733, VMware_bootbank_sata-sata-sil24_1.1-1vmw.510.0.0.799733, VMware_bootbank_sata-sata-sil_2.3-4vmw.510.0.0.799733, VMware_bootbank_sata-sata-svw_2.3-3vmw.510.0.0.799733, VMware_bootbank_scsi-aacraid_1.1.5.1-9vmw.510.0.0.799733, VMware_bootbank_scsi-adp94xx_1.0.8.12-6vmw.510.0.0.799733, VMware_bootbank_scsi-aic79xx_3.1-5vmw.510.0.0.799733, VMware_bootbank_scsi-bnx2i_1.9.1d.v50.1-5vmw.510.0.0.799733, VMware_bootbank_scsi-fnic_1.5.0.3-1vmw.510.0.0.799733, VMware_bootbank_scsi-hpsa_5.0.0-21vmw.510.0.0.799733, VMware_bootbank_scsi-ips_7.12.05-4vmw.510.0.0.799733, VMware_bootbank_scsi-lpfc820_8.2.3.1-127vmw.510.0.0.799733, VMware_bootbank_scsi-megaraid-mbox_2.20.5.1-6vmw.510.0.0.799733, VMware_bootbank_scsi-megaraid-sas_5.34-4vmw.510.0.0.799733, VMware_bootbank_scsi-megaraid2_2.00.4-9vmw.510.0.0.799733, VMware_bootbank_scsi-mpt2sas_10.00.00.00-5vmw.510.0.0.799733, VMware_bootbank_scsi-mptsas_4.23.01.00-6vmw.510.0.0.799733, VMware_bootbank_scsi-mptspi_4.23.01.00-6vmw.510.0.0.799733, VMware_bootbank_scsi-qla2xxx_902.k1.1-9vmw.510.0.0.799733, VMware_bootbank_scsi-qla4xxx_5.01.03.2-4vmw.510.0.0.799733, VMware_bootbank_scsi-rste_2.0.2.0088-1vmw.510.0.0.799733, VMware_bootbank_uhci-usb-uhci_1.0-3vmw.510.0.0.799733, VMware_locker_tools-light_5.1.0-0.0.799733
   VIBs Removed: VMware_bootbank_ata-pata-amd_0.3.10-3vmw.500.0.0.469512, VMware_bootbank_ata-pata-atiixp_0.4.6-3vmw.500.0.0.469512, VMware_bootbank_ata-pata-cmd64x_0.2.5-3vmw.500.0.0.469512, VMware_bootbank_ata-pata-hpt3x2n_0.3.4-3vmw.500.0.0.469512, VMware_bootbank_ata-pata-pdc2027x_1.0-3vmw.500.0.0.469512, VMware_bootbank_ata-pata-serverworks_0.4.3-3vmw.500.0.0.469512, VMware_bootbank_ata-pata-sil680_0.4.8-3vmw.500.0.0.469512, VMware_bootbank_ata-pata-via_0.3.3-2vmw.500.0.0.469512, VMware_bootbank_block-cciss_3.6.14-10vmw.500.0.0.469512, VMware_bootbank_ehci-ehci-hcd_1.0-3vmw.500.1.11.623860, VMware_bootbank_esx-base_5.0.0-1.11.623860, VMware_bootbank_esx-tboot_5.0.0-0.0.469512, VMware_bootbank_ima-qla4xxx_2.01.07-1vmw.500.0.0.469512, VMware_bootbank_ipmi-ipmi-devintf_39.1-4vmw.500.0.0.469512, VMware_bootbank_ipmi-ipmi-msghandler_39.1-4vmw.500.0.0.469512, VMware_bootbank_ipmi-ipmi-si-drv_39.1-4vmw.500.0.0.469512, VMware_bootbank_misc-cnic-register_1.1-1vmw.500.0.0.469512, VMware_bootbank_misc-drivers_5.0.0-1.11.623860, VMware_bootbank_net-be2net_4.0.88.0-1vmw.500.0.7.515841, VMware_bootbank_net-bnx2_2.0.15g.v50.11-5vmw.500.0.0.469512, VMware_bootbank_net-bnx2x_1.61.15.v50.1-1vmw.500.0.0.469512, VMware_bootbank_net-cnic_1.10.2j.v50.7-2vmw.500.0.0.469512, VMware_bootbank_net-e1000_8.0.3.1-2vmw.500.0.7.515841, VMware_bootbank_net-e1000e_1.1.2-3vmw.500.1.11.623860, VMware_bootbank_net-enic_1.4.2.15a-1vmw.500.0.0.469512, VMware_bootbank_net-forcedeth_0.61-2vmw.500.0.0.469512, VMware_bootbank_net-igb_2.1.11.1-3vmw.500.0.0.469512, VMware_bootbank_net-ixgbe_2.0.84.8.2-10vmw.500.0.0.469512, VMware_bootbank_net-nx-nic_4.0.557-3vmw.500.1.11.623860, VMware_bootbank_net-r8168_8.013.00-3vmw.500.0.0.469512, VMware_bootbank_net-r8169_6.011.00-2vmw.500.0.0.469512, VMware_bootbank_net-s2io_2.1.4.13427-3vmw.500.0.0.469512, VMware_bootbank_net-sky2_1.20-2vmw.500.0.0.469512, VMware_bootbank_net-tg3_3.110h.v50.4-4vmw.500.0.0.469512, VMware_bootbank_ohci-usb-ohci_1.0-3vmw.500.0.0.469512, VMware_bootbank_sata-ahci_3.0-6vmw.500.1.11.623860, VMware_bootbank_sata-ata-piix_2.12-4vmw.500.1.11.623860, VMware_bootbank_sata-sata-nv_3.5-3vmw.500.0.0.469512, VMware_bootbank_sata-sata-promise_2.12-3vmw.500.0.0.469512, VMware_bootbank_sata-sata-sil_2.3-3vmw.500.0.0.469512, VMware_bootbank_sata-sata-svw_2.3-3vmw.500.0.0.469512, VMware_bootbank_scsi-aacraid_1.1.5.1-9vmw.500.1.11.623860, VMware_bootbank_scsi-adp94xx_1.0.8.12-6vmw.500.0.0.469512, VMware_bootbank_scsi-aic79xx_3.1-5vmw.500.0.0.469512, VMware_bootbank_scsi-bnx2i_1.9.1d.v50.1-3vmw.500.0.0.469512, VMware_bootbank_scsi-fnic_1.5.0.3-1vmw.500.0.0.469512, VMware_bootbank_scsi-hpsa_5.0.0-17vmw.500.0.0.469512, VMware_bootbank_scsi-ips_7.12.05-4vmw.500.0.0.469512, VMware_bootbank_scsi-lpfc820_8.2.2.1-18vmw.500.0.0.469512, VMware_bootbank_scsi-megaraid-mbox_2.20.5.1-6vmw.500.0.0.469512, VMware_bootbank_scsi-megaraid-sas_5.34-1vmw.500.1.11.623860, VMware_bootbank_scsi-megaraid2_2.00.4-9vmw.500.0.0.469512, VMware_bootbank_scsi-mpt2sas_06.00.00.00-6vmw.500.1.11.623860, VMware_bootbank_scsi-mptsas_4.23.01.00-5vmw.500.0.0.469512, VMware_bootbank_scsi-mptspi_4.23.01.00-5vmw.500.0.0.469512, VMware_bootbank_scsi-qla2xxx_901.k1.1-14vmw.500.0.0.469512, VMware_bootbank_scsi-qla4xxx_5.01.03.2-3vmw.500.0.0.469512, VMware_bootbank_scsi-rste_2.0.2.0088-1vmw.500.1.11.623860, VMware_bootbank_uhci-usb-uhci_1.0-3vmw.500.0.0.469512, VMware_locker_tools-light_5.0.0-1.11.623860
   VIBs Skipped: 

素のESXi 5.1はPCIパススルーにバグ持ちなので対策パッチを当てる。

# esxcli software vib install -d /vmfs/volumes/Datastore/ESXi510-201212001.zip 
Installation Result
   Message: The update completed successfully, but the system needs to be rebooted for the changes to be effective.
   Reboot Required: true
   VIBs Installed: VMware_bootbank_esx-base_5.1.0-0.9.914609, VMware_locker_tools-light_5.1.0-0.9.914609
   VIBs Removed: VMware_bootbank_esx-base_5.1.0-0.0.799733, VMware_locker_tools-light_5.1.0-0.0.799733
   VIBs Skipped: VMware_bootbank_ata-pata-amd_0.3.10-3vmw.510.0.0.799733, VMware_bootbank_ata-pata-atiixp_0.4.6-4vmw.510.0.0.799733, VMware_bootbank_ata-pata-cmd64x_0.2.5-3vmw.510.0.0.799733, VMware_bootbank_ata-pata-hpt3x2n_0.3.4-3vmw.510.0.0.799733, VMware_bootbank_ata-pata-pdc2027x_1.0-3vmw.510.0.0.799733, VMware_bootbank_ata-pata-serverworks_0.4.3-3vmw.510.0.0.799733, VMware_bootbank_ata-pata-sil680_0.4.8-3vmw.510.0.0.799733, VMware_bootbank_ata-pata-via_0.3.3-2vmw.510.0.0.799733, VMware_bootbank_block-cciss_3.6.14-10vmw.510.0.0.799733, VMware_bootbank_ehci-ehci-hcd_1.0-3vmw.510.0.0.799733, VMware_bootbank_esx-dvfilter-generic-fastpath_5.1.0-0.0.799733, VMware_bootbank_esx-tboot_5.1.0-0.0.799733, VMware_bootbank_esx-xlibs_5.1.0-0.0.799733, VMware_bootbank_esx-xserver_5.1.0-0.0.799733, VMware_bootbank_ima-qla4xxx_2.01.31-1vmw.510.0.0.799733, VMware_bootbank_ipmi-ipmi-devintf_39.1-4vmw.510.0.0.799733, VMware_bootbank_ipmi-ipmi-msghandler_39.1-4vmw.510.0.0.799733, VMware_bootbank_ipmi-ipmi-si-drv_39.1-4vmw.510.0.0.799733, VMware_bootbank_misc-cnic-register_1.1-1vmw.510.0.0.799733, VMware_bootbank_misc-drivers_5.1.0-0.0.799733, VMware_bootbank_net-be2net_4.1.255.11-1vmw.510.0.0.799733, VMware_bootbank_net-bnx2_2.0.15g.v50.11-7vmw.510.0.0.799733, VMware_bootbank_net-bnx2x_1.61.15.v50.3-1vmw.510.0.0.799733, VMware_bootbank_net-cnic_1.10.2j.v50.7-3vmw.510.0.0.799733, VMware_bootbank_net-e1000_8.0.3.1-2vmw.510.0.0.799733, VMware_bootbank_net-e1000e_1.1.2-3vmw.510.0.0.799733, VMware_bootbank_net-enic_1.4.2.15a-1vmw.510.0.0.799733, VMware_bootbank_net-forcedeth_0.61-2vmw.510.0.0.799733, VMware_bootbank_net-igb_2.1.11.1-3vmw.510.0.0.799733, VMware_bootbank_net-ixgbe_3.7.13.6iov-10vmw.510.0.0.799733, VMware_bootbank_net-nx-nic_4.0.558-3vmw.510.0.0.799733, VMware_bootbank_net-r8168_8.013.00-3vmw.510.0.0.799733, VMware_bootbank_net-r8169_6.011.00-2vmw.510.0.0.799733, VMware_bootbank_net-s2io_2.1.4.13427-3vmw.510.0.0.799733, VMware_bootbank_net-sky2_1.20-2vmw.510.0.0.799733, VMware_bootbank_net-tg3_3.110h.v50.4-4vmw.510.0.0.799733, VMware_bootbank_net-vmxnet3_1.1.3.0-3vmw.510.0.0.799733, VMware_bootbank_ohci-usb-ohci_1.0-3vmw.510.0.0.799733, VMware_bootbank_sata-ahci_3.0-13vmw.510.0.0.799733, VMware_bootbank_sata-ata-piix_2.12-6vmw.510.0.0.799733, VMware_bootbank_sata-sata-nv_3.5-4vmw.510.0.0.799733, VMware_bootbank_sata-sata-promise_2.12-3vmw.510.0.0.799733, VMware_bootbank_sata-sata-sil24_1.1-1vmw.510.0.0.799733, VMware_bootbank_sata-sata-sil_2.3-4vmw.510.0.0.799733, VMware_bootbank_sata-sata-svw_2.3-3vmw.510.0.0.799733, VMware_bootbank_scsi-aacraid_1.1.5.1-9vmw.510.0.0.799733, VMware_bootbank_scsi-adp94xx_1.0.8.12-6vmw.510.0.0.799733, VMware_bootbank_scsi-aic79xx_3.1-5vmw.510.0.0.799733, VMware_bootbank_scsi-bnx2i_1.9.1d.v50.1-5vmw.510.0.0.799733, VMware_bootbank_scsi-fnic_1.5.0.3-1vmw.510.0.0.799733, VMware_bootbank_scsi-hpsa_5.0.0-21vmw.510.0.0.799733, VMware_bootbank_scsi-ips_7.12.05-4vmw.510.0.0.799733, VMware_bootbank_scsi-lpfc820_8.2.3.1-127vmw.510.0.0.799733, VMware_bootbank_scsi-megaraid-mbox_2.20.5.1-6vmw.510.0.0.799733, VMware_bootbank_scsi-megaraid-sas_5.34-4vmw.510.0.0.799733, VMware_bootbank_scsi-megaraid2_2.00.4-9vmw.510.0.0.799733, VMware_bootbank_scsi-mpt2sas_10.00.00.00-5vmw.510.0.0.799733, VMware_bootbank_scsi-mptsas_4.23.01.00-6vmw.510.0.0.799733, VMware_bootbank_scsi-mptspi_4.23.01.00-6vmw.510.0.0.799733, VMware_bootbank_scsi-qla2xxx_902.k1.1-9vmw.510.0.0.799733, VMware_bootbank_scsi-qla4xxx_5.01.03.2-4vmw.510.0.0.799733, VMware_bootbank_scsi-rste_2.0.2.0088-1vmw.510.0.0.799733, VMware_bootbank_uhci-usb-uhci_1.0-3vmw.510.0.0.799733

5.1に更新するとsata-ahc.v00などが上書きされるので、独自ドライバなどを導入してる場合はそれらを再インストールしないと残念な事になる。

VirtualBoxに物理HDDを丸ごと1台割り当てる

BootCampパーティションだけをVMにアタッチしている例は見かけるが、BootCampパーティションのあるHDDを丸ごとアタッチしている例がなかったのでメモ。

$ sudo diskutil unmountDisk /dev/disk2
Unmount of all volumes on disk2 was successful
$ sudo vboxmanage internalcommands createrawvmdk -filename ./BootCampHDD.vmdk -rawdisk /dev/disk2
RAW host disk access VMDK file ./BootCampHDD.vmdk created successfully.
$ sudo chown username BootCampHDD.vmdk

/dev/disk2の箇所は環境に合わせて適宜読み替えてくだしあ。

後は作ったvmdkをVMに割り当てればおk。

VM起動時はBootCampパーティション単体の場合と同じく、ドライブをアウンマウント&パーミッションを変更する。VM起動中にMacをスリープ&復帰させると、問答無用でドライブがMac側にマウントされてしまうのはどうにかしたいところ(確かVMware FusionのBootCamp起動ではスリープにしても問題がなかった)。Disk Arbitration Frameworkを使えば実現出来そうな気がするので、ちょいと調査中。

  • start.txt
  • 最終更新: 2022-07-27 15:26
  • by Decomo