Format and create a Linux file system

Linux comes with mkfs command to format filesystem. It is used to build a Linux file system on a device, usually a hard disk partition. General syntax of mkfs is as follows:

In RHEL 5.x for create ext3 file system
mkfs -t filetype /dev/DEVICE
OR
mkfs.ext3 /dev/DEVICE


In RHEL 6.x for create ext4 file system
# mke2fs -t ext4 /dev/DEV
or
# mkfs.ext4 /dev/DEV

# mkfs.ext3 /dev/mapper/Backup1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
17924096 inodes, 35831420 blocks
1791571 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
1094 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

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.

# mkdir /backup
# ll /dev/mapper/*
brw-rw—- 1 800 900 253, 7 Jul 25 09:39 /dev/mapper/APP
brw-rw—- 1 800 900 253, 18 Jul 27 08:42 /dev/mapper/APP1
brw-rw—- 1 root disk 253, 9 Jul 25 11:51 /dev/mapper/Backup
brw-rw—- 1 root disk 253, 15 Jul 27 10:26 /dev/mapper/Backup1
crw——- 1 root root 10, 63 Jul 24 17:30 /dev/mapper/control
brw-rw—- 1 root 900 253, 0 Jul 25 09:39 /dev/mapper/ocrvote1
brw-rw—- 1 root 900 253, 10 Jul 27 08:22 /dev/mapper/ocrvote1p1
brw-rw—- 1 root 900 253, 1 Jul 25 09:39 /dev/mapper/ocrvote2
brw-rw—- 1 root 900 253, 11 Jul 27 08:25 /dev/mapper/ocrvote2p1
brw-rw—- 1 root 900 253, 2 Jul 25 09:39 /dev/mapper/ocrvote3
brw-rw—- 1 root 900 253, 12 Jul 27 08:27 /dev/mapper/ocrvote3p1
brw-rw—- 1 800 900 253, 6 Jul 25 09:39 /dev/mapper/oradata
brw-rw—- 1 800 900 253, 5 Jul 25 09:39 /dev/mapper/oradata1
brw-rw—- 1 800 900 253, 16 Jul 27 08:38 /dev/mapper/oradata1p1
brw-rw—- 1 800 900 253, 8 Jul 25 09:39 /dev/mapper/oradata2
brw-rw—- 1 800 900 253, 17 Jul 27 08:41 /dev/mapper/oradata2p1
brw-rw—- 1 800 900 253, 4 Jul 25 09:39 /dev/mapper/oraredo
brw-rw—- 1 800 900 253, 14 Jul 27 08:32 /dev/mapper/oraredo1
brw-rw—- 1 800 900 253, 3 Jul 25 09:39 /dev/mapper/orasys
brw-rw—- 1 800 900 253, 13 Jul 27 08:29 /dev/mapper/orasys1

# mount /dev/mapper/Backup1 /backup

# df -kh
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 37G 3.1G 32G 9% /
/dev/sda9 3.6G 72M 3.4G 3% /tmp
/dev/sda8 7.2G 294M 6.6G 5% /var
/dev/sda7 15G 165M 14G 2% /home
/dev/sda6 15G 165M 14G 2% /opt
/dev/sda2 38G 177M 36G 1% /u01
/dev/sda1 99M 26M 69M 28% /boot
tmpfs 7.8G 0 7.8G 0% /dev/shm
/dev/mapper/Backup1 135G 188M 128G 1% /backup

# cd /backup/

Note: do not put the entries in /etc/fstab otherwise next reboot server not able to startup

Recommended to put the permanent configuration using rc.local file
vi rc.local
mount /dev/mapper/Backup1 /backup

http://www.cyberciti.biz/faq/howto-format-create-linux-filesystem/
https://ext4.wiki.kernel.org/index.php/Ext4_Howto#Creating_ext4_filesystems

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