📜 ⬆️ ⬇️

Go to Fusion Drive


Active users of Mac OS X will surely remember the Fusion Drive feature announced on October 23. Let me remind you that it is a logical combination of SSDs and HDDs installed on your Mac. The size of a single disk will be equal to the sum of the volumes of SSD and HDD, but the main plus is that frequently used files (for example, the system core) Mac OS automatically and transparently places the user on a faster SSD, and all other files on the HDD.


Attention!
A technique for advanced Mac OS X users in the arsenal of which is a neat command of the command line, disk utility and system recovery mode.


To implement the function, I chose my MacBook, which had previously undergone an SSD installation instead of an optical drive. I placed the system and home folder on the SSD, and from the HDD I made a separate section for the download folder, the virtual machine folder and other heavy files. Although I received a big increase in system performance, over time it became more and more often to clean the SSD, which periodically ran out of space. The number of created symbolic links from the home folder to the large disk is also strained.
')
It looked like a disk system before upgrading
[root@ibook Volumes]# df Filesystem Size Used Avail Capacity iused ifree %iused Mounted on /dev/disk0s2 59Gi 48Gi 10Gi 83% 12631725 2735773 82% / /dev/disk1s2 232Gi 153Gi 80Gi 66% 39984428 20948470 66% /Volumes/iBookData 


The transition to the Fusion Drive should eliminate all the inconveniences associated with the separate use of multiple disks of different sizes and performance. File systems on disks that are combined in a Fusion Drive will be destroyed, so the system and all data must be transferred from them. I used an external hard drive for this. I also planned to replace the SSD with another with a slightly smaller volume, but better performance, so I did not need to transfer the system to a temporary disk.

Used hardware and software:


All operations for setting up and transferring data to the Fusion Drive can be performed in two ways:
a) booting from an “old” SSD connected via USB-snap-in and later cloning a system from it using Carbon Copy Cloner;
b) booting into the system recovery mode over the network and restoring the system from Time Machine.

I tried both ways. The second seemed to me more elegant because is built-in and does not require additional software and external USB-accessories for temporary boot from the old system disk.

In the description of the procedure, the steps relating to different methods are labeled "a" and "b" respectively.

Go!


0. At the preparatory stage, we make a backup of the system partition via Time Machine, and transfer data from a large disk to a temporary one. Once again I remind you that in the process of creating Fusion Drive, the file systems on the disks forming it will be destroyed.

1. Disassemble the patient and install the new SSD instead of the old one, assemble it.

2a We turn on MacBook by holding Cmd + Opt + R. After the appearance of the globe, release the keys and wait for the recovery disk to load from the Internet.

2b. We turn on the MacBook by holding Opt. As a boot, select the "old" drive connected via USB.

3. After downloading the MacBook, open the terminal.

We look at the current configuration of disks
 [root@ibook /]# diskutil list /dev/disk0 #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *60.0 GB disk0 1: EFI 209.7 MB disk0s1 2: Apple_HFS Untitled 59.7 GB disk0s2 3: Apple_Boot Boot OS X 134.2 MB disk0s3 /dev/disk1 #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *250.1 GB disk1 1: EFI 209.7 MB disk1s1 2: Apple_HFS Untitled 1 249.7 GB disk1s2 3: Apple_Boot Boot OS X 134.2 MB disk1s3 … 


We memorize and write down the correspondence of names to real disks.
In my case, disk0 is the new SSD 60Gb, disk1 large HDD 250Gb. My disks have already been configured with GUID partitions and HFS partitions have been created on them. If your disks are empty, you need to open the disk utility and clean the necessary disks by creating a GUID table and one large HFS partition on them.

4. In practice, Apple Fusion Drive is an analogue of the Logical Volume Manager (LVM). Mac OS X is implemented by the CoreStorage subsystem. All manipulations are performed by the console disk utility diskutil with the corestorage parameter or simply cs.

