I have just purchased a Raspberry Pi B+ and a 32 GB memory card. The documentation says I have to copy the image to the card, e.g., if my card device is /dev/sdf1, I have to copy the image to /dev/sdf.

Since the card is much bigger than the image, I would like to partition the card and copy the image to partition /dev/sdf1. I would then create other partitions and mount them from the running system. Is this going to work or does the image already contain its hard-coded partition table?

  • Referring to partition tables as "hard coded" is nonsensical in the way that referring to a text file as "hard coded" would be nonsensical. Like a text file, a partition table is just data stored on the card and can always be changed. You do not have to add more partitions to make more use of the card, by the way, you can increase the size of the partitions that are already on it. – goldilocks Mar 24 '15 at 1:36
  • @goldilocks: Yes, hard coded is the wrong term. What I mean is whether the system is supposed to work with those partitions and some things may break if the partition schema is changed. Also, I did not known if the image only contained one partition or if it contained a pre-configured partition table that can be changed later. – Giorgio Mar 24 '15 at 6:50
  • Okay, I follow you now. – goldilocks Mar 24 '15 at 12:15

I would then create other partitions and mount them from the running system. Is this going to work or does the image already contain its hard-coded partition table?

Yes, you can do that. The only thing you should not change anything about is the first small, FAT based partition. This contains the kernel and bootware and the SoC is hardcoded to look for that stuff specifically where it is.

The raspbian image has a second, ext4 based partition that contains the root filesystem, and the kernel will expect to find that. However, as long as your partition table is consistent, you can change its size (you should do this via the "Expand Filesystem" option from raspi-config). You can also add more partitions, and if you modify root= in cmdline.txt on the first partition, you can move the root filesystem to another partition.

  • I did not manage to change the partition table from my desktop using fdisk. However, after booting the image on my raspberry pi, the system suggested me to run the configuration tool raspi-config. There, I used the Expand Filesystem option as you suggested. This is not exactly what I wanted, but it solves the problem for now. – Giorgio Mar 28 '15 at 15:54
  • If you want additional partitions instead of one big one but fdisk with the card in your computer did not work, you can certainly use fdisk in Raspbian on the running pi to add partitions. However DO NOT alter anything about the first TWO partitions when you do this, since the second one is the root filesystem. I.e., if you've already expanded to fill the card, things are now more difficult; you would have to shrink it back using resize2fs with the card in another computer. – goldilocks Mar 28 '15 at 16:01
  • Thanks, I will try again when I have another card. At the moment I have a running system and I would like to experiment with it. But yes, I will definitely try to do as you say when I have the occasion. I still do not understand why it did not work when using a card reader from my desktop. – Giorgio Mar 28 '15 at 16:30
  • Hmmm -- did you forget to commit the changes with w? Otherwise they are just discarded. fdisk doesn't really do anything until you do that; it shows the changes to the table you asked for that would be made if you commit it to disk. – goldilocks Mar 28 '15 at 16:34
  • I did not write the partition table because fdisk offered me to create a new partition that would have overlapped with the existing ones. Normally fdisk recognizes the existing partitions and automatically sets the beginning of a new partition right after the end of the last existing partition. Also, fdisk did not report any bootable partitions on the card. So I thought that maybe the image had some special format that fdisk cannot handle properly. When I have another card I will give it another try. – Giorgio Mar 28 '15 at 16:39

This is definitely something you can do. Just copy the image to the card, then use a partition manager such as Disk Management for Windows (should be preinstalled), GParted for Mac from this link, or GParted or Disks (preinstalled on Ubuntu) to create partitions easily.

  • I have tried this on my desktop running Wheezy using a usb card adapter. After I wrote the image to the card, fdisk reports two partitions: /dev/sdf1 of type W95 FAT32, and partition /dev/sdf2 of type linux. I can mount the first partition, but when I try to mount the second I get the error "mount: special device /dev/sdf2 does not exist". If I try to create a new partition, the default begin sector suggested by fdisk overlaps with one of the existing partitions. Finally, I noticed that the first partition is not marked as bootable. Is all this normal? – Giorgio Mar 25 '15 at 6:47

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.