Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Other Community Discussions > Tutorials & Tips
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Tutorials & Tips
The place to find Ubuntu related Tips & Tricks.

 
Thread Tools Display Modes
Old October 22nd, 2006   #1
bodhi.zazen
Ubuntu Guru
 
bodhi.zazen's Avatar
 
Join Date: Apr 2006
Location: Montana
My beans are hidden!
Xubuntu Development Release
Send a message via Yahoo to bodhi.zazen
Thumbs down HowTo: Partitioning Basics

Partitioning basics

bodhi.zazen

This is a brief guide on partitioning intended as a brief introduction to partitioning terminology and some tips.

UPDATE 11/30/06 Thank you ImmigrantUS for your critical review.

UPDATE 1/02/07 Thank you Bulldog for your review and suggestions.

UPDATE 9/08/08 Please note: as of Ubuntu 7.10 all drives are labeled sdxy (the terminology sdxy is depreciated).

Primary, Extended, and Logical partitions.

Primary partitions: The original partitioning scheme for PC hard disks allowed only four partitions, thus you are allowed up to 4 primary partitions. Linux numbers primary partitions 1-4.
Note: Some OSs (Windows, BSD) can ONLY be installed into a PRIMARY partition.
Linux (and swap) can be installed into a primary or logical partition.
Extended and Logical partitions: To overcome this limitation, extended partitions are used. A single primary partition may "converted" into an "extended" partition which is then further divided into sub-partitions called logical partitions. Sorry you may not convert more then 1 primary partition into an extended partition. You then create logical partitions within the extended partition. It may be possible to create further extended partitions within an extended partition, although this becomes complicated and I am not sure of any advantage this offers.

Linux numbers Logical partitions starting with 5: The numbers 1,2,3 and 4 are reserved for the primaries, even if you have just one primary partition. So if you make one primary partition and one extended extended partition with one logical partition:

The primary would be sda1
The entire extended partition (and any logical partition(s) it contains) would be sda2.
The logical partition within the extended partition would be sda5.

Clear as mud ?

Naming of partitions.

Windows: Windows uses lettering (c:\ ; e:\ , etc).

Linux: Linux uses /dev/hdxy or /dev/sdxy (most distros now use "/dev/sdxy", see below).

x will be a letter starting with a, then b,c,....
y will be a number starting with 1, then 2,3,....

Thus sda1 = First partition on the master HD.

GRUB.
Grub numbers drives starting with 0.
Grub also names partitions starting with 0.
Thus grub (sd0,0) = Linux sda1.

Examples of partition names.

Note: Names without a trailing digit refer to the whole disk, while names with a trailing digit refer to a partition of that whole disk.

Using sda as an example with multiple partitions:

/dev/sda = Entire HD

