2011-01-17

On Megabytes and Mebibytes

Ever since I was a young kid, I was confused by how sometimes, a megabyte was 1000000 bytes and sometimes something different. This confusion still gets me to this day, and it's because there's no consistency.
The webcomic xkcd has a great take on it regarding the smaller unit kilobyte. For the unit "megabyte", the problem is compounded by the extra multiplication possibility: megabyte can not only be either 1000^2 or 1024^2 bytes, but it can also be 1024*1000 bytes.
Yesterday, that issue came back to bite me. I was creating a new partition on my flash drive to make a Linux Mint 10 "Julia" GNOME live USB system. The ISO file is under 850 MB (whatever "MB" means), so I created a partition that's 900 MiB (a MiB is bigger than an MB, as far as I know) to be safe. I started UnetBootin and started writing the ISO to the partition, then got an error saying the partition has run out of room.
Now, it may be entirely possible that an ISO file takes up a lot more room when written to a USB stick partition as opposed to a CD/DVD, though I'd be surprised if it took up that much more room. But I have a feeling it's because of the inconsistent use of MB in GParted vs. Nautilus. Come on, can we please have some consistency?

8 comments:

  1. how did you create your 900MiB partition and did you put a filesystem on it?
    Firstly you probably didn't actually get a 900MiB partition because most tools by default end up rounding to "cylinders" and giving you a bit less.
    Most linux filesystems by default are set up to reserve 5% of space for the root user - so that makes available space 855MiB as a user.

    depending what sort of jiggery-pokery is used to make the iso into a bootable USB a couple of MiB may not be enough room for manoeuvre. It could even be something as simple as a script expecting a partition size of 1GiB or greater and just not completing.

    ReplyDelete
  2. @T_Beermonster: I used GParted to create a 900 MiB EXT3 filesystem on my flash drive (upon which I did not install any OS). Also, if it makes a difference, UnetBootin didn't complain when I put a ~700 MB SimplyMEPIS ISO file in an ~850 MB partition. Thanks for the comment!

    ReplyDelete
  3. You could try using tune2fs to get rid of the 5% reservation of space - the partition is effectively going to be used as read-only anyway.
    tune2fs -m 0 /dev/sdg1
    replace sdg with your usb device and use su or sudo as you prefer.
    That will give you an extra 45MiB to play with on a 900MiB partition. Which may be just enough - I should really go and look at the sizes of the mint iso's.

    I doubt the journal is taking up much room but you may want to consider going for an unjournaled fs on that partition given the read-only nature.

    The tune2fs trick is worth remembering in general anyway, particularly if you have a separate / and /home. /home doesn't need to reserve any space for the superuser and 5% of a 1TiB partition is 51.2GiB that would otherwise be sitting unavailable.

    ReplyDelete
  4. @T_Beermonster: Wow, I've been wondering for a while why empty partitions were taking up significant amounts of space on their own. Now I know why and what to do. Thanks for the tip!

    ReplyDelete
  5. Hi Prashanth,

    Can you give me your email address? I couldn't find any contact info about you.

    Sorry for the unrelated comment.

    ReplyDelete
  6. @Jun: I'd rather not put my email address out there in public; what I'll do instead is go to your site and fill out a contact form. How does that sound?

    ReplyDelete
  7. @PV

    That would be fine. I'll be waiting for your email. Thanks :)

    ReplyDelete
  8. @Jun: If you don't mind responding, what exactly would you need it for?

    ReplyDelete