0

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?

3
  • 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
    Commented Mar 24, 2015 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
    Commented Mar 24, 2015 at 6:50
  • Okay, I follow you now.
    – goldilocks
    Commented Mar 24, 2015 at 12:15

2 Answers 2

1

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.

5
  • 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
    Commented Mar 28, 2015 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
    Commented Mar 28, 2015 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
    Commented Mar 28, 2015 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
    Commented Mar 28, 2015 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
    Commented Mar 28, 2015 at 16:39
2

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.

1
  • 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
    Commented Mar 25, 2015 at 6:47

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.