RAMDisk + SSD = Raid 1? Boot OSX












1














Is it possible to create RAID 1 with RAMDisk and SSD in OSX?



Something like:
Boot Mac, OSX-Partition will be loaded from SSD in RAMDisk. Boot to RAMDisk and use it like any other system-drive. Because of RAID 1 (--write-mostly/write-behind) anything done on RAMDisk will be persisted to SSD. So if I power off the Mac everything will be persisted on SSD and can loaded again during next start...



For better experience the most used applications could be installed to that OSX-System-Partition (SSD) which will also be available in the RAMDisk.



Of course there will be a second "data" partition on the SSD for all the other stuff.



How can I achieve the described setup - is it even possible with OSX? Which Bootloader can I use (Grub?)?










share|improve this question
























  • Er.. how big do you plan to have the Ramdisk? Ramdisk is only as big as your RAM. Mac SSD smallest size is 128GB, unless you plan to have 128GB of RAM? I doubt what you want is even possible.. and if you think about it, RAID1 on RAMDISK and SSD, means the RAID set can only work as fast as the slowest component, which is the SSD. You won't get any performance gain, even assuming it is even possible.
    – Darius
    Mar 3 '16 at 11:38










  • Thought I can use a software raid (do not know if I am able to use only certain partitions in a hardware raid) to use only one partition with osx installed + some apps (ca. 30GB?). I have 64GB Ram and would use 30GB for RAMDisk (in a RAID 1 with SSD-Partition of equal size). Another possibility could be to buy a small 32GB SSD for that. Thought with "--write-mostly / --write-behind" it is possible to delay the data replication a bit (to buy the ssd some time to cope with the ramdisk).
    – mfuesslin
    Mar 3 '16 at 11:45






  • 1




    Technically this might be possible. If you have two 'drives' (one th ramdisk and one a partition on the SSD - no need to use all of the SSDs space). But it might be more useful to use the standard trick for persistent ramdisks. Akak boot, (automatically) copy data to ramdisk. And on shutdown have a copy back to permanent storage.
    – Hennes
    Mar 3 '16 at 11:49










  • @Hennes - that's how I deal with a rather thrashy cache for one application I use. Create RAMDisk & copy out at launch, launch app. At quit, write back to a duplicate cache folder, then after safely copied, swap folders & erase the older one.
    – Tetsujin
    Mar 3 '16 at 11:58










  • @Hennes - But then I am not able to speed up OSX environment... Ok its fast enough already but would be still nice to have things opened instantly. But maybe I am able to load a ramdisk after boot and then copy most used apps in there and create a symlink to their pendants in the ramdisk to get them fast started? But then spotlight needs to reindex to let me open the "right" safari (in ram and not the one on my ssd)... mhm... any tricks how this could be an automatic workflow? Should I put the ssd-safari in a non-compressing zip so it is no longer visible to spotlight (so only ram-version is?)
    – mfuesslin
    Mar 3 '16 at 12:01


















1














Is it possible to create RAID 1 with RAMDisk and SSD in OSX?



Something like:
Boot Mac, OSX-Partition will be loaded from SSD in RAMDisk. Boot to RAMDisk and use it like any other system-drive. Because of RAID 1 (--write-mostly/write-behind) anything done on RAMDisk will be persisted to SSD. So if I power off the Mac everything will be persisted on SSD and can loaded again during next start...



For better experience the most used applications could be installed to that OSX-System-Partition (SSD) which will also be available in the RAMDisk.



Of course there will be a second "data" partition on the SSD for all the other stuff.



How can I achieve the described setup - is it even possible with OSX? Which Bootloader can I use (Grub?)?










