Showing posts with label lossless. Show all posts
Showing posts with label lossless. Show all posts

Sunday, July 29, 2007

Lossless same-drive Mac HD Repartition, part 2

A while ago I explained how I did repartition my iMac hard drive. Then came WWDC, and with it I got the Leopard beta. Being in SF, without access to my iMac, I decided that I had to repartition my MacBook hard disk, so I could install Leopard and follow the sessions correctly.

Using my own post, I followed the different instructions. At repartition time, everytime I executed "diskutil resizeVolume ..." I got an error message about not having enough space. My MacBook's HD had been almost full, but I had freed 26Gb in order to make a new 20Gb partition. Clearly, it was not the disk space. It was also clear that my disk was probably highly fragmented and that diskutil was unable to allocate 20 contiguous gigabytes for my new partition.

I found an app called iDefrag. After some tests, I told it to defrag my drive with the default options. I took like 45 minutes to complete the whole process. I then retried the "diskutil resizeVolume ...". This time it worked perfectly.

Monday, June 04, 2007

LateNiteSoft at WWDC '07

I have started WWDC preparation. I have downloaded some of the headstarts, based on the sessions that interest me. Now, I have to install the latest Leopard preview in my laptop. For that, I need to go back to the repartition the hard drive once again. Lucky I did documented the first time!

I believe there are some very interesting technologies in Leopard. Core Animation being one of them. As I have been always interested in Special FX, game development and movie creation, it seems like a natural choice. So, once I get Leopard installed, along with the latest Xcode 3, I will take the material for Core Animation and try to grasp the basics before getting to San Francisco. I do have some ideas of things that would be nice to implement in Xslimmer, and even some ideas about possible new apps that we could create using Core Animation and other Leopard technologies. If I just had a more time...

Anyhow, I hope next week will be a fun one. I am really looking forward to meeting other Mac developers, whatever exciting news Steve Jobs provides us with, and all the possible learnings I can get.

If you are around, and would like to meet, let us know!

Monday, March 12, 2007

Lossless same-drive Mac HD Repartition

Recently I discovered a lossless way to repartition my Mac's main hard drive, without having to boot from an external drive. I have been looking for this for quite a while, as I wanted to install the Mac OS X Leopard preview in order to test the new development tools and maybe try a new feature or two for Xslimmer.



Some people had suggested to use the Bootcamp utility to resize and partition the drive. But I had already installed Windows (basically for gaming) and did not want to lose that partition.

So, I finally read an article on how to do this using the command line command diskutil, and its hidden feature named resizeVolume. If you check the man pages, you will see that there is no information on this matter, but you can obtain some executing "diskutil resizeVolume":

freeport:~ jorge$ diskutil resizeVolume
Disk Utility Tool
Usage: diskutil resizeVolume [Mount Point|Disk Identifier|Device Node] size
...
Non-destructively resize a disk. You may increase or decrease its size.
When decreasing size, you may optionally supply a list of new partitions to create.
Ownership of the affected disk is required.
Valid partition sizes are in the format of .
Valid sizes are B(ytes), K(ilobytes), M(egabytes), G(igabytes), T(erabytes)
Example: 10G (10 gigabytes), 4.23T (4.23 terabytes), 5M (5 megabytes)
resizeVolume is only supported on GPT media with a Journaled HFS+ filesystem.
A size of "limits" will print the range of valid values for the current filesystem.
Example: diskutil resizeVolume disk1s3 10G
JHFS+ HDX1 5G MS-DOS HDX2 5G
Valid filesystems: "Case-sensitive HFS+" "Journaled HFS+" "Case-sensitive Journaled HFS+" "HFS+" "HFS" "MS-DOS FAT32" "MS-DOS FAT16" "MS-DOS" "MS-DOS FAT12" "UFS" "Linux" "Swap"


So, as you can see, to resize a partition you first need to know its name. For that you can use "diskutil list":

freeport:~ jorge$ diskutil list
/dev/disk0
#: type name size identifier
0: GUID_partition_scheme *465.8 GB disk0
1: EFI 200.0 MB disk0s1
2: Apple_HFS Macintosh HD 434.0 GB disk0s2
3: Microsoft Basic Data WINDOWS HD 31.4 GB disk0s3


In my case, the partition was disk0s2. The partition scheme or the EFI partition should be ignored. As I said before, I already had a Mac OS partition and the Bootcamp partition. I wanted to create a new 20 Gb partition out of the main Mac OS partition, disk0s2.

Now, there are some limitations to the resizing. I guess it has to do with how much free space you have in the partition you want to divide. To verify the limitation, you use "diskutil resizeVolume partition_name limits":

freeport:~ jorge$ diskutil resizeVolume disk0s2 limits
For device disk0s2 Macintosh HD:
Current size: 466003951616 bytes
Minimum size: 213448208384 bytes
Maximum size: 466003951616 bytes


Finally, you have to provide the resizing parameters to the "diskutil resizeVolume" command. In my case, I wanted to keep 414Gb for the main partition and create a new Journaled HFS+ with 20Gb:

freeport:~ jorge$ diskutil resizeVolume disk0s2 414G JHFS+ Leopard 20G
Started resizing on disk disk0s2 Macintosh HD
Verifying
Resizing Volume
Adjusting Partitions

Finished resizing on disk disk0s2 Macintosh HD
You will need to manually reformat your new partitions.
WARNING: You must now reboot!


In my case the first step, "Verifying" was what took the longest time. After that it all went very fast.

Once done, you should reboot. After rebooting, you can use diskutil or Disk Utility to prepare that new partition for use.

freeport:~ jorge$ diskutil list
/dev/disk0
#: type name size identifier
0: GUID_partition_scheme *465.8 GB disk0
1: EFI 200.0 MB disk0s1
2: Apple_HFS Macintosh HD 414.0 GB disk0s2
3: Apple_HFS 19.9 GB disk0s3
4: Microsoft Basic Data WINDOWS HD 31.4 GB disk0s4


In my case, I used Disk Utility, selecting the new partition, the Erase tab, then proving a name for the partition, and clicking on the Erase button.

freeport:~ jorge$ diskutil list
/dev/disk0
#: type name size identifier
0: GUID_partition_scheme *465.8 GB disk0
1: EFI 200.0 MB disk0s1
2: Apple_HFS Macintosh HD 414.0 GB disk0s2
3: Apple_HFS Leopard HD 19.9 GB disk0s3
4: Microsoft Basic Data WINDOWS HD 31.4 GB disk0s4

(Update) One more thing needs to be done. This time is for Windows to keep running fine. You should edit boot.ini (I used textmate), so it knows the partition is it located in. Mine looked like this:

[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(3)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(3)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect
As you see, it says partition(3) for the Windows partition, which is now wrong. I changed it to partition(4) and it worked like a charm. Notice partition(3) appears twice, you should change both.

All set!

Now I have Leopard on my Mac along with Tiger and Windows, thanks to these simple operations. Needless to say, before you attempt to do anything like this, you should have a backup.

[Update: I wrote a second part of this article]

Disclaimer: Visitors do assume all the risk of viewing, reading, using, or relying upon this information. We assume no responsibility for damage to computers or software of the visitor or any person the visitor subsequently communicates this information to.

Have fun!