Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to build my own Linux as "Linux From Scratch".

I need to get a new partition from my hard disk. I checked and saw I have sda1. (I have about 20G empty) When I use the fdisk command n, I can only get about 500M space (according to the first and last cylinder fdisk provided me). Why?

Could anyone help me? How can I do this correctly?

Screen shots of my operation:

fdisk output

df output

share|improve this question
    
By "empty space", do you mean "unpartitioned space" or "unused space"? –  Michael Mrozek Oct 31 '11 at 4:55
    
@MichaelMrozek I mean unused space. –  Anders Lind Oct 31 '11 at 4:57
    
Have a look at man df. It did not show you the space available on your new partition. You cannot use it for unmounted file systems. –  rozcietrzewiacz Oct 31 '11 at 7:59

2 Answers 2

up vote 2 down vote accepted

I think rozcietrzewiacz found the main thig that's bothering you. Your call to df is not reporting information about the new partition you created, it's reporting information about the “none” filesystem that's mounted on /dev. This is an in-memory filesystem that exists solely to host device files. You would see the same output from df /dev or df /dev/sda.

df /path/to/file normally reports information about the filesystem containing the specified file; that's what's happening here, because you haven't mounted /dev/sda5. There's an exception: if you supply the path to a mounted device, then df reports information about the filesystem on that device.

There's a second issue: you've apparently run fdisk /dev/sda1. Don't do that, it won't work. You can't create partitions inside partitions that way. (Well, you can, but Linux won't see them.) You need to run fdisk /dev/sda to create partitions on /dev/sda, and apparently you already have partitions there. It's not clear how you want to allocate space on your disk; make sure you know what you're doing if there's other data on the disk that you don't want to lose. Check that your backups are up-to-date!

Feel free to ask for more help on this site. But please copy-paste output as text, not as images (which are hard to read and can't be searched) and provide full session transcripts (e.g. show what command you ran in addition to the output of the command). As a starting point, if you're confused on how to split up your disk, show the output of fdisk -l /dev/sda and explain what the currently existing partitions contain and how you want to reallocate space.

At this point, I recommend reading this answer for background, at least the section about mounting.

Creating a partition defines an area on the disk; it doesn't write anything inside this area. At this point, you should create a partition (type 83) using up most of the disk, and a second partition (type 82) using a couple of GB for swap. On the bigger partition, the second step is to create a filesystem with mkfs.ext2. Once you've done that, you'll be able to mount that filesystem, e.g. with mount /dev/sda1 /mnt.

share|improve this answer

I've taken a look at the Ubuntu man page for fdisk, in case there was some oddity, I do not see an 'n' switch listed. What about using a Live Distro such as PartedMagic, I'd provide a hyperlink but I am limited to two, which I use below?

You could use GParted and also see a graphical representation of your HDD's partitions. Using GParted you can simply select the 'free-space', size, filesystem type and create the partition (from the back - visually the right side in GParted); or, even create a new partition from the end of an existing one I believe, you cannot split a partition from the front I believe due to technical reasons I had read at one time but cannot recall at the moment.

Below is a link to the official GParted Help Manual:

http://gparted.sourceforge.net/display-doc.php?name=help-manual&lang=C

Here is the section that would apply directly to your needs:

http://gparted.sourceforge.net/display-doc.php?name=help-manual&lang=C#gparted-intermediate-partition-actions

That is the 'Intermediate Partition Actions' section. As you can see, the first subsection is 'Creating a New Partition'. It will guide you through step-by-step.

share|improve this answer
3  
n isn't a switch, it's an fdisk command. fdisk gives you a prompt that lets you run a number of commands; n makes a new partition –  Michael Mrozek Oct 31 '11 at 5:05
    
I apologize, I had read through the op's question a little to quickly. –  V_P Oct 31 '11 at 15:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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