How to create ext4 partition in Oracle Linux 6.3 64bit

Like we added a new Harddisk in our Linux machine and wanted to format in ext4 partition so here is the process.

When we add a disk it will be displayed under /dev directory.

[oracle@OEL64 ~]$ ls -l /dev/sd*
brw-rw—-. 1 root disk 8, 0 Oct 18 23:19 /dev/sda
brw-rw—-. 1 root disk 8, 1 Oct 18 23:20 /dev/sda1
brw-rw—-. 1 root disk 8, 2 Oct 18 23:19 /dev/sda2
brw-rw—-. 1 root disk 8, 16 Oct 18 23:19 /dev/sdb
[oracle@OEL64 ~]$

Login to root user and create a new partition in this new drive:

[oracle@OEL64 ~]$ su – root
Password:
[root@OEL64 ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x66845514.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won’t be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It’s strongly recommended to
switch off the mode (command ‘c’) and change display units to
sectors (command ‘u’).

Command (m for help): p

Disk /dev/sdb: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x66845514

Device Boot Start End Blocks Id System

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1958, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1958, default 1958):
Using default value 1958

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

Calling ioctl() to re-read partition table.
Syncing disks.
[root@OEL64 ~]#

So I created 1 partition /dev/sdb1 above.

Verify it:

[root@OEL64 ~]# fdisk /dev/sdb

WARNING: DOS-compatible mode is deprecated. It’s strongly recommended to
switch off the mode (command ‘c’) and change display units to
sectors (command ‘u’).

Command (m for help): p

Disk /dev/sdb: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x66845514

Device Boot Start End Blocks Id System
/dev/sdb1 1 1958 15727603+ 83 Linux

Command (m for help): quit

[root@OEL64 ~]#

Format the drive in ext4 using below command:

[root@OEL64 ~]# mkfs.ext4 /dev/sdb1

mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
983040 inodes, 3931900 blocks
196595 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4026531840
120 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

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

This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@OEL64 ~]#

Create a directory /u02 and mount it to the above new created partition:

[root@OEL64 ~]# mkdir /u02
[root@OEL64 ~]#
[root@OEL64 ~]# mount -t ext4 /dev/sdb1 /u02/
[root@OEL64 ~]#
[root@OEL64 ~]# df -kh
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VOL01-LogVol01
26G 19G 5.7G 77% /
tmpfs 1001M 276K 1000M 1% /dev/shm
/dev/sda1 194M 50M 134M 28% /boot
/dev/sdb1 15G 166M 14G 2% /u02
[root@OEL64 ~]#
[root@OEL64 ~]#

Put the entry in /etc/fstab, so that next time it will be up while rebooting the system:

[root@OEL64 ~]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Sat Sep 14 17:37:19 2013
#
# Accessible filesystems, by reference, are maintained under ‘/dev/disk’
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/VOL01-LogVol01 / ext4 defaults 1 1
UUID=433b2669-dd25-4429-bad6-4f62ba2901f3 /boot ext4 defaults 1 2
/dev/mapper/VOL01-LogVol00 swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/sdb1 /u02 ext4 defaults 1 1
[root@OEL64 ~]#

This is done.

Thanks for viewing.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s