Hard drive partition management in Linux

Partition Drives
Format Drives

I don't have to tell you to be careful, everyone deletes a hard drive at some point, no doubt \
you have too. Make sure you get the right drive letter (sda or sdb or sdc...). I will substitute \
with x (sdx)

Partition and Format New Drive[-][--][++]

This example will create a swap, a root partition for a linux install, and a large home partition.
I am using a new seagate 750g SATAII HD.

List out all your hard drives. Find the drive letter (like sda or sdc..)[-][--][++]

# fdisk -l

Partition The Drive[-][--][++]

Note: this does not format the drive, just partitions it.

# fdisk /dev/sdx
 m          (show a list of all fdisk commands)
 p          (show the current partition table, will be blank on new HD)
 n          (add partition)
 p          (primary)
 1          (partition number 1, the first partition we make)
 enter      (just hit enter on the First Cylinder, so default to 1)
 +1000M     (for last cylinder, this partition will be 1gig in size)
 p          (there's your new partition, its set to type: linux, we want swap)
 t          (change the type)
 L          (list types)
 82         (linux swap)
 p          (now it's linux swap / Solaris type)
 n          (create new partition)
 p          (primary)
 2          (the second partition were making)
 enter      (default first cylinder)
 +5000M     (make it 5gigs)
 p          (the default Type: linux is good, this can be formated later as ext2 or ext3 or more...)
 a          (set the boot partition, in this case, our main root linux install partition)
 2          (enter 2 for our linux root partition we just made)
 p          (now you see a star by partition 2 (sdx2), that means it is our boot partition)
 n          (create new partition)
 p          (primary)
 3          (our 3rd and final partition (the huge home part))
 enter      (default first cylinder)
 enter      (default last cylinder, this means, use the rest of the drive for this partition)
 p          (view your changes before saving)
 w          (write changes !!! everything will be LOST)

Now you can fdisk -l again and see sdx has 3 partitions

Format the Drive with ext3[-][--][++]

# mkfs.ext3 /dev/sdx2          (this formats our root linux install partition to ext3)
  (note: it default to blocksize=4096 and reserves 5% for root use, which is good for this partition)
# mkfs.ext3 /dev/sdx3 -m 0     (this formats our large home partition)
  (note: the -m 0 sets the root reserve space to 0%, we want to full space for storage)

Label the Drive[-][--][++]

e2label /dev/sdx NewDriveName

Your done! The swap partition does not need formating. You can format whatever type you want, type mkfs \
and then hit tab twice and you will get a list of formatting types (in this case, programs to format with).

asdfasdf:/dev# mkfs
mkfs           mkfs.cramfs    mkfs.ext3      mkfs.msdos     mkfs.vfat
mkfs.bfs       mkfs.ext2      mkfs.minix     mkfs.reiserfs  

ReiserFS is good, you should look into that Filesystem type.

Quick example to mount up your large new home partition on the system you just formated it with

# mkdir /mnt/newDrive | mount -t ext3 /dev/sdx3 /mnt/newDrive

If you can't edit it with your GUI (because you created for folder with root, so only root has permissions)

# chown yourusername /mnt/newDrive/ -R
# chgrp yourusername /mnt/newDrive/ -R