4.1. Create a new volume group specifying the group name and the names of the physical SSD and HDD in the correct order.
 [root@ibook /]# diskutil cs create iBookLVG disk0 disk1 Started CoreStorage operation Unmounting disk0 Repartitioning disk0 Unmounting disk Creating the partition map Rediscovering disk0 Adding disk0s2 to Logical Volume Group Unmounting disk1 Repartitioning disk1 Unmounting disk Creating the partition map Rediscovering disk1 Adding disk1s2 to Logical Volume Group Creating Core Storage Logical Volume Group Switching disk0s2 to Core Storage Switching disk1s2 to Core Storage Waiting for Logical Volume Group to appear Discovered new Logical Volume Group "83AD8C5F-5883-4110-89D7-6097BA33AFBB" Core Storage LVG UUID: 83AD8C5F-5883-4110-89D7-6097BA33AFBB Finished CoreStorage operation 


Checking what happened
 [root@ibook /]# diskutil cs list CoreStorage logical volume groups (1 found) | +-- Logical Volume Group 83AD8C5F-5883-4110-89D7-6097BA33AFBB ========================================================= Name: iBookLVG Size: 309393883136 B (309.4 GB) Free Space: 122880 B (122.9 KB) | +-< Physical Volume 8CEC5A9F-DB16-4C85-897E-700B69BC0D4C | ---------------------------------------------------- | Index: 0 | Disk: disk0s2 | Status: Online | Size: 59678507008 B (59.7 GB) | +-< Physical Volume 8F1CE39C-425D-411B-B481-62E601F237C8 ---------------------------------------------------- Index: 1 Disk: disk1s2 Status: Online Size: 249715376128 B (249.7 GB) 


4.2. Create a logical volume in the volume group 83AD8C5F-5883-4110-89D7-6097BA33AFBB, which is 100% of the group size.
 [root@ibook /]# diskutil cs createVolume 83AD8C5F-5883-4110-89D7-6097BA33AFBB jhfs+ LV 100% Started CoreStorage operation Waiting for Logical Volume to appear Formatting file system for Logical Volume Initialized /dev/rdisk3 as a 307 GB HFS Plus volume with a 32768k journal Mounting disk Core Storage LV UUID: CB7195D6-582C-449D-8303-43961C1C55FE Core Storage disk: disk3 Finished CoreStorage operation 


Result:
 [root@ibook /]# diskutil cs list CoreStorage logical volume groups (1 found) | +-- Logical Volume Group 83AD8C5F-5883-4110-89D7-6097BA33AFBB ========================================================= Name: iBookLVG Size: 309393883136 B (309.4 GB) Free Space: 122880 B (122.9 KB) | +-< Physical Volume 8CEC5A9F-DB16-4C85-897E-700B69BC0D4C | ---------------------------------------------------- | Index: 0 | Disk: disk0s2 | Status: Online | Size: 59678507008 B (59.7 GB) | +-< Physical Volume 8F1CE39C-425D-411B-B481-62E601F237C8 | ---------------------------------------------------- | Index: 1 | Disk: disk1s2 | Status: Online | Size: 249715376128 B (249.7 GB) | +-> Logical Volume Family C2CF1DC7-8EE8-4AE2-8E2F-4F2B9C7DF7EE ---------------------------------------------------------- Encryption Status: Unlocked Encryption Type: None Conversion Status: NoConversion Conversion Direction: -none- Has Encrypted Extents: No Fully Secure: No Passphrase Required: No | +-> Logical Volume CB7195D6-582C-449D-8303-43961C1C55FE --------------------------------------------------- Disk: disk2 Status: Online Size (Total): 307354009600 B (307.4 GB) Size (Converted): -none- Revertible: No LV Name: LV Volume Name: LV Content Hint: Apple_HFS 


The system has a new disk partition Fusion Drive - disk2
 [root@ibook /]# diskutil list /dev/disk0 #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *60.0 GB disk0 1: EFI 209.7 MB disk0s1 2: Apple_CoreStorage 59.7 GB disk0s2 3: Apple_Boot Boot OS X 134.2 MB disk0s3 /dev/disk1 #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *250.1 GB disk1 1: EFI 209.7 MB disk1s1 2: Apple_CoreStorage 249.7 GB disk1s2 3: Apple_Boot Boot OS X 134.2 MB disk1s3 /dev/disk2 #: TYPE NAME SIZE IDENTIFIER 0: Apple_HFS LV *307.4 GB disk2 


