Alejandro Vargas' Blog

  • December 4, 2006

How to Create, configure and mount a new Linux file system

Alejandro Vargas
Technical Leader, ACS Global Delivery, Infrastructure & BigData

How to Create, configure and mount a new Linux file system

1) Create one or more partitions using fdisk:

    fdisk  /dev/sdb
    N (new partition)
    p (primary partition)

    Accept default initial and end blocks if you want to create a single partiton with the whole disk

    w (write the information and quit)

2) check the new partition

    [root@vmractest3 root]# fdisk -l
    Disk /dev/sdb: 21.4 GB, 21474836480 bytes
    255 heads, 63 sectors/track, 2610 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

       Device Boot    Start       End    Blocks   Id  System
    /dev/sdb1             1      2610  20964793+  83  Linux

3) Format the new partition as an ext3 file system type:

    /sbin/mkfs -t ext3 /dev/sdb1

4)Assigning a Label with e2label

    Once you have created and formated a partition,

    you should assign it a label using the e2label command. This allows you

    to add the partition to /etc/fstab using a label instead of using a

    device path, thereby making the system more robust. [1] To add a label

    to a partition, type the following command as root:

    /sbin/e2label /dev/s db1 /oradisk

5) Then add the new partition to /etc/fstab, this way it will be mounted at reboot:

    To check the label use this command:

    [root@vmractest3 root]# /sbin/tune2fs -l /dev/sdb1 |grep volume

    Filesystem volume name:   /oradisk

    vi /etc/fstab and add the following line:

    LABEL=/oradisk          /oradisk                ext3    defaults        1 2

6) Mount the new file system:

    First create the base directory and assign it to the user that will own it

    [root@vmractest3 root]# mkdir /oradisk

    [root@vmractest3 root]#chown oracle:dba /oradisk

    Then mount it

    [root@vmractest3 root]# mount /dev/sdb1 /oradisk

    And check it

    [root@vmractest3 root]# df -k

    Filesystem           1K-blocks      Used Available Use% Mounted on

    /dev/sda2              8064304   2181296   5473352  29% /

    /dev/sda1               101089      9272     86598  10% /boot

    none                    513748         0    513748   0% /dev/shm

    /dev/sdb1             20635700     32828  19554636   1% /oradisk

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.