share|improve this question
























  • Er.. how big do you plan to have the Ramdisk? Ramdisk is only as big as your RAM. Mac SSD smallest size is 128GB, unless you plan to have 128GB of RAM? I doubt what you want is even possible.. and if you think about it, RAID1 on RAMDISK and SSD, means the RAID set can only work as fast as the slowest component, which is the SSD. You won't get any performance gain, even assuming it is even possible.
    – Darius
    Mar 3 '16 at 11:38










  • Thought I can use a software raid (do not know if I am able to use only certain partitions in a hardware raid) to use only one partition with osx installed + some apps (ca. 30GB?). I have 64GB Ram and would use 30GB for RAMDisk (in a RAID 1 with SSD-Partition of equal size). Another possibility could be to buy a small 32GB SSD for that. Thought with "--write-mostly / --write-behind" it is possible to delay the data replication a bit (to buy the ssd some time to cope with the ramdisk).
    – mfuesslin
    Mar 3 '16 at 11:45






  • 1




    Technically this might be possible. If you have two 'drives' (one th ramdisk and one a partition on the SSD - no need to use all of the SSDs space). But it might be more useful to use the standard trick for persistent ramdisks. Akak boot, (automatically) copy data to ramdisk. And on shutdown have a copy back to permanent storage.
    – Hennes
    Mar 3 '16 at 11:49










  • @Hennes - that's how I deal with a rather thrashy cache for one application I use. Create RAMDisk & copy out at launch, launch app. At quit, write back to a duplicate cache folder, then after safely copied, swap folders & erase the older one.
    – Tetsujin
    Mar 3 '16 at 11:58










  • @Hennes - But then I am not able to speed up OSX environment... Ok its fast enough already but would be still nice to have things opened instantly. But maybe I am able to load a ramdisk after boot and then copy most used apps in there and create a symlink to their pendants in the ramdisk to get them fast started? But then spotlight needs to reindex to let me open the "right" safari (in ram and not the one on my ssd)... mhm... any tricks how this could be an automatic workflow? Should I put the ssd-safari in a non-compressing zip so it is no longer visible to spotlight (so only ram-version is?)
    – mfuesslin
    Mar 3 '16 at 12:01
















1












1








1


1





Is it possible to create RAID 1 with RAMDisk and SSD in OSX?



Something like:
Boot Mac, OSX-Partition will be loaded from SSD in RAMDisk. Boot to RAMDisk and use it like any other system-drive. Because of RAID 1 (--write-mostly/write-behind) anything done on RAMDisk will be persisted to SSD. So if I power off the Mac everything will be persisted on SSD and can loaded again during next start...



For better experience the most used applications could be installed to that OSX-System-Partition (SSD) which will also be available in the RAMDisk.



Of course there will be a second "data" partition on the SSD for all the other stuff.



How can I achieve the described setup - is it even possible with OSX? Which Bootloader can I use (Grub?)?










share|improve this question















Is it possible to create RAID 1 with RAMDisk and SSD in OSX?



Something like:
Boot Mac, OSX-Partition will be loaded from SSD in RAMDisk. Boot to RAMDisk and use it like any other system-drive. Because of RAID 1 (--write-mostly/write-behind) anything done on RAMDisk will be persisted to SSD. So if I power off the Mac everything will be persisted on SSD and can loaded again during next start...



For better experience the most used applications could be installed to that OSX-System-Partition (SSD) which will also be available in the RAMDisk.



Of course there will be a second "data" partition on the SSD for all the other stuff.



How can I achieve the described setup - is it even possible with OSX? Which Bootloader can I use (Grub?)?







macos boot bootloader raid-1 ramdisk






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 3 '16 at 11:38

























asked Mar 3 '16 at 11:32









mfuesslin

2815




