Welcome to the new Linux Foundation Forum!

Creating a new Filesystem in LINUX

I need to create a new Filesystem in RHEL. The problem i am facing is that the system is allowing me to create a prtition only at the end of disk (after /dev/sda5) whereas i have empty space in between the Partitions. Please find the command results as below:

[[email protected] ~]# umount /dev/sda4

umount: /dev/sda4: not mounted

[[email protected] ~]# move

bash: move: command not found

[[email protected] ~]# clear

[[email protected] ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/sda2 3.9G 2.4G 1.4G 64% /

/dev/sda1 46M 11M 33M 25% /boot

none 252M 0 252M 0% /dev/shm

/dev/sda3 4.9G 64M 4.6G 2% /home

[[email protected] ~]# parted

GNU Parted 1.6.19

Copyright (C) 1998 - 2004 Free Software Foundation, Inc.

This program is free software, covered by the GNU General Public License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY

WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A

PARTICULAR PURPOSE. See the GNU General Public License for more details.

Using /dev/sda

(parted) print

Disk geometry for /dev/sda: 0.000-20480.000 megabytes

Disk label type: msdos

Minor Start End Type Filesystem Flags

1 0.031 47.065 primary ext3

2 47.065 4039.782 primary ext3

3 4039.783 9295.422 primary ext3

4 19453.711 20473.461 extended

5 19453.742 20473.461 logical linux-swap

(parted)

Now i want to create a partition in between Minor 3 and 4. An ellaborative answer would be appreciated. I am quite new to LINUX so please excuse me for my silly questions.

Thanks,

Deepika

Comments

  • jabiralijabirali Posts: 157
    There are some restrictions at work here. The Master Boot Record of a harddisk, the part of the drive that among other things contain your partition table, is limited to 512 bytes. Because of this, you are only allowed to create 4 primary partitions per harddrive - in your case, those are partitions sda1 to sda4. Since it is impossible to create any more primary partitions, you cannot place a new partition in between sda3 and sda4.

    To get around these ancient restrictions, someone came up with the idea of creating primary partitions that could contain other partitions. The primary partition is then called an extended partition, while the contained partitions are called logical partitions. In your case, sda4 is an extended partition that contains the logical partition sda5.

    What you want to do, is basically to resize the extended partition sda4 to also contain all unused space on your harddrive, and then create a new partition sda6 inside this extended partition.

    I would recommend downloading and using the LiveCD from the GParted project to repartition your harddrive, as it is specifically created to solve issues like this.

    Hope this helps :)

    [edit]
    I just noticed that your logical partition is just a swap partition, so using a LiveCD might be overkill. I instead suggest:
    [ol][li]Use su -c "swapoff /dev/sda5" to disable your swap partition[/li][li]Use your favorite partition editor to delete the partition /dev/sda4 (I suggest installing and using the application gparted since it is a simple, graphical tool with enough features for the task)[/li][li]Add a new extended partition sda4 that covers all unused space[/li][li]Create a new logical swap partition sda5 inside sda4[/li][li]Create a new logical ext3 partition sda6 inside sda4[/li][/ol]
  • DeepikaDeepika Posts: 5
    Can you please check if i have done it correct? Also, please tell me the paritions i created are logical only.. How can i link them with the Files/directories as i cannot see them after cuming out of parted.

    Command (m for help): p

    Disk /dev/sda: 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/sda1 1 6 48163+ 83 Linux
    /dev/sda2 7 515 4088542+ 83 Linux
    /dev/sda3 516 1185 5381775 83 Linux
    /dev/sda4 1186 2610 11446312+ 5 Extended
    /dev/sda5 2481 2610 1044193+ 82 Linux swap

    Command (m for help): n
    First cylinder (1186-2610, default 1186): 1186
    Last cylinder or +size or +sizeM or +sizeK (1186-2480, default 2480): 1691

    Command (m for help): n
    First cylinder (1692-2610, default 1692): 1692
    Last cylinder or +size or +sizeM or +sizeK (1692-2480, default 2480): 1818

    Command (m for help): n
    First cylinder (1819-2610, default 1819): 1819
    Last cylinder or +size or +sizeM or +sizeK (1819-2480, default 2480): 1944

    Command (m for help): n
    First cylinder (1945-2610, default 1945): 1945
    Last cylinder or +size or +sizeM or +sizeK (1945-2480, default 2480):
    Using default value 2480

    Command (m for help): p

    Disk /dev/sda: 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/sda1 1 6 48163+ 83 Linux
    /dev/sda2 7 515 4088542+ 83 Linux
    /dev/sda3 516 1185 5381775 83 Linux
    /dev/sda4 1186 2610 11446312+ 5 Extended
    /dev/sda5 2481 2610 1044193+ 82 Linux swap
    /dev/sda6 1186 1691 4064413+ 83 Linux
    /dev/sda7 1692 1818 1020096 83 Linux
    /dev/sda8 1819 1944 1012063+ 83 Linux
    /dev/sda9 1945 2480 4305388+ 83 Linux

    Partition table entries are not in disk order

    Command (m for help): quit

    You have new mail in /var/spool/mail/root
    [[email protected] ~]# df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/sda2 3.9G 2.4G 1.4G 65% /
    /dev/sda1 46M 11M 33M 25% /boot
    none 252M 0 252M 0% /dev/shm
    /dev/sda3 4.9G 64M 4.6G 2% /home
    [[email protected] ~]# fdisk -l

    Disk /dev/sda: 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/sda1 1 6 48163+ 83 Linux
    /dev/sda2 7 515 4088542+ 83 Linux
    /dev/sda3 516 1185 5381775 83 Linux
    /dev/sda4 1186 2610 11446312+ 5 Extended
    /dev/sda5 2481 2610 1044193+ 82 Linux swap
    [[email protected] ~]#sync
    [[email protected] ~]#reboot
  • DeepikaDeepika Posts: 5
    Can you please check if this is correct what i have done. :) Also, let me know how to mount my files on these directories.


    Also, Why i am not able to see my aprtitions in DF but in FDISK?

    [[email protected] ~]# df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/sda2 3.9G 2.4G 1.4G 64% /
    /dev/sda1 46M 11M 33M 25% /boot
    none 252M 0 252M 0% /dev/shm
    /dev/sda3 4.9G 64M 4.6G 2% /home
    [[email protected] ~]# fdisk -l

    Disk /dev/sda: 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/sda1 1 6 48163+ 83 Linux
    /dev/sda2 7 515 4088542+ 83 Linux
    /dev/sda3 516 1185 5381775 83 Linux
    /dev/sda4 1186 2610 11446312+ 5 Extended
    /dev/sda5 2481 2610 1044193+ 82 Linux swap
    /dev/sda6 1186 1691 4064413+ 83 Linux
    /dev/sda7 1692 1960 2160711 83 Linux
    /dev/sda8 1961 2100 1124518+ 83 Linux
    /dev/sda9 2101 2480 3052318+ 83 Linux

    Partition table entries are not in disk order
    [[email protected] ~]#
  • jabiralijabirali Posts: 157
    You did the right things until you got here:
    Disk /dev/sda: 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/sda1 1 6 48163+ 83 Linux
    /dev/sda2 7 515 4088542+ 83 Linux
    /dev/sda3 516 1185 5381775 83 Linux
    /dev/sda4 1186 2610 11446312+ 5 Extended
    /dev/sda5 2481 2610 1044193+ 82 Linux swap
    /dev/sda6 1186 1691 4064413+ 83 Linux
    /dev/sda7 1692 1818 1020096 83 Linux
    /dev/sda8 1819 1944 1012063+ 83 Linux
    /dev/sda9 1945 2480 4305388+ 83 Linux

    Partition table entries are not in disk order
    The output above shows us that fdisk should create the logical partitions sda6-sda9, which is correct. But here comes your problem:
    Command (m for help): quit
    Since you quit here, the changes to the partition layout were never actually written to disk. You will have to type the command 'w' to write the changes to disk first:
    Command (m for help): w
    Your kernel will probably still use the old partition layout, so at this point you will have to reboot your computer.

    When that is done, you should have the new partitions /dev/sda6 to /dev/sda9 available to the kernel, but they would still contain no filesystem. To create ext3 filesystems on all the partitions, run these commands as root:
    mkfs.ext3 /dev/sda6
    mkfs.ext3 /dev/sda7
    mkfs.ext3 /dev/sda8
    mkfs.ext3 /dev/sda9
    

    These partitions should then be be usable. To make them mount automatically to e.g. the directories /mnt/music, /mnt/movies, /mnt/images and /mnt/data, you have to edit the file /etc/fstab as root and add these entries to the bottom:
    /dev/sda6 /mnt/music ext3 defaults 0 2
    /dev/sda7 /mnt/movies ext3 defaults 0 2
    /dev/sda8 /mnt/images ext3 defaults 0 2
    /dev/sda9 /mnt/data ext3 defaults 0 2
    

    You would then have to create these mountpoints (again, as root):
    mkdir /mnt/music /mnt/movies /mnt/images /mnt/data
    
    And at last, mount the partitions to their respective mountpoints (this is only required the first time, it should be done automatically when you reboot):
    mount -a
    

    [edit]
    To answer your second question, df only shows partitions that are mounted, not all existing partitions (those can be viewed by fdisk -l). The new partitions should show up in df after you complete all the steps mentioned above ;)

    [edit]
    Also, please tell me the paritions i created are logical only..
    They are logical only :). Since you can only have 4 primary partitions per harddrive (sda1 - sda4), the names sda5 and up always refer to logical partitions.
  • DeepikaDeepika Posts: 5
    Thanks a lot for bearing with me.

    I had done "w" command earlier also, but somehow missed to paste it on board.

    Now i am not able to make Filesystem. The system is throwing the folloing message:

    [[email protected] ~]# mkfs.ext3 /dev/sda6
    mke2fs 1.35 (28-Feb-2004)
    Could not stat /dev/sda6 --- No such file or directory

    The device apparently does not exist; did you specify it correctly?
    [[email protected] ~]#

    Seeking Help again !!!!! :(
  • jabiralijabirali Posts: 157
    It sounds like you forgot to reboot after writing the partition layout to disk?
  • DeepikaDeepika Posts: 5
    Hey Jabir,
    Thanks for all your help !!! The issue is resolved, n all because of you. Thanks a ton!!!!!
  • jabiralijabirali Posts: 157
    I'm glad I could help :)
Sign In or Register to comment.