Monday, May 13, 2013

create a new filesystem on linux

Having the device ready

[oracle@rac1 ~]$ ls -al /dev/sd*
brw-r----- 1 root disk 8,   0 May 13 08:42 /dev/sda
brw-r----- 1 root disk 8,   1 May 13 08:42 /dev/sda1
brw-r----- 1 root disk 8,   2 May 13 08:42 /dev/sda2
brw-r----- 1 root disk 8,  16 May 13 08:42 /dev/sdb
brw-r----- 1 root disk 8,  17 May 13 08:44 /dev/sdb1
brw-r----- 1 root disk 8,  32 May 13 08:42 /dev/sdc
brw-r----- 1 root disk 8,  33 May 13 08:44 /dev/sdc1
brw-r----- 1 root disk 8,  48 May 13 08:42 /dev/sdd
brw-r----- 1 root disk 8,  49 May 13 08:44 /dev/sdd1
brw-r----- 1 root disk 8,  64 May 13 08:42 /dev/sde
brw-r----- 1 root disk 8,  65 May 13 08:44 /dev/sde1
brw-r----- 1 root disk 8,  80 May 13 08:42 /dev/sdf
brw-r----- 1 root disk 8,  81 May 13 08:44 /dev/sdf1
brw-r----- 1 root disk 8,  96 May 13 08:42 /dev/sdg
brw-r----- 1 root disk 8,  97 May 13 08:42 /dev/sdg1
brw-r----- 1 root disk 8, 112 May 13 08:42 /dev/sdh


Partitioning with fdisk

[root@rac1 ~]# fdisk /dev/sdh
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 6527.
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): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-6527, default 1): 
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-6527, default 6527): 
Using default value 6527

Command (m for help): p

Disk /dev/sdh: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdh1               1        6527    52428096   83  Linux

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

Calling ioctl() to re-read partition table.
Syncing disks.

Creating an ext3 filesystem

[root@rac1 ~]#  mkfs -t ext3 /dev/sdh1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
6553600 inodes, 13107024 blocks
655351 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
400 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

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

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


Create a mount point:
[root@rac1 u01]# mkdir /u01


Edit the /etc/fstab to include the new partition
# vi /etc/fstab
Append the new line as follows:
/dev/sdh1 /u01 ext3 defaults 1 2 

Mount the filesystem

[root@rac1 u01]# mkdir /u01

No comments:

Post a Comment