RHEL: How to Make Partition and Add File System

Posted on April 7, 2009

2


Recently I added storage into my server in the office and I had to make a new file system for the new storage.

Firstly, I used fdisk to make the partition on the raw disk:

[root@xxxxxx cciss]# fdisk /dev/cciss/c1d1
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

The number of cylinders for this disk is set to 140531.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-140531, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-140531, default 140531):
Using default value 140531

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): p

Disk /dev/cciss/c1d1: 587.1 GB, 587128709120 bytes
255 heads, 32 sectors/track, 140531 cylinders
Units = cylinders of 8160 * 512 = 4177920 bytes

           Device Boot      Start         End      Blocks   Id  System
/dev/cciss/c1d1p1               1      140531   573366464   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@xxxxxx /]# cat /proc/partitions
major minor  #blocks  name

 104     0   35532720 cciss/c0d0
 104     1     102400 cciss/c0d0p1
 104     2   35430286 cciss/c0d0p2
 104    16   71652960 cciss/c0d1
 104    17   71652944 cciss/c0d1p1
 105     0  234285840 cciss/c1d0
 105     1  234285824 cciss/c1d0p1
 105    16  573367880 cciss/c1d1
 105    17  573366464 cciss/c1d1p1 <-- fdisk made this
 253     0   29327360 dm-0
 253     1    6094848 dm-1

And then, I used mkfs to make file system on top of the new partitions:

[root@xxxxxx /]# mkfs -t ext3 /dev/cciss/c1d1p1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
71680000 inodes, 143341616 blocks
7167080 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
4375 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 23 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

Finally, I labeled the new file system and added it into the linux file system table (fstab):

[root@xxxxxx /]# e2label /dev/cciss/c1d1p1 /ns10
[root@xxxxxx /]# vi /etc/fstab
"/etc/fstab" 9L, 629C/dev/VolGroup00/LogVol00 /ext3    defaults1 1
LABEL=/boot/efi1/boot/efivfat    defaults 0 0
tmpfs/dev/shmtmpfs   defaults0 0
devpts/dev/ptsdevpts  gid=5,mode=620  0 0
sysfs/syssysfs   defaults0 0
proc/procproc    defaults0 0
/dev/VolGroup00/LogVol01 swap swap    defaults 0 0
LABEL=/ns00 /ns00 ext3    defaults 1 2
LABEL=/ns01 /ns01 ext3    defaults 1 2
LABEL=/ns02 /ns02 ext3    defaults 1 2
LABEL=/ns03 /ns03 ext3    defaults 1 2
LABEL=/ns04 /ns04 ext3    defaults 1 2
LABEL=/ns05 /ns05 ext3    defaults 1 2
LABEL=/ns06 /ns06 ext3    defaults 1 2
LABEL=/ns07 /ns07 ext3    defaults 1 2
LABEL=/ns08 /ns08 ext3    defaults 1 2
LABEL=/ns09 /ns09 ext3    defaults 1 2
LABEL=/ns10 /ns10 ext3    defaults 1 2 <-- I added this line

In conclusion, making partition in RHEL is pretty easy and consists of three basic steps, making the partition using fdisk, making the file system using mkfs and mounting the new file system. Adding in your file system into the file system table (fstab) will allow the system to automatically mount the file system during boot. Remember that the mounting directory must exist before you try to mount the file system.

Advertisements
Tagged:
Posted in: Technology