Partition using Terminal

Last couple of weeks have been a great learning experience. I needed a “Case-sensitive Journaled HFS+” file system on my machine. By default Macintosh supports Case-insensitive file system. The normal way of partitioning the drives would be to use Disk Utility application but fortunately it displayed Mac OS extended(case-insensitive, Journalated) as an option for partition format and not HFS+. I didn’t realize that HFS+ is also called Mac OS extended. So I decided to use the terminal for creating a new partition. I will take you guys through the process of creating new partition from Terminal.


Step 1

Type “diskutil listFilesystems” command on the terminal, you get the list of file system supported by your Macintosh. You can refer the image displayed below.

Run 'diskutil listFilesystems' on terminal. (Click on the image to enlarge it)

(Once I went through the entire list, I realized that HFS+ is also called Mac OS extended. Since I had come this far, I decided to go ahead and create a case-insensitive hfs+ partition from terminal. Another reason being I was hopelessly stuck in the task I was working on, I thought this might help change the state of my mind)

Back to the discussion on hand.

Step 2
Before making any partitions lets check the file system once, because we need few information regarding the partitions currently available on the machine. Type ‘diskutil list‘ on terminal and press enter. You will get information like identifier, size and partition format type, which will come in handy in next stage.

Refer the image below for details.

Run 'diskutil list' on terminal (Click on the image to enlarge it)


Step 3

Now lets create a new partition. The command for creating partition is
diskutil resizeVolume IDENTIFIER NEW_SIZE PERSONALITY NEW_DRIVE_NAME NEW_DRIVE_SIZE

I know it looks very complex. So I will give an example

Please refer to image 1 and 2 for details regarding the values used.


diskutil resizeVolume disk0s3 10.3G jhfsx Testing 10G

disk0s3 is the Identifier of the partition (refer Image 2)
10.3G would be the new size of the partition disk0s3
jhfsx means Case-sensitive Journaled HFS+ (refer Image 1)
Testing name of the new partition
10G size of the new partition

Another thing I realized is that creating partition from terminal takes almost half the time required to create partition using Disk Utility.

The different options available for format(Personality) are shown in Image 1.

NOTE :
Before using this technique to resize/create the partitions on your drive, make sure you’ve backed up everything. It’s all too easy to make a typo, and you can’t undo the command line!

Feel free to drop in your comments.

Advertisements

11 thoughts on “Partition using Terminal

    • Thanks man. Requirement is the mother of all inventions in this case innovation. To be honest it’s great coming from one of my first Macintosh mentors.

  1. Pingback: Building Eclair on Snow Leopard « Vishvesh's Blog

  2. Pingback: Building Froyo on Snow Leopard- Stepwise guide « Vishvesh's Blog

  3. Your post is very useful. Thank you so much for providing plenty of useful content.Thanks a lot for sharing these information. The post has also helped a lot. Look forward to your next post Your blog is very useful. Thank you so much for providing plenty of useful content. I have bookmark your blog site and will be without doubt coming back. Once again, I appreciate all your work and also providing a lot vital tricks for your readers.
    Thanks for the great idea you have post.

  4. Thanks a lot for the info, it’s really useful – but something really really useful (and something I need, and can’t find at the moment) would be: how to create a partition using terminal, not modify an existing one… 🙂

    So how about it, do you know how it’s done?

    • Thanks :).

      Step 3 in the post shows how to create a new partition.

      diskutil resizeVolume IDENTIFIER NEW_SIZE PERSONALITY NEW_DRIVE_NAME NEW_DRIVE_SIZE

      Please clarify if I have understood your requirement wrongly.

  5. Pingback: Partition Error for Mac PowerPC (Part 1) | MAC POWERPC 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s