16

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?

14

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
  • 1
    On my Pi (Debian squeeze) /dev/sda was /dev/mmcblk0 and x was px, e.g. /dev/mmcblk0p4 – David Sykes Jun 24 '12 at 17:55
  • That seems to be standard for the RPi distributions for some reason. – Jivings Jun 24 '12 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 – David Sykes Jun 24 '12 at 19:59
  • I would mount with "defaults,noatime" since it's on an SD card – Paolo Jul 7 '12 at 20:27
  • 1
    @DavidSykes You should mount with noatime as well. This question will explain why. – Jivings Jul 8 '12 at 15:41

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.