Close the terminal.

5a. Restore the system from Time Machine to the created section Fusion Drive.

5 B. We launch Carbon Copy Cloner and clone the system from the “old” SSD to the Fusion Drive section.

Reboot.

6. After booting from Fusion Drive, I disabled the update of file access time for the HFS root partition and rebooted again.
 [root@ibook /]# cat > /Library/LaunchDaemons/com.noatime.root.plist <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.noatime.root</string> <key>ProgramArguments</key> <array> <string>mount</string> <string>-uwo</string> <string>noatime</string> <string>/</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist> 


As a result, the disk system looks like this
 [root@ibook /]# df -h Filesystem Size Used Avail Capacity iused ifree %iused Mounted on /dev/disk2 286Gi 34Gi 252Gi 12% 9001947 66035651 12% / … [root@ibook /]# mount /dev/disk2 on / (hfs, local, journaled, noatime) … 


7. Copy the data from the temporary disk back to the MacBook.

In the process of copying control the activity of individual drives components Fusion Drive
 [root@ibook /]# iostat 1 disk0 disk1 disk3 cpu load average KB/t tps MB/s KB/t tps MB/s KB/t tps MB/s us sy id 1m 5m 15m 207.34 170 34.34 0.00 0 0.00 126.16 277 34.17 13 14 73 1.24 1.11 0.86 260.84 167 42.45 0.00 0 0.00 125.78 280 34.44 9 17 74 1.24 1.11 0.86 251.41 148 36.27 0.00 0 0.00 125.91 280 34.49 12 16 73 1.24 1.11 0.86 ... 


When the space on the SSD (disk0) runs out, the data will be recorded on the HDD (disk1), which will be reflected in the corresponding column.
  280.52 122 33.37 0.00 0 0.00 123.84 278 33.57 19 16 64 1.65 1.24 0.93 205.77 179 35.91 0.00 0 0.00 126.11 283 34.79 20 18 61 1.65 1.24 0.93 274.48 132 35.32 0.00 0 0.00 123.96 288 34.80 16 15 69 1.68 1.25 0.93 264.53 106 27.33 442.67 3 1.29 125.38 211 25.79 9 15 76 1.68 1.25 0.93<------------------- 7.20 10 0.07 313.53 102 31.16 125.87 218 26.74 13 15 72 1.68 1.25 0.93 5.17 216 1.09 243.64 145 34.44 126.06 276 33.92 15 20 65 1.80 1.29 0.95 5.01 127 0.62 221.40 171 36.91 126.49 279 34.41 14 17 69 1.74 1.29 0.95 


Check if file migration from HDD to SSD is working


The test method was chosen simple - with the help of dd we read the same large file several times while observing the activity of the disks. For the test, I selected a 2GB virtual machine image file that was recorded on the HDD disk of the new storage after filling out the SSD.

Read # 1

 [root@ibook Elsa.vmwarevm]# dd if=Elsa-s007.vmdk of=/dev/null bs=100m 18+1 records in 18+1 records out 1987051520 bytes transferred in 31.128078 secs (63834700 bytes/sec) 


In another console, monitor the load using iostat:
  disk0 disk1 cpu load average KB/t tps MB/s KB/t tps MB/s us sy id 1m 5m 15m 0.00 0 0.00 0.00 0 0.00 4 3 93 10.39 5.95 3.32 6.86 7 0.05 0.00 0 0.00 4 4 91 9.55 5.85 3.30 76.80 5 0.37 496.30 106 51.25 4 12 85 9.55 5.85 3.30 <-------- 56.80 10 0.55 481.88 102 47.88 12 10 79 9.55 5.85 3.30 64.00 2 0.12 504.07 113 55.54 7 10 84 9.55 5.85 3.30 52.50 8 0.41 494.75 141 67.96 13 11 76 8.79 5.76 3.28 44.00 3 0.13 503.47 135 66.27 4 10 86 8.79 5.76 3.28 


