I'm somewhat new to working with commandline tools when dealing with partitioning, so you'll have to excuse my newness.

I'm basically trying to create a new logical partition on /dev/sdb and would like to install ext3 on it. How would I do this, step by step, in parted? It's a brand-new hard drive with absolutely nothing on it.


First, make sure you understand the difference between primary, extended and logical partitions. To create a logical partition, you first need to create the extended partition that will contain it. If there's only one partition on a drive, there's no point in not making it primary. Below I'll give instructions for a logical partition; creating a primary partition is similar, only simpler, so you should be able to figure it out.

Parted isn't the easiest tool for a straightforward task, a dedicated partitioning tool such as cfdisk or even fdisk may be easier to apprehend. But here goes (untested, make sure you understand what's going on and don't proceed blindly if you see error messages). You'll need to enter the size of the device when creating the partition (parted displays it).

mklabel msdos
mkpart extended 0 123456
mkpart logical 0 123455

Then run mkfs.ext3 /dev/sdb5 outside Parted.

If you choose to use cfdisk, you should be able to navigate its menu-driven interface. If you prefer fdisk, the sequence of instructions is:

n             create partition
e             extended
1             number (1–4)
<return>      accept default start
<return>      accept default end
n             create partition
l             logical
<return>      accept default start
<return>      accept default end
p             show the current table, review it
w             write changes
q             exit
  • 1
    Thanks, I did end up using fdisk and it was a lot easier than parted. I did create a primary partition, as that's all I really needed. Thanks for the help with parted, though, I just assumed it would be easier to specify the size of the drive, as per fdisk, which defaulted to using all the space. – Naftuli Kay Apr 11 '11 at 22:41
  • Out of curiosity, why do you advocate creating an extended+logical partition, over simply creating a primary partition? If you're just putting one big partition across the entire disk and thus don't need 5+ partitions (as made possible by the extended partition) I just don't see any point to doing it this way over just mkpart primary 0 123456. Not trying to start a discussion on this, just seeking clarification of your answer. – Kromey Apr 11 '11 at 23:48
  • @Kromey: I don't advocate a logical partition, I'm just focusing on it because that's what the question requested. In fact I advocated using a primary partition; hopefully my edit makes this a bit clearer. – Gilles 'SO- stop being evil' Apr 12 '11 at 0:01
  • Sorry, I must have mis-read both question and answer, unless your edit was to add the "not" in front of "making it primary". – Kromey Apr 12 '11 at 0:09
  • 1
    I love fdisk as much as the next guy, but please be aware that it is on its way to becoming legacy due to a lack of support for many modern partition table formats (read GPT). I think parted and cfdisk handle this better. – Lennart Rolland May 24 '14 at 4:08

You can use parted to do both at the same time

parted -a optimal /dev/sda mkpartfs primary ext4 0% 100%
  • That is incorrect, parted does not build the root inodes of a filesystem. – grochmal Oct 14 '16 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.