How can I delete a partition (coreStorage logical volume?) from the Terminal? I finally understood why Disk Utility will not change the partitions on my HDD, even though I added the most recent one myself (maybe significant: to test Yosemite DP) with it. Now I see it says it won't change either partition, because it has encrypted data and CoreStorage objects. It tells me vaguely to use diskutil from the command line for this, but this makes me a bit uncomfortable. I found a very similar question here,  with a great but incomplete answer about how to resolve this. How can one drop the smaller partition, then?

Note that I don't even see my pain partition from diskutil corestorage list (output below), which is worrisome.

Also note (also in the older question) that the name of the disk is unstable, sometimes Disk Utility lists my original, old name for the disk (Toshiba…), sometimes the name of the new, smaller partition. Note that I made these partitions from within Mavericks, not Yosemite. Why would Yosemite mess with this?

My relevant Terminal output:

d2m66h2j:~ laszlosandor$ diskutil list; echo; diskutil cs list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *320.1 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            289.2 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
   4:          Apple_CoreStorage                         29.3 GB    disk0s4
   5:                 Apple_Boot Recovery HD             650.0 MB   disk0s5
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                  Apple_HFS OS X Test              *28.8 GB    disk1

CoreStorage logical volume groups (1 found)
|
+-- Logical Volume Group B6308EC8-297D-44BD-9212-6BD867F6331B
    =========================================================
    Name:         OS X Test
    Status:       Online
    Size:         29349998592 B (29.3 GB)
    Free Space:   204955648 B (205.0 MB)
    |
    +-&lt; Physical Volume 3325F333-C8E3-46EE-9357-5E0C21A600D1
    |   ----------------------------------------------------
    |   Index:    0
    |   Disk:     disk0s4
    |   Status:   Online
    |   Size:     29349998592 B (29.3 GB)
    |
    +-&gt; Logical Volume Family E8CB0EB7-A2B7-48AA-AA13-5DE30867901B
        ----------------------------------------------------------
        Encryption Status:       Unlocked
        Encryption Type:         None
        Conversion Status:       NoConversion
        Conversion Direction:    -none-
        Has Encrypted Extents:   No
        Fully Secure:            No
        Passphrase Required:     No
        |
        +-&gt; Logical Volume 2F7B1893-07E8-4194-840B-F2552042E055
            ---------------------------------------------------
            Disk:                  disk1
            Status:                Online
            Size (Total):          28809494528 B (28.8 GB)
            Conversion Progress:   -none-
            Revertible:            Yes (no decryption required)
            LV Name:               OS X Test
            Volume Name:           OS X Test
            Content Hint:          Apple_HFS
I highly recommend completely backing up the machine before attempting this, either using TM with no exclusions set, or better yet, cloning the whole drive using a program like Carbon Copy Cloner.

Unmount the Logical Volume:

sudo diskutil unmount force /dev/disk1


Remove the Logical Volume Group and all of its contents:

sudo diskutil cs deleteLVG B6308EC8-297D-44BD-9212-6BD867F6331B


From diskutil's man page:


  delete | deleteLVG lvgUUID | lvgName
           Delete a CoreStorage logical volume group. All logical volume families with their
           logical volumes are removed, the logical volume group is destroyed, and the now-
           orphaned physical volumes are erased and partition-typed as Journaled HFS+.



Merge the now orphaned partition disk0s4 into startup volume disk0s2 (note: disk0s3, one recovery partition, will be erased and merged as well). disk0s5, the other recovery partition, shouldn't be affected:

sudo diskutil mergePartitions HFS+ "Apple_HFS Macintosh HD" disk0s2 disk0s4


Again, from the man pages:

 Merge two or more partitions on a disk.  All data on merged partitions other than the first
                will be lost.  Data on the first partition will be lost as well if the force argument is
                given.

                If force is not given, and the first partition has a resizable file system (e.g. JHFS+), the
                file system will be preserved and grown in a data-preserving manner; your format and name
                parameters are ignored in this case.


Verify the boot Volume structure. 

diskUtil VerifyVolume /


Verify the partition map:

diskutil verifyDisk disk0


Boot into Recovery Mode, or Internet Recovery if needed -- if any errors appear:

You should be left with:

/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *320.1 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            319.7 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3