2815












  • Er.. how big do you plan to have the Ramdisk? Ramdisk is only as big as your RAM. Mac SSD smallest size is 128GB, unless you plan to have 128GB of RAM? I doubt what you want is even possible.. and if you think about it, RAID1 on RAMDISK and SSD, means the RAID set can only work as fast as the slowest component, which is the SSD. You won't get any performance gain, even assuming it is even possible.
    – Darius
    Mar 3 '16 at 11:38










  • Thought I can use a software raid (do not know if I am able to use only certain partitions in a hardware raid) to use only one partition with osx installed + some apps (ca. 30GB?). I have 64GB Ram and would use 30GB for RAMDisk (in a RAID 1 with SSD-Partition of equal size). Another possibility could be to buy a small 32GB SSD for that. Thought with "--write-mostly / --write-behind" it is possible to delay the data replication a bit (to buy the ssd some time to cope with the ramdisk).
    – mfuesslin
    Mar 3 '16 at 11:45






  • 1




    Technically this might be possible. If you have two 'drives' (one th ramdisk and one a partition on the SSD - no need to use all of the SSDs space). But it might be more useful to use the standard trick for persistent ramdisks. Akak boot, (automatically) copy data to ramdisk. And on shutdown have a copy back to permanent storage.
    – Hennes
    Mar 3 '16 at 11:49










  • @Hennes - that's how I deal with a rather thrashy cache for one application I use. Create RAMDisk & copy out at launch, launch app. At quit, write back to a duplicate cache folder, then after safely copied, swap folders & erase the older one.
    – Tetsujin
    Mar 3 '16 at 11:58










  • @Hennes - But then I am not able to speed up OSX environment... Ok its fast enough already but would be still nice to have things opened instantly. But maybe I am able to load a ramdisk after boot and then copy most used apps in there and create a symlink to their pendants in the ramdisk to get them fast started? But then spotlight needs to reindex to let me open the "right" safari (in ram and not the one on my ssd)... mhm... any tricks how this could be an automatic workflow? Should I put the ssd-safari in a non-compressing zip so it is no longer visible to spotlight (so only ram-version is?)
    – mfuesslin
    Mar 3 '16 at 12:01




















  • Er.. how big do you plan to have the Ramdisk? Ramdisk is only as big as your RAM. Mac SSD smallest size is 128GB, unless you plan to have 128GB of RAM? I doubt what you want is even possible.. and if you think about it, RAID1 on RAMDISK and SSD, means the RAID set can only work as fast as the slowest component, which is the SSD. You won't get any performance gain, even assuming it is even possible.
    – Darius
    Mar 3 '16 at 11:38










  • Thought I can use a software raid (do not know if I am able to use only certain partitions in a hardware raid) to use only one partition with osx installed + some apps (ca. 30GB?). I have 64GB Ram and would use 30GB for RAMDisk (in a RAID 1 with SSD-Partition of equal size). Another possibility could be to buy a small 32GB SSD for that. Thought with "--write-mostly / --write-behind" it is possible to delay the data replication a bit (to buy the ssd some time to cope with the ramdisk).
    – mfuesslin
    Mar 3 '16 at 11:45






  • 1




    Technically this might be possible. If you have two 'drives' (one th ramdisk and one a partition on the SSD - no need to use all of the SSDs space). But it might be more useful to use the standard trick for persistent ramdisks. Akak boot, (automatically) copy data to ramdisk. And on shutdown have a copy back to permanent storage.
    – Hennes
    Mar 3 '16 at 11:49










  • @Hennes - that's how I deal with a rather thrashy cache for one application I use. Create RAMDisk & copy out at launch, launch app. At quit, write back to a duplicate cache folder, then after safely copied, swap folders & erase the older one.
    – Tetsujin
    Mar 3 '16 at 11:58










  • @Hennes - But then I am not able to speed up OSX environment... Ok its fast enough already but would be still nice to have things opened instantly. But maybe I am able to load a ramdisk after boot and then copy most used apps in there and create a symlink to their pendants in the ramdisk to get them fast started? But then spotlight needs to reindex to let me open the "right" safari (in ram and not the one on my ssd)... mhm... any tricks how this could be an automatic workflow? Should I put the ssd-safari in a non-compressing zip so it is no longer visible to spotlight (so only ram-version is?)
    – mfuesslin
    Mar 3 '16 at 12:01


















