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:
[root@tsrm72rhel ~]# umount /dev/sda4
umount: /dev/sda4: not mounted
[root@tsrm72rhel ~]# move
bash: move: command not found
[root@tsrm72rhel ~]# clear
[root@tsrm72rhel ~]# 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
[root@tsrm72rhel ~]# 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
-
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]0 -
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
[root@tsrm72rhel ~]# 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
[root@tsrm72rhel ~]# 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
[root@tsrm72rhel ~]#sync
[root@tsrm72rhel ~]#reboot0 -
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?
[root@tsrm72rhel ~]# 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
[root@tsrm72rhel ~]# 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
[root@tsrm72rhel ~]#0 -
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 orderCommand (m for help): quitCommand (m for help): w
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... Since you can only have 4 primary partitions per harddrive (sda1 - sda4), the names sda5 and up always refer to logical partitions.
0 -
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:
[root@tsrm72rhel ~]# 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?
[root@tsrm72rhel ~]#
Seeking Help again !!!!!0 -
It sounds like you forgot to reboot after writing the partition layout to disk?0
-
Hey Jabir,
Thanks for all your help !!! The issue is resolved, n all because of you. Thanks a ton!!!!!0 -
I'm glad I could help0
Categories
- All Categories
- 49 LFX Mentorship
- 102 LFX Mentorship: Linux Kernel
- 553 Linux Foundation Boot Camps
- 296 Cloud Engineer Boot Camp
- 119 Advanced Cloud Engineer Boot Camp
- 52 DevOps Engineer Boot Camp
- 53 Cloud Native Developer Boot Camp
- 4 Express Training Courses
- 4 Express Courses - Discussion Forum
- 1.9K Training Courses
- 18 LFC110 Class Forum
- 6 LFC131 Class Forum
- 25 LFD102 Class Forum
- 150 LFD103 Class Forum
- 17 LFD121 Class Forum
- LFD137 Class Forum
- 61 LFD201 Class Forum
- LFD210 Class Forum
- LFD210-CN Class Forum
- 1 LFD213 Class Forum - Discontinued
- 128 LFD232 Class Forum
- LFD237 Class Forum
- 23 LFD254 Class Forum
- 598 LFD259 Class Forum
- 102 LFD272 Class Forum
- 1 LFD272-JP クラス フォーラム
- LFD273 Class Forum
- 2 LFS145 Class Forum
- 24 LFS200 Class Forum
- 739 LFS201 Class Forum
- 1 LFS201-JP クラス フォーラム
- 3 LFS203 Class Forum
- 69 LFS207 Class Forum
- 300 LFS211 Class Forum
- 54 LFS216 Class Forum
- 47 LFS241 Class Forum
- 41 LFS242 Class Forum
- 37 LFS243 Class Forum
- 11 LFS244 Class Forum
- 34 LFS250 Class Forum
- 1 LFS250-JP クラス フォーラム
- LFS251 Class Forum
- 140 LFS253 Class Forum
- LFS254 Class Forum
- 1K LFS258 Class Forum
- 10 LFS258-JP クラス フォーラム
- 92 LFS260 Class Forum
- 130 LFS261 Class Forum
- 32 LFS262 Class Forum
- 79 LFS263 Class Forum
- 15 LFS264 Class Forum
- 11 LFS266 Class Forum
- 17 LFS267 Class Forum
- 17 LFS268 Class Forum
- 23 LFS269 Class Forum
- 203 LFS272 Class Forum
- 1 LFS272-JP クラス フォーラム
- LFS281 Class Forum
- 221 LFW211 Class Forum
- 167 LFW212 Class Forum
- SKF100 Class Forum
- 901 Hardware
- 219 Drivers
- 74 I/O Devices
- 44 Monitors
- 115 Multimedia
- 208 Networking
- 101 Printers & Scanners
- 85 Storage
- 761 Linux Distributions
- 88 Debian
- 66 Fedora
- 15 Linux Mint
- 13 Mageia
- 24 openSUSE
- 141 Red Hat Enterprise
- 33 Slackware
- 13 SUSE Enterprise
- 356 Ubuntu
- 477 Linux System Administration
- 41 Cloud Computing
- 69 Command Line/Scripting
- Github systems admin projects
- 95 Linux Security
- 77 Network Management
- 108 System Management
- 49 Web Management
- 66 Mobile Computing
- 23 Android
- 29 Development
- 1.2K New to Linux
- 1.1K Getting Started with Linux
- 536 Off Topic
- 131 Introductions
- 216 Small Talk
- 21 Study Material
- 817 Programming and Development
- 275 Kernel Development
- 508 Software Development
- 928 Software
- 260 Applications
- 184 Command Line
- 3 Compiling/Installing
- 76 Games
- 316 Installation
- 59 All In Program
- 59 All In Forum
Upcoming Training
-
August 20, 2018
Kubernetes Administration (LFS458)
-
August 20, 2018
Linux System Administration (LFS301)
-
August 27, 2018
Open Source Virtualization (LFS462)
-
August 27, 2018
Linux Kernel Debugging and Security (LFD440)