3 primary partitions:
/dev/sda1 = First partition = GRUB (hd0,0)
/dev/sda2 = Second partition = GRUB (hd0,1)
/dev/sda3 = Third partition = GRUB (hd0,2)
3 logical partitions (Note you can have more then 3 logical partitions within an extended partition:

-----

Note: /dev/sda4 = Entire Extended partition. sda4 is "theoretical" in that it can not be mounted as such, but it "takes up a number".
This is true for both Linux and grub speak !
-----
/dev/sda5 = fourth partition = GRUB (hd0,4)
/dev/sda6 = fifth partition = GRUB (hd0,5)
/dev/sda7 = sixth partition = GRUB (hd0,6)
HD vs SD.
As of Ubuntu 7.10 all drives are sd. This information is thus depreciated, and is available as a reference for those people using a version of Ubuntu previous to 7.10

IDE/ATA cable = hdxy
  1. Hard Drives
    /dev/hda = Entire first HD, master drive on primary IDE cable.
    /dev/hda1 = First partition on master drive.
    /dev/hdb = Entire second HD, slave drive on primary IDE cable.
  2. CDROM/DVD
    /dev/hdc = Master CD on secondary IDE cable
    /dev/hdd = Slave CD on secondary IDE cable


SCSI devices = sdxy
  1. SATA HD
  2. SCSI HD
  3. Zip drives
    Note: Although they contain only 1 partition, zip drives are numbered "4".
    ie /dev/sda4.
  4. USB devices- both flash drives and hard drives.
  5. Firewire devices.


Floppy
/dev/fd0 = First FD.
Basic partitioning scheme.

Ubuntu (Linux) "requires" 2 partitions: / and swap. Both / and swap may be either Primary or Logical partitions.
/ = root min size 5 GB (Yes, I know you can go smaller if needed), 15-20 Gb may be better if you have the HD space.
swap size
  1. RAM < 1 Gb swap = RAM X2.
  2. RAM > 1 Gb swap = 2 Gb
Some claim a swap size of > 1 Gb is excessive. The 2 Gb recommendation is "conservative".
(If you boot more then 1 distro you should share the swap partition)
Options.

/home: This is helpful if you need to re-install Ubuntu. /home stores user data and user configuration files.

Limitations:
  1. /home does not save all of the installed applications you have installed or removed beyond the base install.
  2. If you boot multiple distros those user config files can conflict.

/data: This is helpful and I use this in favor of /home.

Why?
  1. First, I boot multiple distros and user configuration files in /home can conflict as above.
  2. Those user config files are not "mission critical" to back up. They will be regenerated if deleted, although you will loose your application preferences.
  3. Backup /home to /data and you can restore /home.
  4. Data partition can be shared with other OS (Windows or other distro's) easier then /home.

You can, of course, mount your data partition as any name (mount point) you like.

Bulldog's Partitioning advice
Quote:
Some suggestions for disk partition.
Windows as big as you like.

Create an ext3 10GB for /
Create an extended from the rest off the space.
In the extended,
Create a /home 10GB
Create a swap 1GB
Create a ext3 partition for data if you have space left.
You have a separate /home for some data and a separate /data partition to backup important data.

I think a 10GB / partition is necessary to install programs without running out of space to soon.
Yes it can be 5GB or even less,but I think you shouldn't promote that one.
Advanced partitioning.
You can give each system directory a separate mount point. This includes:
/boot
/tmp
/var

This is not needed on a desktop install but is more common in server installs.

Adding /boot, /home, /var, and /tmp partitions can increase security.

For further reading, see References section below.

Partitioning and formatting can be done from the CLI:
This works well with new discs/devices and, IMO, is faster then GParted.
You can delete, create, and format partitions easily.
The CLI will not resize or move a partition, use Gparted.
The CLI will not format a partition with ntfs (windows XP).

How to Gparted, graphical guide

Partitioning with fdisk: It is easy and fast. IMO fdisk is more reliable then GParted, although Gparted is improving. The main problem I have had GParted is that it likes to re-number existing partitions which can then be fixed with fdisk.

Unmount the HD or USB device you want to partition or boot from a Live CD.

Then start fdisk:
Code:
sudo fdisk /dev/sda
Basic fdisk syntax:

p = print the partition table

n = create a new partition

d = delete a partition

q = quit without saving changes

w = write the new partition table and exit

Partitioning with fdisk
New HOWTO: Linux Partition HOWTO
Linux Partition HOWTO

Format with the command line: Syntax mkfs.<fs> <option_label> label_name <device>
See also man mkfs.* (man mkfs.ext3)
Note: If you are installing Linux you can format the target (install) partition during the install process. In this case you do not need do do more then partition your HD.

ext2:
Code:
mkfs.ext2 -L <label_name> <device>
ext3:
Code:
mkfs.ext3 -L <label_name> <device>
reiserfs:
Code:
mkfs.reiserfs -l <label_name> <device>
reiser 4:
Code:
mkfs.reiser4 -l <Device>
jfs:
Code:
mkfs.jfs -L <label_name> <device>
xfs:
Code:
mkfs.xfs -L <label_name> <device>
Note: If you use xfs for your root partition you will need a separate /boot partition.
/boot may be formated as ext2 (saves space)
FAT:
Code:
sudo mkfs.vfat -n <label_name> <device>
Examples:
Code:
mkfs.ext3 -L data /dev/sda1
Will format sda1 to ext3 and add a label "data".


Code:
mkfs.vfat -n data /dev/sda1
Will format sda1 to FAT32 and add a label "data".


References.
See this as a primer to more advanced partitioning: Linux Partitioning Guide.

For a more detailed, "short" review see also: A Short Guide to Partitioning a Hard Drive for a Linux System

For a shorter, yet through discussion see: Ubuntu Partitioning Thanks aysiu

GParted: How to Gparted, graphical guide

fdisk:
Partitioning with fdisk
New HOWTO: Linux Partition HOWTO
Linux Partition HOWTO

bodhi.zazen
__________________
A person with ubuntu is open and available to others, affirming of others, does not feel threatened that others are able and good, for he or she has a proper self-assurance that comes from knowing that he or she belongs in a greater whole and is diminished when others are humiliated or diminished, when others are tortured or oppressed. ~ Archbishop Desmond Tutu, 1999


Last edited by bodhi.zazen; December 27th, 2008 at 01:28 AM..
bodhi.zazen is offline   Reply With Quote
Old October 24th, 2006   #2
Malakia
A Carafe of Ubuntu
 
Join Date: Jun 2006
Beans: 90
Re: HowTo: Partitioning Basics

I think its an excellent guide about partions. I have notice a lot of question on how to partion my harddrive or something to do with partioning. Hopefully this will eliminate a lot of questions.
Malakia is offline   Reply With Quote
Old October 27th, 2006   #3
DJiNN
Quad Shot of Ubuntu
 
DJiNN's Avatar
 
Join Date: Nov 2005
Location: UK
Beans: 458
Xubuntu 8.10 Intrepid Ibex
Re: HowTo: Partitioning Basics

Hey, bodhi..... this is a most "Excellent" guide indeed, and one that i shall certainly be pointing a lot of people towards..... In fact, i'm gonna add it to my Sig right now! Then i'm going to check out the fstab guide.... Which i shall be reading most intently!

Got your PM by the way, shall be replying soon. In the UK at the moment, just setting up the new laptop.... it's awesome, and of course i have just downloaded the new Edgy release (Server & Desktop CD's) which i shall be installing on it asap!

Well done again, and talk to you soon........
__________________
Registered Linux user: #413753 | Ubuntu user: #7595
| Tiny Me | antiX | Zenwalk |
DJiNN is offline   Reply With Quote
Old October 27th, 2006   #4
ric_spam
First Cup of Ubuntu
 
Join Date: Oct 2006
Beans: 3
Re: HowTo: Partitioning Basics

One technical add

sdxy ie sda1 notation will indicate SATA disks. As these are becoming more popular, I think users will start to see the convention more often.

I have had problems with some older kernels with SATA - both hdd and dvd's. Typically, you can boot the live/install cd/dvd but during installation the devices are no longer detected. If you are running older kernels, keep that in mind.

Then again, if you have a mainboard which supports SATA, you are probably running as new a kernel as possible. Sorry, I know next to zero on compiling a kernel, so I can't suggest what may or may not help if you are trying to roll your own.


Thanks for this fine HowTo,

Last edited by ric_spam; October 27th, 2006 at 07:32 PM.. Reason: typo's
ric_spam is offline   Reply With Quote
Old January 3rd, 2007   #5
bulldog
Ubuntu addict and loving it
 
bulldog's Avatar
 
Join Date: Jun 2006
Location: The Netherlands
My beans are hidden!
Ubuntu 9.10 Karmic Koala
Re: HowTo: Partitioning Basics

Bookmarked for further reference,just as the fstab How To,you made again a very complete Tutorial.

Thanks.
__________________
Resistance is futile.....you will be assimilated!

Registered Linux User 418427.
#Ubuntu User 3226#
bulldog is offline   Reply With Quote
Old June 18th, 2007   #6
chinx21
Spilled the Beans
 
Join Date: Jun 2007
Beans: 14
Cool Re: HowTo: Partitioning Basics

Thank You! It's all I need! I've been searhing for guides about partitioning. Good job!
chinx21 is offline   Reply With Quote
Old November 2nd, 2007   #7
hidinginthemountains
Just Give Me the Beans!
 
hidinginthemountains's Avatar
 
Join Date: Nov 2007
Location: British Columbia, Canada
Beans: 46
Ubuntu 9.10 Karmic Koala
Re: HowTo: Partitioning Basics

Great guide. Answered a lot of questions for me. It's bookmarked for future reference. Thanks!
__________________
"Gravity is a harsh mistress" -The Tick

Ubuntu Stoke <-my blog of "things and stuff" usually about Ubuntu
hidinginthemountains is offline   Reply With Quote
Old November 15th, 2007   #8
danbar
A Carafe of Ubuntu
 
Join Date: Dec 2006
Beans: 105
Ubuntu 9.10 Karmic Koala
Question Gparted not working properly

When I installed gparted, I saw that I cannot format, resize etc.....my partitions. All I can do is to Unmount, manage flags and information. What's wrong?

Secondly, it's taking to long to open the partition editor (scanning devices). Is it normal in Ubuntu 7.10 ?
danbar is offline   Reply With Quote
Old November 15th, 2007   #9
bodhi.zazen
Ubuntu Guru
 
bodhi.zazen's Avatar
 
Join Date: Apr 2006
Location: Montana
My beans are hidden!
Xubuntu Development Release
Send a message via Yahoo to bodhi.zazen
Re: Gparted not working properly

Quote:
Originally Posted by danbar View Post
When I installed gparted, I saw that I cannot format, resize etc.....my partitions. All I can do is to Unmount, manage flags and information. What's wrong?

Secondly, it's taking to long to open the partition editor (scanning devices). Is it normal in Ubuntu 7.10 ?
FYI, managing your partitions is best done from a live CD. You should not format or resize a mounted partition, so unmounting a partition should be the first step (which is why it is easier to run from a live CD).

Just a guess, but are you running gparted as root :

Code:
gksu gparted
__________________
A person with ubuntu is open and available to others, affirming of others, does not feel threatened that others are able and good, for he or she has a proper self-assurance that comes from knowing that he or she belongs in a greater whole and is diminished when others are humiliated or diminished, when others are tortured or oppressed. ~ Archbishop Desmond Tutu, 1999

bodhi.zazen is offline   Reply With Quote
Old February 6th, 2008   #10
Scavok
5 Cups of Ubuntu
 
Join Date: Feb 2008
Beans: 30
Ubuntu 7.10 Gutsy Gibbon
Re: HowTo: Partitioning Basics

Very well done--thank you.

It would be nice to add a quick explanation of the file system types (ext2, ext3, jfs, xfs, etc.) and/or links to detailed references, along with a brief explanation of the features/advantages/benefits of each.
Scavok is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:34 PM.


vBulletin ©2000 - 2010, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. bilberry