RAMDisk + SSD = Raid 1?启动 OSX

RAMDisk + SSD = Raid 1?启动 OSX

是否有可能在 OSX 中使用 RAMDisk 和 SSD 创建 RAID 1?

类似:启动 Mac,OSX 分区将从 RAMDisk 中的 SSD 加载。启动到 RAMDisk 并像任何其他系统驱动器一样使用它。由于 RAID 1(--write-mostly/write-behind),在 RAMDisk 上执行的任何操作都将保留到 SSD。因此,如果我关闭 Mac,所有内容都将保留在 SSD 上,并且可以在下次启动时再次加载...

为了获得更好的体验,最常用的应用程序可以安装到 OSX-System-Partition (SSD),该分区也可以在 RAMDisk 中使用。

当然,SSD 上还会有第二个“数据”分区,用于存储所有其他内容。

我如何才能实现所描述的设置 - 使用 OSX 是否可行?我可以使用哪个引导加载程序(Grub?)?

答案1

根据评论,以下是我如何进行 RAMDisk 设置和复制的概要。

它不是完整的结构,因此无法按原样编译 [会有很多缺失的声明,因为在到达这一部分之前,我有一整套其他结构,它们不够通用,不值得复制进去],但提供了创建、复制和复制回来的例程。将其保存为应用程序并启动它而不是您的应用程序。

其中也没有任何条款规定您的应用程序如何使用它 - 对我来说,这是一个单独的结构,仅—settings在启动时使用应用程序的首选项和一些说明。

如果发生不匹配,它也会进行覆盖 - 这是因为我有该特定应用程序的多个版本,并且缓存不应混合。您可能可以忽略该部分。

-- RAM Disk setup
        set copying to 0
        if not {exists disk RAMDisk} then
            set VolumeName to RAMDisk
            set SizeInMB to 1024
            -- can choose size using this dialog
            --display dialog "RAM Disk Size:" default answer SizeInMB buttons {"OK", "Cancel"}      
            set NumSectors to ((2 * 1024 * SizeInMB))
            set DeviceName to do shell script "hdid -nomount ram://" & NumSectors
            tell current application to do shell script "diskutil eraseVolume 'HFS+' '" & VolumeName & "' " & DeviceName        
            set foundDisk to false
            repeat until (foundDisk = true)
                if exists disk RAMDisk then
                    foundDisk = true
                    delay 1
                    -- do copy...   
                    duplicate full_path to disk RAMDisk
                    exit repeat
                else
                    delay 1 -- waiting for RAM disk to appear, if it's slow
                end if
            end repeat -- end disk wait
        else -- if RAMDisk exists already           
            set p to (folders of disk RAMDisk)
            if (exists folder cache_name of disk RAMDisk) then
                if p is {} then -- disk's empty
                    duplicate full_path to disk RAMDisk
                end if
            else -- if not (exists folder cache_name of disk RAMDisk) then
                display alert "RAM Disk contents are from a different version.\nErasing first..." giving up after 4
                try --deletes entire contents of RAMDisk, doesn't throw to Trash
                    --Folder in Trash can still cause "disk full" error.
                    --'quoted form' in shell scripts (unix) enables spaces in file names (ie RAMDisk name)
                    tell current application to do shell script "rm -rf Volumes/" & quoted form of RAMDisk & "/"
                end try
                duplicate full_path to disk RAMDisk
                delay 2
            end if -- end cache name check
        end if -- end RAMDisk check

(*at this point, launch your app, the script will sit & wait for it to quit*)

-- after app quits, copy back & tidy up
        display dialog "Quitting or just restarting 'app'?" buttons {"Quitting", "restarting"} ¬
            default button "Quitting" giving up after 30
        set thebutton to button returned of result as string
        if thebutton is "Quitting" then

            set toCopy to true -- to test for copyback
            if folder backup_location exists then
                display dialog "Safety folder already exists\nDelete & continue copy-back or just quit?" buttons {"Delete", "Just Quit"} default button "Delete" giving up after 30
                set thebutton to button returned of result as string
                if thebutton is "Delete" then
                    delete folder backup_location
                else
                    set toCopy to false -- will bypass copyback
                end if
            end if
            if toCopy is true then
                -- set a backup folder name before copying
                set name of folder full_path to cache_name & " - old"
                delay 1
                duplicate contents of folder cache_name of disk RAMDisk to folder custom_caches_base_path
                delay 1
                delete folder backup_location
            end if
        end if -- end quit sequence

相关内容