I recently installed Ubuntu in my computer, which I was crazily looking forward to as this was my first big step in installing an open source OS by myself. So I created a 20Gb partition for Ubuntu and installed it via USB. After installing and setting up Ubuntu, I found that the Ubuntu partition was reduced by approx. 4Gb (it was 16.49 Gb). Now I am panicking whether that some of the partition cannot be recovered if I decide to remove Ubuntu and still won't get it back even when I delete the partition. Can you please help me?
On installing with the defaults Ubuntu will have created at least two partitions:
- The root partition to hold Ubuntu and your data.
- A swap partition to extend your virtual memory in case it was needed.
The Swap partition will not be accessible from your desktop but you can see and list all of your partitions from a terminal with
sudo fdisk -l
or from the "Disks" utility (search the Dash for it):
The size of the Swap partition (on my disk 10 GB) depends on the amount of RAM in your computer and will roughly equal it.
Therefore it seems very likely that the 4 GB you can't see is just this Swap partition.
On removing Ubuntu (or other Linux distributions) you will also have to manually remove this swap partition.
Takkat's answer is almost certainly the correct one, or at least it's probably the bulk of the correct answer. There might be something else going on in addition to what Takkat wrote, though, which might be a small part of the answer.
Disk, partition, and filesystem sizes have long been measured in two ways:
- Using SI units -- power-of-10 multiples of bytes (B) or bits (b), as in kilobytes (kB, 1,000 bytes), gigabytes (GB, 1,000,000,000 bytes), or megabits per second (Mb/s, 1,000,000 bits per second).
- Using IEEE 1541 units -- power-of-2 multiples of bytes (B) or bits (b), as in kibibytes (KiB, 1024 bytes) or gibibytes (GiB, 1,073,741,824 bytes).
The IEEE 1541 units are relatively new. In the past, SI prefixes were applied to both power-of-10 and power-of-2 units, with rounding occurring to get similar values -- for instance, "kilo" was applied to multiples of 1024. This was inaccurate when applied to power-of-2 units, but the difference was small. At the kilobyte scale (as for instance when measuring the capacity of 5.25-inch floppy disks), the difference is only 2.4%. The difference between an SI terabyte and an IEEE 1541 tebibyte, however, is almost 10%. Disk manufacturers tended to stick to the canonical SI meanings of the prefixes, probably because it made their disks sound a little bigger than they were, given that most everybody else used the power-of-2 meanings.
Today, people unfamiliar with these distinctions can become confused when they see that their 4TB hard disk shows up in a disk utility as having just 3.6TiB of space. Both figures describe the same capacity, though.
In your case, the difference between a GB and a GiB is nowhere near enough to explain the difference you see. That's why I say that this distinction might be just a small amount of the effect, and Takkat's answer is probably the bulk of what's happening.
As a side note, please notice that I described an uppercase "B" as the abbreviation for byte and a lowercase "b" as the abbreviation for bit. In most contexts, a byte is 8 bits, so a 20Gb partition is really just 2.5GB. In the context of your question, your intended meaning (GB or GiB, not Gb) is clear, but that might not be the case in some situations. Data transfer rates are often expressed in (multiples of) bits per second, which can lead you to very wrong conclusions if you mis-read the abbreviation!
As a second side note, although a lot of programs and manufacturers are now taking greater care to distinguish between SI and IEEE 1541 units for disk capacities, RAM is still often being mis-measured using SI prefixes to refer to IEEE 1541 units. This is worth noting so that you don't misjudge something.