I created image of raspbian jessie on 32GB memory card using dd command.

sudo dd if=/dev/disk3 of=~/os_images/raspbian_jessie.img bs=1m

then I used etcher tool to flash that image to the 120GB SSD,

I finally managed to boot it without much trouble but if I run df command I do not see correct side of my SSD which is sda1

$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/root              29G   12G   16G  41% /
devtmpfs              458M     0  458M   0% /dev
tmpfs                 462M     0  462M   0% /dev/shm
tmpfs                 462M  6.7M  456M   2% /run
tmpfs                 5.0M  4.0K  5.0M   1% /run/lock
tmpfs                 462M     0  462M   0% /sys/fs/cgroup
//  466G  370G   97G  80% /home/pi/USBHDD
/dev/sda1              63M   22M   42M  34% /boot
tmpfs                  93M     0   93M   0% /run/user/1000

but If I run the partedcommand :

$ sudo parted /dev/sda print
Model: WDC WDS1 20G2G0A-00JH30 (scsi)
Disk /dev/sda: 120GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
 1      4194kB  70.3MB  66.1MB  primary  fat16        lba
 2      70.3MB  31.3GB  31.2GB  primary  ext4

to fix this issue I tied sudo rasp-config > advanced option > expand filesystem, I get error message saying sda2 is not on SD card. Don't know how to expand

How should I expand the file system now ?

so I discovered this: https://www.raspberrypi.org/forums/viewtopic.php?t=217686

cp /usr/bin/raspi-config ~
sed -i 's/mmcblk0p/sda/' ~/raspi-config
sed -i 's/mmcblk0/sda/' ~/raspi-config

which corrupted the installation


2 Answers 2


The sda2 partition needs to be expanded beyond the 32GB size created by the Jessie install, then the filesystem needs to be expanded into that new space.

open up fdisk sudo fdisk /dev/sda

'delete' the sda2 partition using option d, 2 and yes then create a new partition n. Have this at position two and a primary type. Accept both defaults for start and end size, these will be the end of the first (boot) partition and the end of the drive (120GB). Then press w to write the changes.

If it complains about syncing disks you may need to tell the kernel you've done this via sudo partprobe.

Then expand the file system into the new space with sudo resize2fs /dev/sda2.

This works by redefining the live sda2 partition but doesn't delete any data. resize2fs then just extends the ext4 partition into the new space and should give you your 120GB root volume.

As pointed out in the comments, You should inspect the output of fdisk /dev/some-disk-or-other -l if you at all unsure of the boundaries and limits of layout of your drives, especially in relation to which partition numbers mean what. You seem to already be on the case with parted which offers similar info.

  • 2
    Good answer - odd thing though, on one of my pi's the linux partition does not begin on the sector after the boot partition end - in fact there are 1851 "unused" sectors between boot and root - so, I would suggest that instead of blindly deleting partition 2, first print the "layout" and take note of the sector partition 2 begins at Commented Dec 25, 2018 at 23:21
  • Absolutely, just blinding mucking around with fdisk isn't too smart. However, in this case, the parted output (which is just a clone of the SD image) is showing just the two so I think it'll be alright.
    – user29019
    Commented Dec 25, 2018 at 23:27
  • Wasn't there limit of 32GB supported by Raspbian or is it outdated?
    – Ingo
    Commented Dec 26, 2018 at 0:27
  • 1
    Comment from @Milliways on the deleted "answer" (the next comment above): "This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post." Of course you are right. I just took the Answer-window for the Comment-window. Sorry
    – Ingo
    Commented Dec 26, 2018 at 0:34

The same error is thrown when you want to issue raspi-config -> Expand Filesystem after resizing the RaspberryPi image physically with qemu-img resize raspbian.img +6G and booting on Qemu. Here is how you can workaround it:

  1. Boot your RPi and issue the following command:

    sed -E 's/mmcblk0p?/sda/' /usr/bin/raspi-config | sudo bash
  2. Select (7) Advanced options -> (A1) Expand Filesystem

Here we are replacing all mmcblk0p* prefixes with sda* within the raspi-config script so raspi-config is looking for sda2 device in the first place.

(Based on this forum post)

  • Why to resize the image before booting it? Do you really suggest to modify raspi-config for this? Are you sure that it doesn't break it for doing all its other options? Why to pipe the output to bash?
    – Ingo
    Commented Sep 1, 2019 at 9:08
  • Resizing the image is actually optional and to be used when you need to resize your RaspberryPi image which is for using on Qemu afterwards. When you boot RPi.img on Qemu, raspi-config can not continue because harddrive is named as sda*. I'm sure that it doesn't break other things because egrep 'mmcblk0p?' which raspi-config`` output is pretty affirmative. Pipe to bash because we derive a brand new script with sed output. To run this newly created script, you need to pipe to bash.
    – ceremcem
    Commented Sep 1, 2019 at 10:41
  • But there was nothing asked about Qemu. B.t.w. you should edit your answer and add the additional info to it.
    – Ingo
    Commented Sep 1, 2019 at 11:00
  • You are correct. That's why I already edited my answer to add the "optional" note to the first step. Don't you think it's sufficient?
    – ceremcem
    Commented Sep 1, 2019 at 11:25
  • 1
    Things should be explained in the question/answer, not in comments. It's not a question if sufficient, it's a question of doing it right according to our policies. Answers should contain some explanations and there are some more informations in your comment ;-)
    – Ingo
    Commented Sep 1, 2019 at 11:55

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.