6

I have just flashed an image of my original 16 GB SD card (the one that comes in the Raspberry Pi kit) to a new 128 GB card. It booted up fine but when I tried to expand the filesystem using raspi-config it gave me

Your partition layout is not currently supported by this tool.
You are probably using NOOBS, in which case
your root filesystem is already expanded anyway.

I've seen that you can do this manually but all the tutorials I try have been for the RPi 2 or 3 and my partitions have been different to the tutorial. I can't figure out how to do it for the RPi 4. Please help.

Edit: output of sudo fdisk -l /dev/mmcblk0:

Disk /dev/mmcblk0: 119.1 GiB, 127865454592 bytes, 249737216 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x000895ae

Device Boot Start End Sectors Size Id Type /dev/mmcblk0p1 8192 4615234 4607043 2.2G e W95 FAT16 (LBA) /dev/mmcblk0p2 4615235 31116287 26501053 12.7G 5 Extended /dev/mmcblk0p5 4620288 4685821 65534 32M 83 Linux /dev/mmcblk0p6 4685824 5210109 524286 256M c W95 FAT32 (LBA) /dev/mmcblk0p7 5210112 31116287 25906176 12.4G 83 Linux

Glorfindel
  • 620
  • 1
  • 8
  • 15
Jack3G
  • 71
  • 1
  • 1
  • 5
  • "I have just flashed an image of my original 16 GB SD card " How? Whatever you did has obviously produced a non-standard result. Did you use NOOBS? – Milliways Jan 20 '20 at 06:46
  • @Milliways I used Win32DiskImager on another computer and just read from the old one to a .img then wrote that to the new one. Edit: I don't think NOOBS this just came with the kit preinstalled – Jack3G Jan 20 '20 at 06:49
  • Add exactly what you have tried till now to the question as an update. – M. Rostami Jan 20 '20 at 06:55
  • If you can boot using the new SD Card post the output of sudo fdisk -l /dev/mmcblk0 (into your Question). – Milliways Jan 20 '20 at 07:47

4 Answers4

3

From the additional information you posted it appears you are using NOOBS (as the error message suggested).

I don't know why the Foundation continues to recommend NOOBS - the experienced users on this site don't use it - even on the Foundation Forum experienced users advise against using NOOBS, because it just makes everything more difficult.

You have 3 options

  1. Perform a new clean installation.
  2. Convert the NOOBS installation to a normal Raspbian image.
  3. Manually expand the extended partition then the Raspbian root partition.

2 requires some Linux expertise, but you should be able to find instructions.

Backup/Shrink the image of my working Raspbian SD Card will create an installable image, but will NEED changes to etc/fstab and cmdline.txt to match the PARTUUID (which will be the Disk identifier with "-02" appended) of the target.
sudo fdisk -l /dev/sda | grep "Disk identifier" will show the Disk identifier of a SD Card in sda

3 is comparatively simple, but requires a Linux computer (which can be the Pi with the new card in a SD reader).

It may be possible to expand the extended partition on Raspbian if you install gparted then resize the Raspbian root partition

It is possible that you could expand the extended partition on Windows then expand the Raspbian root partition on the Pi itself.

You could try the SD Card Copier on the Pi (which requires a SD reader).

Milliways
  • 59,890
  • 31
  • 101
  • 209
  • 1
    +1 for "I don't know why...NOOBS." As far as I can tell, the only thing it's good for is trying to install something other than Raspbian. – Bob Brown Jan 20 '20 at 14:20
3

It is doable without a third-party computer, but is tricky. Back-up first.

You can resize the partitions with fdisk alone, by deleting them and recreating them at exactly the right locations. Write down the start and end sectors of each partition, as you have in the output of fdisk above. Then run sudo fdisk /dev/mmcblk0, and inside the fdisk prompt, run the following commands:

  • delete partition 2 (d, 2)
  • recreate partition 2 (n, choose extended,USE THE SAME START SECTOR, use the default for the end sector (which should be much larger)),
  • recreate partition 5 and 6 (n, USE THE SAME START AND END SECTORS)
  • change the type of partition 6 to c (t, 6, c)
  • recreate partition 7 (n, USE THE SAME START SECTOR, leave the default for the end sector)
  • print the table (p) and verify that everything matches with what you had before, except the end sectors (and sector counts) of partitions 2 and 7 should be much larger. If you notice any error, abort by entering q.
  • commit the writes to disk (w).

back at the shell:

  • run sudo partx to inform the kernel about the new layout. Alternatively, it may be safer to just reboot and check everything boots OK.
  • run sudo resize2fs /dev/mmcblk0p7 to attempt an online fs resize.

If everything went OK, you should see more space available in df.

b0fh
  • 131
  • 3
1

The easiest would be to connect SD card to PC and use GParted to extend the partition. That's one of easiest solutions available.

pbies
  • 298
  • 4
  • 13
0

Repeat the backup using one of the supported tools (which DO NOT include Win32DiskImager) and try again. Alternatively use SD Card Copier

See Periodic backup of Rpi3 Stretch SD card for a discussion of methods.

Milliways
  • 59,890
  • 31
  • 101
  • 209
  • Can you give me a list of the supported tools. The machine that i am using to work with the sd cards is running windows and by the look of this the only other one is etcher and I don't think that supports creating images. – Jack3G Jan 20 '20 at 07:24
  • @Jack3G I can't comment on Windows tools (I rarely use Windows, and even then XP). Win32DiskImager may be OK to backup, but not restore - there are reports of problems on newer Windows and SD Cards larger than 32GiB. Etcher may be better to restore these. See https://www.raspberrypi.org/documentation/installation/installing-images/README.md I use my Raspberry Pi to make my backups. – Milliways Jan 20 '20 at 07:40
  • Unsuccessful :( I just re-flashed with etcher but I couldn't expand, got the same message as before. – Jack3G Jan 20 '20 at 08:27
  • @Jack3G I absolutely agree with the recommendation in the answer; if you need one copy of an SD card, use the SD Card Copier tool that's built into Raspbian. However, if you really need to make an image on a Windows machine, I have used HDD Raw Copy with success. It is effectively dd for Windows. The portable version doesn't even need to be installed. – Bob Brown Jan 20 '20 at 14:27