📜 ⬆️ ⬇️

Transfer user folders to another HDD

Based on this post with a few additions. I could not leave a comment to the above post, so I am writing a new article.

I decided to upgrade my Mac mini (late 2012), equipping it with an Intel X25-M 160GB SSD. Operating system - Yosemite 10.10.1. I stuck the SSD under the article with iFixit - there is nothing complicated, I ordered the SSD cable from our friends from the “heavenly”. I decided to do this in such a way - operating systems and programs on the SSD, user data on the HDD.

Since I prefer unix way, I decided to mount the HDD in / Users

First, I copied a boot disk with the help of Carbon Copy Cloner, besides user data (/ Users) to the SSD. Next, I moved the / Users / username / folder to the root of the HDD and rebooted from the Recovery section. To do this, we clamp alt at boot and select Recovery (in principle, you can boot from any bootable USB flash drive with OS X on board).
I deleted all partitions and files from the HDD except / username, cleared the / Users folder on the SSD so that the disk was mounted.
')
The mounting process is described in the above post in the “Method 2” section, so I will not repeat it again, although there is only one addition. When defining a disk UUID with the command:

diskutil info /Volumes/HDD/ | grep UUID 

On the output, get two UUID codes - logical volume and partition. Need to take the first in the list.

  Volume UUID: 409AF953-4812-38DA-A0D9-4B0C5C49BC8E Disk / Partition UUID: 00000DAE-5F23-0000-586C-0000281D0000 

In principle, it is possible to specify in the mount options not the UUID, but simply the name of the disk in / dev /. For example, / dev / disk1s2 - I usually do it on linux.

The name of the desired disk can be defined with the command:
 diskutil list 

Regarding SSD mount option - noatime. I didn’t do anything on my own - my default OS installed SSD with this option. Perhaps this is a feature of Yosemite.
 macmini:~ home$ mount /dev/disk0s2 on / (hfs, local, journaled, noatime) devfs on /dev (devfs, local, nobrowse) /dev/disk1s2 on /Users (hfs, local, journaled) map -hosts on /net (autofs, nosuid, automounted, nobrowse) map auto_home on /home (autofs, automounted, nobrowse) 

TRIM activated with Chameleon SSD Optimizer .

Hibernation file moved here - /Users/.vm
The procedure is described normally in the post.
Check if hibernate and its mode is working.
 sudo pmset -g 


What is not specified
It is also necessary to transfer the swap to HDD. The procedure is described in detail here .

Briefly set out the procedure:
To begin with we define in what folder the swap will lie. I decided in the same where the hibernation file is /Users/.vm
 sudo mkdir /Users/.vm 

Naturally, my OS is already loaded with SSD and the HDD is mounted in / Users.
Open the terminal and make a backup of the swap settings file.
 $ cd /System/Library/LaunchDaemons $ sudo cp com.apple.dynamic_pager.plist{,_bak} 

Convert binary settings file to XML.
 sudo plutil -convert xml1 com.apple.dynamic_pager.plist 

Open the settings file with any editor, I used vim.
 sudo vim com.apple.dynamic_pager.plist 

Change the same lines to the following.
 <key>ProgramArguments</key> <array> <string>/bin/bash</string> <string>-c</string> <string>/bin/wait4path /Users/.vm &am;&am; /sbin/dynamic_pager -F /Users/.vm/swapfile</string> </array> 

For those who do not know how to use vim - press “i” for editing, at the end of editing press “Esc” and in order to write the file
": wq".

Convert back to binary:
 sudo plutil -convert binary1 com.apple.dynamic_pager.plist 

IMPORTANT MOMENT - in the above listing com.apple.dynamic_pager.plist in codes & am p ; the letter p is the Russian era !
Therefore, it is better not to copy, but to reprint. Otherwise he couldn’t do it - forum scripts convert & am; in & .

Reboot. If something goes wrong - we boot into verbose mode (Command-v when loaded) or single mode (Command-s when loaded) and restore the settings file from the backup.
The author also explains why it is necessary to use the waith4path console utility - the dynamic_page process (swap management)
It runs at a very early stage of the launch of the OS and other disks besides the root may not have time to mount at this stage, which will lead to problems.

See if the swap was created in a new way.
 cd /Users/.vm $ ls -la 

I have a lot of RAM, so I had to launch a bunch of programs in order for the kernel to start writing in a swap.
If everything is OK, delete the old swap.
 $ cd /private/var/vm $ sudo rm swapfile* 

Check if swap is enabled.
 sysctl vm.swapusage 

Another important point - we exclude the folder with the hibernation file and the swap from TimeMachine.
In order not to create a backup of the swap and hibernation file. I have the same folder for this:
 sudo tmutil addexclusion -p /Users/.vm 

Checking:
 tmutil isexcluded /Users/.vm 

And they also recommend that you exclude swaps from indices, but the following command will work only if you have a swap and a hibernation file on a separate logical volume.
A kind of linux way.
 sudo mdutil -i off /pathtoswap && sudo mdutil -E /pathtoswap 

Check the indexing can be so.
 sudo mdutil -s /pathtoswap 

Successes!

Source: https://habr.com/ru/post/376153/


All Articles