It is seen that the data is read from the HDD (disk1), and the SSD is slightly loaded apparently by the system.

Read # 2

 [root@ibook Elsa.vmwarevm]# dd if=Elsa-s007.vmdk of=/dev/null bs=100m 18+1 records in 18+1 records out 1987051520 bytes transferred in 39.535700 secs (50259677 bytes/sec) 


In another iostat console:
  107.11 18 1.88 448.52 123 53.75 4 11 86 3.45 4.78 3.10 54.74 35 1.87 445.15 108 46.87 4 11 85 3.45 4.78 3.10 124.00 93 11.24 288.20 159 44.68 5 11 84 3.45 4.78 3.10 118.05 325 37.52 128.00 298 37.31 4 12 84 3.45 4.78 3.10 <-------- 67.48 547 36.05 128.00 261 32.63 21 14 64 3.49 4.76 3.10 84.42 430 35.47 128.81 278 34.91 15 16 69 3.49 4.76 3.10 127.01 370 45.84 128.00 367 45.82 5 13 81 3.49 4.76 3.10 119.30 344 40.13 128.00 318 39.81 2 12 86 3.49 4.76 3.10 


We draw attention to the slightly increased reading time and the continued load on the HDD at the end of the dd process. Obviously, the system transfers our file to the SSD, trying to make this process more invisible by limiting the speed of data exchange.

Observe the end of the transfer process:
  124.39 439 53.38 128.00 426 53.31 46 23 31 2.48 3.97 2.95 92.67 385 34.84 127.57 271 33.78 52 16 32 2.48 3.97 2.95 126.04 422 51.89 128.00 416 51.95 65 22 13 2.92 4.04 2.98 83.21 177 14.37 128.00 111 13.89 25 10 65 2.92 4.04 2.98 4.40 10 0.04 0.00 0 0.00 18 10 72 2.92 4.04 2.98 <--------- 4.44 18 0.08 0.00 0 0.00 13 11 77 2.92 4.04 2.98 6.29 7 0.04 0.00 0 0.00 16 10 74 2.92 4.04 2.98 


Read # 3

 [root@ibook Elsa.vmwarevm]# dd if=Elsa-s007.vmdk of=/dev/null bs=100m 18+1 records in 18+1 records out 1987051520 bytes transferred in 8.074579 secs (246087322 bytes/sec) 


iostat:
  9.50 16 0.15 0.00 0 0.00 18 10 72 2.55 3.92 2.95 4.00 1 0.00 0.00 0 0.00 9 4 87 2.55 3.92 2.95 238.63 308 71.89 0.00 0 0.00 6 16 78 2.55 3.92 2.95 464.47 506 229.70 0.00 0 0.00 4 22 74 2.55 3.92 2.95 462.12 532 240.12 0.00 0 0.00 4 21 75 2.55 3.92 2.95 430.49 545 229.11 0.00 0 0.00 6 22 72 2.43 3.87 2.94 


Only SSD drive is involved, and reading time has decreased several times.
The experience described in the network by other users also confirms the work of this functionality.

With high probability, the procedure can be successfully performed on Apple computers of previous versions and in other form factors. I have a Mac Mini on my turn.

Thanks for attention.

Used sources


Fusion drive on older Macs? YES!
Undocumented CoreStorage Commands

Ps.


  1. Combining disks into a logical volume group increases the risk of losing all data when LVM is destroyed. Be sure to set up your Time Machine backup.
  2. It is possible to convert a disk to LVM volume and back without formatting and without data loss. However, the undocumented possibility of adding a second disk to that unfortunately does not work, which does not allow making the transition to the Fusion Drive even easier and faster. It is necessary to decide in advance how many disks will be used in the group, since while it is not possible to change their number on the fly. We will wait for the expansion of functionality from Apple.


UPDATE


They waited! In Mac OS X Mavericks, the functionality is extended. Details here .

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


All Articles