Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to figure out how the paritioning works, so I'll know which partition I can format or create for data, and which I should format to reinstall linux.

Using "df -hT" I got this:

Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/sda2     ext3     15G  4.4G  9.1G  33% /
/dev/sda1     ext3    996M   40M  905M   5% /boot
tmpfs        tmpfs    2.0G     0  2.0G   0% /dev/shm

I want to create a new partition. Where is the disk memory taken from? An existing partition? Or from memory that isn't partitioned and don't appear in this list?

Another question related - is the default partition I am using at "/" ? and where is the installation directory of linux located?

share|improve this question

migrated from stackoverflow.com Dec 18 '12 at 9:00

This question came from our site for professional and enthusiast programmers.

2 Answers 2

up vote 1 down vote accepted

I want to create a new partition. Where is the disk memory taken from? An existing partition? Or from memory that isn't partitioned and don't appear in this list?

It's taken from unpartitioned space, which is not shown in df because the command only shows currently active (mounted) filesystems. If you want to see low-level partition details, install GParted.

GParted

Alternatively, try the following commands:

sudo parted /dev/sda print free

sudo fdisk -l /dev/sda

sudo gdisk -l /dev/sda

When you partition a disk, the partitions are created exactly as large as you tell them to be. They do not automatically grow to occupy the entire disk; instead, unused space remains just like that: unallocated.

For example, if you have a 1 TB disk, and create two 500 GB and 300 GB partitions, they will only occupy 800 GB together; the disk will still have 200 GB left "unallocated" and not used by the operating system.

┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│                        Unallocated                        │
└───────────────────────────────────────────────────────────┘
╔═════╤═════╤═════╤═════╤═════╗─────┬─────┬─────┬─────┬─────┐
║         Partition 1         ║         Unallocated         │
╚═════════════════════════════╝─────────────────────────────┘
╔═════╤═════╤═════╤═════╤═════╤═════╤═════╤═════╗─────┬─────┐
║         Partition 1         │   Partition 2   ║Unallocated│
╚═════════════════════════════╧═════════════════╝───────────┘

If you want to create a third partition (let's say 100 GB), it will take from the unallocated space.

╔═════╤═════╤═════╤═════╤═════╤═════╤═════╤═════╤═════╗─────┐
║         Partition 1         │   Partition 2   │Part3║Unall│
╚═════════════════════════════╧═════════════════╧═════╝─────┘

Some tools (such as GParted) allow filesystems inside the partitions to be resized, so if you decide you need a larger partition than the unallocated space you have, you can take from the existing partitions:

╔═════╤═════╤═════╤═════╤═════╤═════╤═════╤═════╤═════╤═════╗
║      Partition 1      │Partition 2│      Partition 3      ║
╚═══════════════════════╧═══════════╧═══════════════════════╝

Sometimes it gets more complicated – the unallocated space is not always at the end, for example, if you delete a partition from the middle, it becomes necessary to move a partition somewhere else:

╔═════╤═════╤═════╤═════╤═════╗─────┬─────┬─────╔═════╗─────┐
║         Partition 1         ║   Unallocated   ║Part2║Unall│
╚═════════════════════════════╝─────────────────╚═════╝─────┘
╔═════╤═════╤═════╤═════╤═════╤═════╗─────┬─────┬─────┬─────┐
║         Partition 1         │Part2║      Unallocated      │
╚═════════════════════════════╧═════╝───────────────────────┘

Another question related - is the default partition I am using at "/" ? and where is the installation directory of linux located?

Depends on what you mean by "default". / is where most of the system is kept. (But some people keep /usr or /var in separate partitions from /; others have a single partition for the entire system. Linux doesn't care too much.)

There is no single "installation directory – almost all directories under / contain various parts of the system. Typically /etc contains system configuration; /usr – programs, libraries, and various read-only program data; /var – variable data such as mail, websites (on a web server), databases (MySQL), downloaded packages (apt-get), and such – not all of them can be considered part of the OS.

In your case – yes, / contains both the operating system and your own files. The only exception is /boot which contains the Linux kernel itself and – in your system – has a dedicated partition.

share|improve this answer

I'm not sure exactly what you are asking, but I'll explain Linux partitions to you.

First of all, "/" is the main partition, in that the operating system, and sometimes your files lie.

Next, you have "/home" (optional) which is all of your files.

Lastly (that I can remember), you can have "/var", which stores all your system variables and other files.

Also, (kind of different), you can have a swap partition, which is virtual RAM (good for an SSD)

Although these are the main folders you will mount separately, you can do this to any folder you want.

share|improve this answer
    
Thanks. So if "/" is where linux is installed, what is "/boot" for? It's a seperate partition.. Also - do you know where the memory for a new partition is taken from? an existing one, or something like "unpartitioned" space ? –  GilM Dec 18 '12 at 1:32
    
@GilM: Some systems use a more complex setup than ordinary partitions – / could be encrypted, on a LVM volume, using Btrfs or ZFS, and so on. The bootloader has to be fairly small and only supports very basic file system features, so often, only Linux itself knows how to access its own / on such systems. In this case, the Linux kernel and the initramfs are stored in /boot, and the initramfs contains the tools necessary to access the main filesystem /. –  grawity Dec 18 '12 at 9:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.