Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Recover some hard drive space via pdisk UNIX
Apple's Disk Utility wastes 128 MB of hard drive space for every partition it creates. On my PowerBook with a 40GB disk and three partitions (system, user, swap), this corresponds to about 1% of wasted space, or 384 MB. This is output from pdisk for that disk:
/dev/rdisk0  map block size=512
   #:                 type name                 length   base       ( size )
   1:  Apple_partition_map Apple                    63 @ 1       
   2:           Apple_Free                           0+@ 64      
   3:            Apple_HFS Apple_HFS_Untitled_2  9961472 @ 262208   (  4.8G)
   4:           Apple_Free                           0+@ 10223680
   5:            Apple_HFS Apple_HFS_Untitled_3  4225792 @ 10485824 (  2.0G)
   6:           Apple_Free                           0+@ 14711616
   7:            Apple_HFS Apple_HFS_Untitled_4 63166384 @ 14973760 ( 30.1G)
   8:           Apple_Free                           0+@ 78140144
Your output might look slightly different; for no appearant reason my two PowerBook's pdisk output varies a little. These Apple_Free parts are completely unnecessary and can be removed. I won't tell exactly how to repartition your drive, because if you can't figure out that yourself, you probably shouldn't do it, but I will give some hints on the way...

Here are a few things to keep in mind...
  1. You have to boot into single user mode (Command-S), otherwise you will get an error message stating "The map is not writeable."
  2. It is not until you do [w]rite that the partition table something actually changes. Until then, you can quit at any moment without risk.
  3. Let the first partition remain untouched:
      1: Apple_partition_map Apple                 63 @ 1
    Also, save 16 blocks (i.e. 8KB) at the end of the partition table:
      5:          Apple_Free Extra                 16 @ 78140144
    I don't know what the last 16 blocks are for, but they have been there since I used pdisk for the first time on my 9600 back in 1997.
  4. Just use the base of the Apple_Free section as start point for the next partition onwards.
Caution: If you have no means for backup, you shouldn't try this hint. With that said, you can split one partiton into two (or more) without losing your data, if you first defragment the partition and put all data at the beginning of the partition. You can also merge two partitions and keep the data on the first partition (the data of the second partition will disappear).

[robg adds: Please note that the instructions for doing this step-by-step are not provided here on purpose -- I've not used pisk before, and I'm not going to experiment through testing of this hint. The details here are for those who already understand pdisk and wish to use it to recover some free space.]
    •    
  • Currently 3.50 / 5
  You rated: 4 / 5 (4 votes cast)
 
[17,981 views]  

Recover some hard drive space via pdisk | 41 comments | Create New Account
Click here to return to the 'Recover some hard drive space via pdisk' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Don't partition MacOX drives. No need to.
Authored by: Chas on May 29, '05 11:01:44AM

There is absolutely no reason to partition a single hard drive so it has a separate swap partition. A separate swap partition is thought to increase performance, but that only works when the swap is on a separate drive. There really isn't any reason to have separate System and user partitions.
MacOS X is designed to work on huge disk volumes, the volume structure is self-optimizing, and is designed for good performance even when fragmented.

Multiple partitions on a drive is an anachronism from the days of MacOS 9. Get over it. Your partition scheme wastes more disk space than this tip reclaims.



