19

I have seen instructions for resizing the partition here, but how do I create a whole new partition using the remaining space, and then mount it?

1 Answer 1

15

Using fdisk:

fdisk /dev/sda

Type n to create a new partition.

Type p to make a primary partition.

Next press enter when prompted for a partition number to choose the next available.

Press enter again to pick the next available sector to start the partition. Press enter again to use all of the remaining disk space.

Type w to save the changes.

Fdisk will now exit. You am need to reboot in order for the partition to be available.

You can now make a file system for the new partition using the mkfs command.

mkfs.ext4 /dev/sdax

Where x is the partition number.

Note: sometimes when creating a new partition for the sd card there has been a small amount of logical space that takes up the rest of the image. You'll need to use the method in the question you linked to in order to extend that space, or do as I do and just create another partition after it.

To mount you use the mount command like this:

mount /dev/sdax /path/to/mount/point

If you want the partition to mount automatically at boot then you need to add an entry in the /etc/fstab file.

/dev/sdax      /path/to/mount    defaults      1 0
8
  • 2
    On my Pi (Debian squeeze) /dev/sda was /dev/mmcblk0 and x was px, e.g. /dev/mmcblk0p4 Commented Jun 24, 2012 at 17:55
  • That seems to be standard for the RPi distributions for some reason.
    – Jivings
    Commented Jun 24, 2012 at 18:09
  • 1
    Ok, the default partitions are created with 16 cylinder gaps. If I accept the first default it creates a 1mb partition in one of the gaps. If I specify the end plus 16 (assuming the gaps are for a reason) then the second default is the end of the unused 2gb. Success, thx Commented Jun 24, 2012 at 19:59
  • I would mount with "defaults,noatime" since it's on an SD card
    – Paolo
    Commented Jul 7, 2012 at 20:27
  • 1
    @DavidSykes You should mount with noatime as well. This question will explain why.
    – Jivings
    Commented Jul 8, 2012 at 15:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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