FDISK

Linux Questions and Answers.

FDISK:

Q1. Linux allows how many Primary Partitions?

Linux allows only 4 primary partitions. We can have a much larger number of logical partitions by sub-dividing one of the primary partitions. Only one of the primary partitions can be sub-divided.

 

Q2. What is fdisk?

Fdisk is a disk partition utility command.

fdisk is started by typing (as root) fdisk device at the command prompt. device might be something like /dev/hda or /dev/sda

 

Q3. What commands do we need  to create disk partitions?

The basic fdisk commands we need are:

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

Changes we make to the partition table do not take effect until we issue the write (w) command. Here is a sample partition table:

Disk /dev/hdb: 64 heads, 63 sectors, 621 cylinders

Units = cylinders of 4032 * 512 bytes

Device Boot Start End Blocks Id System

/dev/hdb1 * 1 184 370912+ 83 Linux

/dev/hdb2 185 368 370944 83 Linux

/dev/hdb3 369 552 370944 83 Linux

/dev/hdb4 553 621 139104 82 Linux swap

 

The first line shows the geometry of your hard drive. It may not be physically accurate, but you can accept it as though it were. The hard drive in this example is made of 32 double-sided platters with one head on each side (probably not true). Each platter has 621 concentric tracks. A 3- dimensional track (the same track on all disks) is called a cylinder. Each track is divided into 63 sectors. Each sector contains 512 bytes of data. Therefore the block size in the partition table is 64 heads * 63 sectors * 512 bytes er…divided by 1024.  The start and end values are cylinders.

$fdisk /dev/hdxx n – create a new partition

press <-| at first cylinder

define size +100M at Last cylinder

w – write and quit

 

$sync

$partprobe -s /dev/hdxx

 

– rereads the partition table and updates the kernel table.

-s – to show the output.

 

Linux Questions and Answers.

FORMAT:

 

Q1  Which command do we use to format disk and assign filesystem type?

We use  mke2fs for it. For ext2 format use $mke2fs for ext3 use $mke2fs -j

 

$ mke2fs – j /dev/hdxx

-j stands for journaling as ext3 is a journaling filesystem.

$mkdir /newdir

$mount /dev/hdxx /newdir

for permanent mount use fstab

$vi /etc/fstab

Append – /dev/hdxx /mnt ext3 defaults 0 0

 

Q2. What is fstab?

fstab is 9th out of the 10 most critical and important configuration files which is stored in /etc directory, where all the configuration files are stored. fstab stands for “File System TABle” and this file contains information of hard disk partitions and removeable devices in the system. It contains infor-mation of where the partitions and removeable devices are mounted and which device drivers are used for mounting them, which filesystem they are using and what permissions are assigned to them.

 

/dev/hdxx /mnt ext3 defaults 0 0

 

1st field device

2nd field mountpoint

3rd field filesystem

4th filed permisson

5th field backup for sixth field

6th field fsck sequence (same as chkdsk in windows)  

Q3. What is filesystem?

File System is a method to store and organize files and directories on disk. A file system can have 2 different formats called file system types. These formats determine how the information is stored as files and directories.

 

Q4. What is basic difference between ext2 and ext3 filesystem?

ext3 is a journaling which maintains record in its journal. Fast recovery & recovery successful Ext2 doesnt maintains journal.Slow recovery & no guarantee.

 

Q5.  What is journaling?

It means you don’t have to fsck after a crash. Basically.  This is useful, because it means that every time your screen whites out and crashes. We don’t have to sit through an entire filesystem check of every inode. The filesystem still fscks itself every X mounts or Y days, but doesn’t put us through the entire wait every time you crash it.

 

Q6. How do we convert ext2 to ext3 file system ?

To convert partition,s to the ext3 filesystem, you need to cleanly unmount them, boot something else (like the Debian CD you installed from and then, on a console, do:

tune2fs -j /dev/hdaX

 

wherein /dev/hdaX is the partition we want to add journaling to (hence the `-j’ flag).Don’t forget to modify the lines in our /etc/fstab to reflect that the partitions in question are to be mounted as ext3, not ext2. When cleanly unmounted, they can still be mounted as ext2, but the whole point of changing them was so they wouldn’t be. That’s it. When we reboot, our partitions should come up as ext3.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s