Er.. how big do you plan to have the Ramdisk? Ramdisk is only as big as your RAM. Mac SSD smallest size is 128GB, unless you plan to have 128GB of RAM? I doubt what you want is even possible.. and if you think about it, RAID1 on RAMDISK and SSD, means the RAID set can only work as fast as the slowest component, which is the SSD. You won't get any performance gain, even assuming it is even possible.
– Darius
Mar 3 '16 at 11:38




Er.. how big do you plan to have the Ramdisk? Ramdisk is only as big as your RAM. Mac SSD smallest size is 128GB, unless you plan to have 128GB of RAM? I doubt what you want is even possible.. and if you think about it, RAID1 on RAMDISK and SSD, means the RAID set can only work as fast as the slowest component, which is the SSD. You won't get any performance gain, even assuming it is even possible.
– Darius
Mar 3 '16 at 11:38












Thought I can use a software raid (do not know if I am able to use only certain partitions in a hardware raid) to use only one partition with osx installed + some apps (ca. 30GB?). I have 64GB Ram and would use 30GB for RAMDisk (in a RAID 1 with SSD-Partition of equal size). Another possibility could be to buy a small 32GB SSD for that. Thought with "--write-mostly / --write-behind" it is possible to delay the data replication a bit (to buy the ssd some time to cope with the ramdisk).
– mfuesslin
Mar 3 '16 at 11:45




Thought I can use a software raid (do not know if I am able to use only certain partitions in a hardware raid) to use only one partition with osx installed + some apps (ca. 30GB?). I have 64GB Ram and would use 30GB for RAMDisk (in a RAID 1 with SSD-Partition of equal size). Another possibility could be to buy a small 32GB SSD for that. Thought with "--write-mostly / --write-behind" it is possible to delay the data replication a bit (to buy the ssd some time to cope with the ramdisk).
– mfuesslin
Mar 3 '16 at 11:45




1




1




Technically this might be possible. If you have two 'drives' (one th ramdisk and one a partition on the SSD - no need to use all of the SSDs space). But it might be more useful to use the standard trick for persistent ramdisks. Akak boot, (automatically) copy data to ramdisk. And on shutdown have a copy back to permanent storage.
– Hennes
Mar 3 '16 at 11:49




Technically this might be possible. If you have two 'drives' (one th ramdisk and one a partition on the SSD - no need to use all of the SSDs space). But it might be more useful to use the standard trick for persistent ramdisks. Akak boot, (automatically) copy data to ramdisk. And on shutdown have a copy back to permanent storage.
– Hennes
Mar 3 '16 at 11:49












@Hennes - that's how I deal with a rather thrashy cache for one application I use. Create RAMDisk & copy out at launch, launch app. At quit, write back to a duplicate cache folder, then after safely copied, swap folders & erase the older one.
– Tetsujin
Mar 3 '16 at 11:58




@Hennes - that's how I deal with a rather thrashy cache for one application I use. Create RAMDisk & copy out at launch, launch app. At quit, write back to a duplicate cache folder, then after safely copied, swap folders & erase the older one.
– Tetsujin
Mar 3 '16 at 11:58












@Hennes - But then I am not able to speed up OSX environment... Ok its fast enough already but would be still nice to have things opened instantly. But maybe I am able to load a ramdisk after boot and then copy most used apps in there and create a symlink to their pendants in the ramdisk to get them fast started? But then spotlight needs to reindex to let me open the "right" safari (in ram and not the one on my ssd)... mhm... any tricks how this could be an automatic workflow? Should I put the ssd-safari in a non-compressing zip so it is no longer visible to spotlight (so only ram-version is?)
– mfuesslin
Mar 3 '16 at 12:01






