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..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
- 167 LFX Mentorship
- 219 LFX Mentorship: Linux Kernel
- 795 Linux Foundation IT Professional Programs
- 355 Cloud Engineer IT Professional Program
- 179 Advanced Cloud Engineer IT Professional Program
- 82 DevOps Engineer IT Professional Program
- 127 Cloud Native Developer IT Professional Program
- 112 Express Training Courses
- 138 Express Courses - Discussion Forum
- 6.2K Training Courses
- 48 LFC110 Class Forum - Discontinued
- 17 LFC131 Class Forum
- 35 LFD102 Class Forum
- 227 LFD103 Class Forum
- 14 LFD110 Class Forum
- 39 LFD121 Class Forum
- 15 LFD133 Class Forum
- 7 LFD134 Class Forum
- 17 LFD137 Class Forum
- 63 LFD201 Class Forum
- 3 LFD210 Class Forum
- 5 LFD210-CN Class Forum
- 2 LFD213 Class Forum - Discontinued
- 128 LFD232 Class Forum - Discontinued
- 1 LFD233 Class Forum
- 2 LFD237 Class Forum
- 23 LFD254 Class Forum
- 697 LFD259 Class Forum
- 109 LFD272 Class Forum
- 3 LFD272-JP クラス フォーラム
- 10 LFD273 Class Forum
- 154 LFS101 Class Forum
- 1 LFS111 Class Forum
- 1 LFS112 Class Forum
- 1 LFS116 Class Forum
- 1 LFS118 Class Forum
- LFS120 Class Forum
- 7 LFS142 Class Forum
- 7 LFS144 Class Forum
- 3 LFS145 Class Forum
- 1 LFS146 Class Forum
- 3 LFS147 Class Forum
- 1 LFS148 Class Forum
- 15 LFS151 Class Forum
- 1 LFS157 Class Forum
- 33 LFS158 Class Forum
- 8 LFS162 Class Forum
- 1 LFS166 Class Forum
- 1 LFS167 Class Forum
- 3 LFS170 Class Forum
- 2 LFS171 Class Forum
- 1 LFS178 Class Forum
- 1 LFS180 Class Forum
- 1 LFS182 Class Forum
- 1 LFS183 Class Forum
- 29 LFS200 Class Forum
- 736 LFS201 Class Forum - Discontinued
- 2 LFS201-JP クラス フォーラム
- 14 LFS203 Class Forum
- 102 LFS207 Class Forum
- 1 LFS207-DE-Klassenforum
- 1 LFS207-JP クラス フォーラム
- 301 LFS211 Class Forum
- 55 LFS216 Class Forum
- 48 LFS241 Class Forum
- 42 LFS242 Class Forum
- 37 LFS243 Class Forum
- 15 LFS244 Class Forum
- LFS245 Class Forum
- LFS246 Class Forum
- 50 LFS250 Class Forum
- 1 LFS250-JP クラス フォーラム
- LFS251 Class Forum
- 154 LFS253 Class Forum
- LFS254 Class Forum
- LFS255 Class Forum
- 5 LFS256 Class Forum
- 1 LFS257 Class Forum
- 1.3K LFS258 Class Forum
- 10 LFS258-JP クラス フォーラム
- 111 LFS260 Class Forum
- 159 LFS261 Class Forum
- 41 LFS262 Class Forum
- 82 LFS263 Class Forum - Discontinued
- 15 LFS264 Class Forum - Discontinued
- 11 LFS266 Class Forum - Discontinued
- 20 LFS267 Class Forum
- 24 LFS268 Class Forum
- 29 LFS269 Class Forum
- 1 LFS270 Class Forum
- 199 LFS272 Class Forum
- 1 LFS272-JP クラス フォーラム
- LFS274 Class Forum
- 3 LFS281 Class Forum
- 9 LFW111 Class Forum
- 261 LFW211 Class Forum
- 182 LFW212 Class Forum
- 13 SKF100 Class Forum
- 1 SKF200 Class Forum
- 1 SKF201 Class Forum
- 782 Hardware
- 198 Drivers
- 68 I/O Devices
- 37 Monitors
- 96 Multimedia
- 174 Networking
- 91 Printers & Scanners
- 83 Storage
- 758 Linux Distributions
- 80 Debian
- 67 Fedora
- 15 Linux Mint
- 13 Mageia
- 23 openSUSE
- 143 Red Hat Enterprise
- 31 Slackware
- 13 SUSE Enterprise
- 348 Ubuntu
- 461 Linux System Administration
- 39 Cloud Computing
- 70 Command Line/Scripting
- Github systems admin projects
- 90 Linux Security
- 77 Network Management
- 101 System Management
- 46 Web Management
- 64 Mobile Computing
- 17 Android
- 34 Development
- 1.2K New to Linux
- 1K Getting Started with Linux
- 371 Off Topic
- 114 Introductions
- 174 Small Talk
- 19 Study Material
- 507 Programming and Development
- 285 Kernel Development
- 204 Software Development
- 1.8K Software
- 211 Applications
- 180 Command Line
- 3 Compiling/Installing
- 405 Games
- 309 Installation
- 97 All In Program
- 97 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)