1822727 Members
3772 Online
109644 Solutions
New Discussion юеВ

fdisk command

 
SOLVED
Go to solution
Anh-Thu Tran
Frequent Advisor

fdisk command

[root@addel01 fs21]#
Not sure why I have this selection when trying to create the new partition:

fdisk /dev/sdb

Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)

I don't have this selection on another linux box. Please help. Thank you.
15 REPLIES 15
Ivan Ferreira
Honored Contributor

Re: fdisk command

This is because in the other box, you already have four partitions and you cannot create another primary partition. In this box, you still can create a primary partition and that is why you have that option, and of course, the option to create a logical partition.

Please post the output of fdisk -l if you want more information
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Anh-Thu Tran
Frequent Advisor

Re: fdisk command

[root@addel01 etc]# fdisk -l /dev/sdb

Disk /dev/sdb: 146.5 GB, 146548981760 bytes
255 heads, 63 sectors/track, 17816 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 2611 20972826 83 Linux
/dev/sdb3 5162 6466 10482412+ 83 Linux
/dev/sdb4 6467 17816 91168875 f Win95 Ext'd (LBA)
/dev/sdb5 6467 7231 6144831 83 Linux
/dev/sdb6 7232 7766 4297356 83 Linux
/dev/sdb7 7767 8027 2096451 83 Linux
/dev/sdb8 8028 8158 1052226 82 Linux swap
/dev/sdb9 8159 11806 29302528+ 83 Linux
/dev/sdb10 118 17816 48275293+ 83 Linux

I believe I still have 43G left, but could not create more. If I select p, I only create sdb2 with 20G(from 2612 - 5261). If I select l, it said I have no more partition to create. I thought for /dev/sdb I can 15 partitions.
Ivan Ferreira
Honored Contributor

Re: fdisk command

The fact is that you don't have the possibility to create a new logical partition because you don't have free space on the extended partition, all the space in the extended partition is used by logical devices. You have the option to create a new primary partition, and the maximum size that you can create is 20 GB. So, it's correct.

How do I get that conclusion?

If you sum the space used by the logical partitions, you will get the size of the extended partition, so you don't have free space and you cannot create more logical parittions.

If you sum the size of the extended partitions and the primary partitions, you will get 122624113 (122 GB), so you only have aprox 20 GB available for a primary partition.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Anh-Thu Tran
Frequent Advisor

Re: fdisk command

But if I ran df -k command, the total size just show ~103G. Look like I still have ~43G free. If the sdb2 can create partition with 20G, where is another 23G?
[root@addel01 etc]# df -k
FS 1K-blocks Used Available Use% Mounted on
/dev/sdb3 10317860 749580 9044160 8% /
/dev/sda1 101089 14829 81041 16% /boot
/dev/sdb1 20641788 16597472 2995676 85% /home
/dev/sdb5 6048320 3034560 2706520 53% /opt
none 2045772 0 2045772 0% /dev/shm
/dev/sdb6 4229840 2214184 1800792 56% /usr
/dev/sdb7 2063504 709708 1248976 37% /var
/dev/sdb9 28842748 10328776 17048848 38% /fsbuild
/dev/sdb10 28842748 9135976 18241648 34% /fs21
Ivan Ferreira
Honored Contributor

Re: fdisk command

There is something wrong with the /fs21 file system. As you can see, in the fsdisk output for /dev/sdb10 you get 48275293 blocks, but your file system is using only 28842748. This may be because at the creation time you specified the wrong values for the file system creation and is not using the whole partition (block-count). There is you missing space.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Anh-Thu Tran
Frequent Advisor

Re: fdisk command

How can I fix it? I tried to delete /fs21 and re-create it with the same /dev/sdb10, but I could not create bigger than ~28G(the last cylinder is 17816, that means I had to accept the default cylinder for start and end points). Should I delete /dev/sdb10 and re-create /fs21 with /dev/sdb11? Thanks.
Ivan Ferreira
Honored Contributor

Re: fdisk command

To be able to use the space not used in /fs21, you must umount /fs21 and re-create the file system, this will allow you to use the whole partition. Anyway, you cannot "join" the available space, I mean the sdb3 and sdb10 unless you use LVM.

So, this is what you should do:

You don't need to change the partition configuration /dev/sdb10 (accept the default values), just recreate the file system for fs21:

mkfs -t ext3 /dev/sdb10
tune2fs -c0 -m0 -i0 /dev/sdb10

Whit this you should be able to use the whole space for sdb10.

Now create your primary partition and a file system on it. This will be the 20 GB partition that started the discussion.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Anh-Thu Tran
Frequent Advisor

Re: fdisk command

After umount /fs21, should I use d option to delete /dev/sdb10 and then use n to create?
Or I can use mk2fs command right after umount /fs21?
Anh-Thu Tran
Frequent Advisor

Re: fdisk command

To be specific: I would like to use the whole /dev/sdb10 (~48G) to be /fs21 rather than ~28G.
Ivan Ferreira
Honored Contributor

Re: fdisk command

You only need to use mkfs after umount the file system as I showed in the example above to use the whole partition size.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Anh-Thu Tran
Frequent Advisor

Re: fdisk command

Hi,
One more question: should I worry about the data on /fs21 now? Do I need to back it up before to do mkfs? Thank you.
Ivan Ferreira
Honored Contributor
Solution

Re: fdisk command

YES! All data will be destroyed when you run mkfs. Always have a backup.

As an option to mkfs, you can try using ext2online to resize the file system, in this way you won't loose any data, but anyway you must have a good backup.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Anh-Thu Tran
Frequent Advisor

Re: fdisk command

Now I got /fs21 with the new size 48G by umount and run mkfs, but this is read-only filesystem. Why it happens like that, now no one can access to it?
Ivan Ferreira
Honored Contributor

Re: fdisk command

What is the output of cat /proc/mounts?

If it's mounted as read only (ro), run:

# mount -o rw,remount /fs21

What are the permissions for /fs21 and who is the owner?
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Anh-Thu Tran
Frequent Advisor

Re: fdisk command

Thank you for all your help. Everything is OK now.