@Hennes - But then I am not able to speed up OSX environment... Ok its fast enough already but would be still nice to have things opened instantly. But maybe I am able to load a ramdisk after boot and then copy most used apps in there and create a symlink to their pendants in the ramdisk to get them fast started? But then spotlight needs to reindex to let me open the "right" safari (in ram and not the one on my ssd)... mhm... any tricks how this could be an automatic workflow? Should I put the ssd-safari in a non-compressing zip so it is no longer visible to spotlight (so only ram-version is?)
– mfuesslin
Mar 3 '16 at 12:01












1 Answer
1






active

oldest

votes


















0














From comments, here's the bones of how I do a RAMDisk setup & copy back.



It's not the complete structure, so won't compile as it stands [there will be many missing declarations, as I have a whole set of other structures before I get to this bit, that aren't generic enough to be worth copying in], but gives the routines for creation, copy out & copy back. Save it as an application & launch this instead of your app.



There's also no provision in it for telling your app to use it - that, for me, is a separate structure just using the app's prefs & some —settings instructions at launch.



It's also set to cover if a mismatch occurs - that's because I have several versions of that particular app, & caches should not be mixed. You can probably leave that section out.



-- 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 existsnDelete & 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





share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1048114%2framdisk-ssd-raid-1-boot-osx%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    From comments, here's the bones of how I do a RAMDisk setup & copy back.



    It's not the complete structure, so won't compile as it stands [there will be many missing declarations, as I have a whole set of other structures before I get to this bit, that aren't generic enough to be worth copying in], but gives the routines for creation, copy out & copy back. Save it as an application & launch this instead of your app.



    There's also no provision in it for telling your app to use it - that, for me, is a separate structure just using the app's prefs & some —settings instructions at launch.



    It's also set to cover if a mismatch occurs - that's because I have several versions of that particular app, & caches should not be mixed. You can probably leave that section out.



    -- 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 existsnDelete & 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





    share|improve this answer


























      0














      From comments, here's the bones of how I do a RAMDisk setup & copy back.



      It's not the complete structure, so won't compile as it stands [there will be many missing declarations, as I have a whole set of other structures before I get to this bit, that aren't generic enough to be worth copying in], but gives the routines for creation, copy out & copy back. Save it as an application & launch this instead of your app.



      There's also no provision in it for telling your app to use it - that, for me, is a separate structure just using the app's prefs & some —settings instructions at launch.



      It's also set to cover if a mismatch occurs - that's because I have several versions of that particular app, & caches should not be mixed. You can probably leave that section out.



      -- 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 existsnDelete & 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





      share|improve this answer
























        0












        0








        0






        From comments, here's the bones of how I do a RAMDisk setup & copy back.



        It's not the complete structure, so won't compile as it stands [there will be many missing declarations, as I have a whole set of other structures before I get to this bit, that aren't generic enough to be worth copying in], but gives the routines for creation, copy out & copy back. Save it as an application & launch this instead of your app.



        There's also no provision in it for telling your app to use it - that, for me, is a separate structure just using the app's prefs & some —settings instructions at launch.



        It's also set to cover if a mismatch occurs - that's because I have several versions of that particular app, & caches should not be mixed. You can probably leave that section out.



        -- 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 existsnDelete & 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





        share|improve this answer












        From comments, here's the bones of how I do a RAMDisk setup & copy back.



        It's not the complete structure, so won't compile as it stands [there will be many missing declarations, as I have a whole set of other structures before I get to this bit, that aren't generic enough to be worth copying in], but gives the routines for creation, copy out & copy back. Save it as an application & launch this instead of your app.



        There's also no provision in it for telling your app to use it - that, for me, is a separate structure just using the app's prefs & some —settings instructions at launch.



        It's also set to cover if a mismatch occurs - that's because I have several versions of that particular app, & caches should not be mixed. You can probably leave that section out.



        -- 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 existsnDelete & 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






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 3 '16 at 12:24









        Tetsujin

        15.4k53261




        15.4k53261






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1048114%2framdisk-ssd-raid-1-boot-osx%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Probability when a professor distributes a quiz and homework assignment to a class of n students.

            Aardman Animations

            Are they similar matrix