[ Reply to This | # ]
what about minimum block size?
Authored by: schaps on May 29, '05 11:18:42AM

My reasons for partitioning before was the minimum block size-- partitioning created smaller blocks. I would think with all the thousands of itsy bitsy files that *nix based OSes have, this would still be a reason to partition. You seem rather worked up about this, so please note I am not challenging you, I am attempting to improve my knowledge. Please let me know what you think.



[ Reply to This | # ]
what about minimum block size?
Authored by: derrickbass on May 29, '05 10:28:28PM

The minimum block size is 4K on HFS+ disks (well, it can be chosen differently when you format the disk, but I've never seen that happen). In the days of HFS, you could only have a maximum of 65536 blocks on a disk, so the bigger the disk, the bigger the block size. But no such limitation is present on HFS+ disks.



[ Reply to This | # ]
what about minimum block size?
Authored by: schaps on May 30, '05 12:05:17AM

thanks-- did not know that!



[ Reply to This | # ]
what about minimum block size?
Authored by: axello on May 30, '05 03:08:23AM

Actually, there is a limit to the number of files on an HFS+ disk. It is 2^32, so around 4.29 billion.
The biggest volume you can access with 4 KB blocks is thus 16 TB. We should approach that in a couple of years.



[ Reply to This | # ]
Don't partition MacOX drives. No need to.
Authored by: david-bo on May 29, '05 11:48:30AM

A separate swap-partition reduces the fragmentation in the system and user parts of the disk. Yes, I know that Mac OS X automatically defragments some files nowadays.

Furthermore, with a separate swap-partition you never risk that a process that has gone crazy fills up the disk so no more swap can be used; it will fill the disk but only the system and/or user-part(ition), at least if you are so disciplined that you never store any documents, applications etc on the swap.

Finally, you can fit a swap-partition to just accomodate the swap files, i.e. if you never user more than, e.g., 4 swap files (64, 64, 128 and 256 MB), you can make the swap 513 MB and you optimize the space usage in the disk. If you just leave the swap on the boot partition, you always have to make sure that the free space is in the order 2^n bytes, if you have 2^1-1 the last swap file can't be created.

Anyway, this hint was not about the existence swap-partitions or not, but rather a hint on how you could save some space on a crowded disk.

---
http://www.google.com/search?as_q=%22Authored+by%3A+david-bo%22&num=10&hl=en&ie=ISO-8859-1&btnG=



[ Reply to This | # ]
Don't partition MacOX drives. No need to.
Authored by: chucky23 on May 29, '05 11:52:44AM
"There really isn't any reason to have separate System and user partitions."

That's a pretty ignorant thing to say.

You may choose to go with a single partition, but if you had any clue about using OS X, you would know that there are many good reasons for having multiple partitions. And separating the system from user partitions is one of those good reasons.

[ Reply to This | # ]

Don't partition MacOX drives. No need to.
Authored by: deleted_user18 on May 30, '05 02:47:56AM

So then you should mention the good reasons. Why should I seperate user data from "the rest"? This is already done. It is called home directory...

And by forcing the swap file to use a specific area of your hard drive you lose the ability of OS X to move often accessed files to the hot area (fastest tracks on your hard drive) automatically.

It the same waste of time as defrag.exe is on Windows XP.



[ Reply to This | # ]
Don't partition MacOX drives. No need to.
Authored by: chucky23 on May 30, '05 10:17:57AM
"So then you should mention the good reasons. Why should I seperate user data from "the rest"? This is already done. It is called home directory..."

There are multiple reasons.

- Avoiding the swap generated disk full errors that frequently destroy user prefs and data.

- Much easier re-installations.

- Data protection in event of serious disk structure problems.

And those are three of only the most obvious reasons. More valid reasons do exist. I always have a minimum of two partitions, even if I'm not doing anything fancy.

"And by forcing the swap file to use a specific area of your hard drive you lose the ability of OS X to move often accessed files to the hot area (fastest tracks on your hard drive) automatically."

Only semi-true. If your swap file partition is over 10GB, you get the exact same hot-file capability. And given the naturally defragmented nature of swap disks, it's not much of a problem to begin with.

But I personally don't give swap its own partition. From my point of view, it's too little or no gain for much too much work, and should only be done for educational purposes.

But separating /System from /Users seems like an absolute no-brainer to me.

[ Reply to This | # ]

Don't partition MacOX drives. No need to.
Authored by: greed on May 30, '05 11:25:49AM

Aside from all the other reasons people have put forth for and against partitions, how about this:

If you want to use multiple partitions, do it. It works well under Mac OS X. And if you have multiple drives that you haven't RAIDed together, you've got multiple partitions anyway--even if you don't have multiples on each drive.

If you don't want to use multiple partitions, don't do it. It works well under Mac OS X; user data is under /User, system under /System, /usr, /var, and so on; and global non-user stuff is under everything else.

But why try to convice others your way is best? Your way is good for you, my way is good for me, his way is good for him, and her way is good for her. A little discussion is great, but blanket statements like "Don't partition you don't need to" don't really help. I don't need to do lots of things; if we got right down to it, I wouldn't have a Mac if I went on "need". I'd have an ANSI TTY and a 9600 BPS modem to a dusty UNIX machine somewhere.



[ Reply to This | # ]
Don't partition MacOX drives. No need to.
Authored by: JohnnyMnemonic on May 29, '05 05:07:10PM

Multiple partitions on a drive is an anachronism from the days of MacOS 9.

It is not totally without reason. I have several partitions on my drive; one for beta or in testing OSes; one for Linux; one master "working" OS and data; and one with an image for CCC to copy to client machines. I could put them all but the master on a FW hard drive(s), but I prefer to have them all with me wherever I have my powerbook for use as the mood or need strikes me.

However, I do have a question: I have heard that Apple's hot-file-adaptive technology and prebinding stuff only works on a drive with one (user-created) partition. Has this changed in 10.3 or .4, or is there an actual penalty for using more than one partition?



[ Reply to This | # ]

Don't partition MacOX drives. No need to.
Authored by: chucky23 on May 29, '05 07:12:54PM
"I have heard that Apple's hot-file-adaptive technology and prebinding stuff only works on a drive with one (user-created) partition."

Untrue.

The hot-file-adaptive technology kicks in on any partition larger than 10GB. So if you partition your drive with partitions smaller than that, you'll lose hot-files. Otherwise, not.

[ Reply to This | # ]

Don't partition MacOX drives. No need to.
Authored by: rhowell on May 29, '05 06:17:13PM

In addition to the posts above, here's another reason. Placing your iTunes, iPhoto, iCal, Address Book, Bookmarks, etc, etc, whatever you want, on a separate partition that has ownerships turned off has many benefits. This is the easiest way to share these libraries among multiple users (like an entire trusting family) on your computer. And no, "sharing" them via their respective Preferences does not accomplish the same thing. Everyone should be able to change the libraries.

Great for sharing documents, too.



[ Reply to This | # ]
Don't partition MacOX drives. No need to.
Authored by: Anonymous on Jun 02, '05 03:20:05PM

The only reason I split up my main disk into two partitions last clean reinstall was that booting to OS 9 was killing my system, forcing me to fsck constantly. No matter what I did, the simple act of booting to OS 9 would often hose my main disk, causing the dreaded "?" on boot.

I put OS 9 on a separate 10Mb partition and now if it goes pear-shaped I can just blow it away and reinstall -- without afffecting OS X at all.

Regardless of _why_ this was happening, having the two systems on different logical disks means I can count on my important system (OS X) booting. I just don't care if OS 9 blows up. I do care if it takes my only boot disk with it.



[ Reply to This | # ]
Don't partition MacOX drives. No need to.
Authored by: jesboat on Jun 20, '05 04:00:00PM
I have three seperate partitions on my system— one for the system, one for my data (symlinked to /Users), and one for my media (symlinked to ~/Movies, ~/Music, etc.)— because:
  • It allows me to fiddle with different settings for different partitions (e.g. make some case-sensitive, which I do need sometimes)
  • It allows me to wipe certain partitions and not others during re-install. When Apple releases a new major version of OS X, I can just wipe my system partition, getting rid of all the crap I've built up, and re-install the new version over it.
  • Backups are much easier. I don't have to worry about backing up my System partition, though I like to so it's easy to restore the OS should things die. I need to back up my User partition frequently, but, since it's small (1 GB), I can fit backups on my server and USB flash drive. Media needs to be backed up very infrequently, and can safely use incremental backups. (Safely, as in without me being paranoid the incremental backups will mess something important up.)
Jesboat

---
--
With no walls or fences on the 'net, who needs Windows or Gates?

[ Reply to This | # ]

Recover some hard drive space via pdisk
Authored by: rspress on May 29, '05 02:58:52PM

The original poster is incorrect, Apple disk utility is creating these "Apple Free" spaces for a reason. They are used for various purposes for the partition you just created. When you partition a disk under windows it will require you to save at least 8 MB per partition for that partitions use. It might be argued that 128MB per partition may be a little on the high side but since Apple sets this default value in Disk Utility I would feel safer leaving it alone.



[ Reply to This | # ]
Recover some hard drive space via pdisk
Authored by: chucky23 on May 29, '05 07:15:43PM
"The original poster is incorrect, Apple disk utility is creating these "Apple Free" spaces for a reason. They are used for various purposes..."

Care to enlighten the discussion with what those "various purposes" might be? Or why you think getting rid of those spaces will be harmful?

[ Reply to This | # ]

Recover some hard drive space via pdisk
Authored by: Shawn Parr on May 29, '05 11:00:18PM

Er, no.

The Windows partitioner (as of XP) will force you to save 8MB unallocated per disk, no matter how many partitions are desired.

8MB per physical disk, not 8MB per partition.

With Linux and/or Partition Magic you can create a partition setup without losing this 8MB.

I believe Microsoft is making space for an extended bootloader functionality that doesn't exist yet.



[ Reply to This | # ]
Recover some hard drive space via pdisk
Authored by: jsuen on May 31, '05 01:32:22PM

The extra 8 MB are used if you convert the disk into a dynamic disk. This is exactly why you should leave Apple's extra space alone: for future use.



[ Reply to This | # ]
Why would somebody make different partitions anyway?
Authored by: deleted_user18 on May 30, '05 02:45:18AM

What is the point in making different partition for data and software? Isn't this why we have /Users?



[ Reply to This | # ]
Why would somebody make different partitions anyway?
Authored by: gvitale on May 30, '05 03:14:34AM

If you have /Users on a different partition you can happily reformat the Root partition without loosing your personal data; say for instance that you want to reinstal the System for Tiger upgrade: this can be cleanly done by reformating the Root partition and doing a fresh install: you can later on rescue ALL your user(s) data just by soft linking /otherpartition/Users with /Users.



[ Reply to This | # ]
Why would somebody make different partitions anyway?
Authored by: madamimadam on May 30, '05 06:34:37AM

Could just use archive and install

If the need somehow arose, you could always format and recreate your home folder from your back up.



[ Reply to This | # ]
Why would somebody make different partitions anyway?
Authored by: gvitale on May 30, '05 07:02:29AM

Archive and instal is not clean instal.
If the backup strategy is good for you, go for it, but having an untouched partition with all your data is way easier...



[ Reply to This | # ]
Why would somebody make different partitions anyway?
Authored by: madamimadam on May 31, '05 07:08:05AM

How can you say "way" easier when you have to do the clean install, re-link the "old" home folders to the new OS and then delete the new home folders when you could just start a copy back onto the drive and grab a cup of coffee or start work again straight away?

Yeah... WWWAAAAYYYY easier



[ Reply to This | # ]
Why would somebody make different partitions anyway?
Authored by: gvitale on May 31, '05 07:16:15AM

You just don't want to get the point: fine with me



[ Reply to This | # ]
Why would somebody make different partitions anyway?
Authored by: jesboat on Jun 20, '05 04:06:16PM

I think the point wasn't that you had to restore from backups with a clean install, restore of /Users, etc. but that you could clean install if you wanted. I find the separation useful when I want to do a new install (typically with new major versions of OS X). Then, I can wipe my system partition, clean install the new OS on it, create my account, symlink /Volumes/Users to /Users, and be done with it.

The advantage for backups (again, IMO) is that you can backup different partitions using different methods. For example, for me, /Volumes/Users is small (1 GB), so I can back it up very regularly to my USB flash drive. I can back up / less often, because I know I don't have any critical data on it, and /Volumes/Media, my last partition (symlinked to ~/Movies, ~/Music, etc.) I can back up very infrequently, because it doesn't change often.

Jesboat


---
--
With no walls or fences on the 'net, who needs Windows or Gates?



[ Reply to This | # ]
Why would somebody make different partitions anyway?
Authored by: tim-wood-MacOSXH on May 30, '05 11:54:38PM

A few years back, I had to salvage a webserver that died. It turned out that a blackout had outlasted the powerbackup, crashing the server, when an automatic update was happening, completely corrupting the entire partition. It would no longer boot. And the corruption was not fixable. And the backup hadn't been functioning properly. And it was a production webserver for about a dozen domains. Gulp. But, when I set up the server, I had partitioned the drive. The data (the websites, the email, the databases, etc) was on two partitions that did not hold any programs or the OS. I backed up the data, installed a new drive, reinstalled stuff, copied the data back and everything was back online. Painful, but partitioning was the extra little bit of insurance that saved the day.



[ Reply to This | # ]
Why would somebody make different partitions anyway?
Authored by: deleted_user18 on May 31, '05 09:38:58AM

The black out could also easily hit your data partition. You just had luck.

You need a proper backup strategy. A backup partition which just is backuped to is no backup. What happend to you can happen evertime, the computer dies while the backup is made and you have two corrupted copies of your files. Because of this you should make different backups.



[ Reply to This | # ]
Why would somebody make different partitions anyway?
Authored by: jesboat on Jun 20, '05 04:09:05PM

Certainly, his data partition could have been wiped too, but with his strategy, there's also the potential for it to be OK. The point isn't to forgo backups and proper protection because "my separate-partitions-ness will save me", but that, should everything else fail, there's one more hope.

Jesboat

---
--
With no walls or fences on the 'net, who needs Windows or Gates?



[ Reply to This | # ]
Recover some hard drive space via pdisk
Authored by: deleted_user18 on May 30, '05 08:24:29AM

How often do your format your sytem poartition? I did this only once in four years.

There are still dependancies between your system and your /Users directory! Only in a perfect world /Users is totally independent from the rest of the system. In other words, formatting your system partition and mounting your old /Users will give you propably some strange errors (and the you want to format your system partion again...).



[ Reply to This | # ]
Recover some hard drive space via pdisk
Authored by: gvitale on May 30, '05 08:40:51AM

Not true, sorry...
I have moved my home directory to a separate partition back in 10.1 and I had no troubles installing 10.2, 10,3 and 10.4 (not the one yo are referring anyways...)



[ Reply to This | # ]
Recover some hard drive space via pdisk
Authored by: deleted_user18 on May 30, '05 10:28:11AM

In your home folder is at least your ~/Library/Preferences/ folder. Files in there have settings depending of the software version and your system configuration. For example: A software stores the screen position of your software, on a different Mac you have a smaller resolution. It now depends on the application if it can deal with the situation and switch to standard window postions or just crash... Yo get the picture?



[ Reply to This | # ]
Recover some hard drive space via pdisk
Authored by: greed on May 30, '05 11:17:47AM

...and well-formed applications will put their system-specific preferences in ~/Library/Preferences/ByHost.

The filename convention is the same as for regular preferences, but the en0 MAC address is placed before the ".plist" in the name, like so:

com.apple.windowserver.000d93b2112c.plist

As a frequent-iBook-Logic-Board-Replacer, I've gotten really good at swapping the files around when en0 gets a new MAC every 3 or 4 months.



[ Reply to This | # ]
Recover some hard drive space via pdisk
Authored by: deleted_user18 on May 30, '05 04:30:14PM

Oh thanks for the information. This is new to me, I always wondered what ByHost directories meant. So in theory there is a way to do a clean swap.



[ Reply to This | # ]
Recover some hard drive space via pdisk
Authored by: gvitale on May 31, '05 04:18:20AM

You're happy now?



[ Reply to This | # ]
Recover some hard drive space via pdisk
Authored by: chucky23 on May 30, '05 10:26:12AM

Yup. It's quite easy. We're talking about a single symbolic link.



[ Reply to This | # ]
Recover some hard drive space via pdisk
Authored by: jesboat on Jun 20, '05 04:13:39PM

Wow, you and gvitale are really arguing here. (I say as I throw in my $0.02, oh well.)

I reformat my system partition with every major OS X release, and maybe once in between. I've never encountered a problem with my ~ being grumpy between installations [1].

[1] I've only tried going from an older version of OS X to the same version or a newer version, which means it makes sense I've never had any problems: my ~ just follows the standard upgrade path for preferences and such.

Jesboat

---
--
With no walls or fences on the 'net, who needs Windows or Gates?



[ Reply to This | # ]
um, bad idea?
Authored by: Krioni on May 31, '05 01:33:19PM

I may be wrong, IANADTE (I Am Not A Disk Technology Export), but I thought that the AppleFree zones were so that if sectors of the disk went bad, the disk could use space from that zone to keep the available disk volume the same. I think that if you delete those and get bad sectors you can lose data.

Anyone actually know more about this? The original poster sounds like he's guessing that they aren't needed.



[ Reply to This | # ]
Don't partition MacOX drives. No need to.
Authored by: david-bo on Jun 25, '05 11:44:45AM

A separate swap-partition reduces the fragmentation in the system and user parts of the disk. Yes, I know that Mac OS X automatically defragments some files nowadays.

Furthermore, with a separate swap-partition you never risk that a process that has gone crazy fills up the disk so no more swap can be used; it will fill the disk but only the system and/or user-part(ition), at least if you are so disciplined that you never store any documents, applications etc on the swap.

Finally, you can fit a swap-partition to just accomodate the swap files, i.e. if you never user more than, e.g., 4 swap files (64, 64, 128 and 256 MB), you can make the swap 513 MB and you optimize the space usage in the disk. If you just leave the swap on the boot partition, you always have to make sure that the free space is in the order 2^n bytes, if you have 2^1-1 the last swap file can't be created.

Anyway, this hint was not about the existence swap-partitions or not, but rather a hint on how you could save some space on a crowded disk.

---
http://www.google.com/search?as_q=%22Authored+by%3A+david-bo%22&num=10&hl=en&ie=ISO-8859-1&btnG=



[ Reply to This | # ]
um, bad idea?
Authored by: david-bo on Jun 25, '05 11:53:33AM

It does not work like that. When a sector goes bad it is marked in the file allocation table (FAT) as "don't use". The FAT is stored in a part of the disk you can't access with normal formatting tools, including pdisk.

---
http://www.google.com/search?as_q=%22Authored+by%3A+david-bo%22&num=10&hl=en&ie=ISO-8859-1&btnG=



[ Reply to This | # ]
Recover some hard drive space via pdisk
Authored by: david-bo on Jun 25, '05 11:50:23AM

I just got a new 2,5" disk which I put in an exernal FW-case and formatted with Disk Utility.

This disk did not waste a lot of space on Apple Free areas, its partition table:

/dev/rdisk1 map block size=512
#: type name length base ( size )
1: Apple_partition_map Apple 63 @ 1
2: Apple_HFS Apple_HFS_Untitled_4 8408488 @ 64 ( 4.0G)
3: Apple_HFS Apple_HFS_Untitled_5 22020096 @ 8408552 ( 10.5G)
4: Apple_HFS Apple_HFS_Untitled_6 125872840 @ 30428648 ( 60.0G)


No idea why Disk Utility gives different results from time to time but Apple Free seems unnecessary if Disk Utility itselfs not always creates it.

---
http://www.google.com/search?as_q=%22Authored+by%3A+david-bo%22&num=10&hl=en&ie=ISO-8859-1&btnG=



[ Reply to This | # ]