Saturday, June 14, 2014

How to create ext3 filesystem when a new disk is added to the server



1. Check for the partition newly available
[root@test ~]# fdisk -l

Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          38      305203+  83  Linux
/dev/sda2              39        3405    27045427+  83  Linux
/dev/sda3            3406        3916     4104607+  82  Linux swap / Solaris

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

2. Now, partition the disk as below. 

[root@test ~]# fdisk /dev/sdb
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 1305.
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): u
Changing display/entry units to sectors

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

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

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

3. Format the hard disk. 
[root@test ~]# mke2fs -j /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1310720 inodes, 2621432 blocks
131071 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2684354560
80 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

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

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

4. Create  a directory in the OS.

[root@test ~]# mkdir /u01

5. Update /etc/fstab file to have new directory to be mounted.  Append the below line to the file. 

[root@test ~]# vi /etc/fstab

/dev/sdb1               /u01                    ext3    defaults        1 2


6.  To mount, enter
[root@test ~]# mount -a

7.  Verify now, the new mount point is available. 

[root@test ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              25G  2.1G   22G   9% /
/dev/sda1             289M   16M  258M   6% /boot
tmpfs                 1.3G     0  1.3G   0% /dev/shm
/dev/sdb1             9.9G  151M  9.2G   2% /u01



No comments:

Post a Comment