npaisnel
Posts: 62
Joined: Sun Aug 05, 2018 4:23 pm

Clone and “Error: Can't have a partition outside the disk!”

Tue Jan 15, 2019 10:36 am

Have been trying to create a clone of my 'working ' desktop image to save the hassle of rebuilding it with samba/ ssh/ parted, dc3dd, etc etc , cleaning Wolfram Libre office etc every time I 'f it up.

So I have made multiple Disk Clones using either the SD card copier utility or dc3dd.
Have been on this for two day s now, copying/ cloning
I have a 64gb SD card but with only about 3GB used space.

have used SD Card Copier from the Rasp GUI to clone down to 32 gb card, 816 Gb card and a 8Gb card.
All seem to boot OK.

but if I want to copy them to a disk image using dc3dd and then use th pishrink.sh script to reduces the size a bit I keep getting this

“Error: Can't have a partition outside the disk!”

When viewing the copied Micros SD card in Parted.

With this error , pishrink.sh script fails to reduce the size of the image, saying it is at its smallest... Parted viewing the SD card will not show any 'yellow' bar

Have been looking at this with links like https://gparted.org/h2-fix-msdos-pt.php ... tside-disk
or trying to use fsck. but can't use that in auto mode as it says FS in use...but can't amount it either???

I have a successful clone of my 64gb SD card to an 8gb card.
have successfully (multiple times used dc3dd to create an image.


So how do I fix this bloody Partition outside the disk error. ? the link i posted above has not been of any help to me.

Code: Select all

pi@raspgui:~ $ sudo fdisk -l -u /dev/sda
Disk /dev/sda: 7.4 GiB, 7969177088 bytes, 15564799 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: 0xfde85379

Device     Boot Start      End  Sectors  Size Id Type
/dev/sda1        8192    96663    88472 43.2M  e W95 FAT16 (LBA)
/dev/sda2       98304 15564799 15466496  7.4G 83 Linux



pi@raspgui:~ $ sudo fsck -a /dev/sda
fsck from util-linux 2.29.2
/dev/sda is in use.
e2fsck: Cannot continue, aborting.


pi@raspgui:~ $ sudo umount -f /dev/sda
umount: /dev/sda: not mounted

User avatar
DarkPlatinum
Posts: 842
Joined: Thu Nov 02, 2017 2:30 pm
Location: Unknown
Contact: Website YouTube

Re: Clone and “Error: Can't have a partition outside the disk!”

Tue Jan 15, 2019 10:39 am

Why not try etcher to flash the image to the card? Also why dont you just plug the SD card into another computer and copy it if your having problems?
1 * Raspberry Pi Zero W, 1 * Raspberry Pi 2, 1 * Raspberry Pi 3 1 * Raspberry Pi 3B + :mrgreen:

Check Out My Raspberry Site (Run on a Raspberry Pi 3B :) ): https://html.dynu.net

pcmanbob
Posts: 6618
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Clone and “Error: Can't have a partition outside the disk!”

Tue Jan 15, 2019 11:03 am

pishrink is no meant to be used directly on an SD card or on the pi.

To use pishrink you first have to make a copy of the SD card as an img file using a desktop or laptop pc,
for example on my windows7 pc I would use win32 disk imager.

you then need to transfer this image to a pc running Linux, for example Ubuntu 16.10.

you then run pishrink on the img file on the pc like this

Code: Select all

sudo pishrink.sh [-s] imagefile.img [newimagefile.img]
which will then create a new smaller image from your original one.

see the read.me file on the github page https://github.com/Drewsif/PiShrink
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

npaisnel
Posts: 62
Joined: Sun Aug 05, 2018 4:23 pm

Re: Clone and “Error: Can't have a partition outside the disk!”

Tue Jan 15, 2019 12:06 pm

Hi

Thanks for your replies. I do truly appreciate your help.

OK, my first post was not good enough obviously , thought I had explained what I was trying to do clearly enough, without to much waffle.
What I want is a solution to the, Error: Can't have a partition outside the disk!” problem

So, To answer the points in your replies, with explanations as to why things are as they are. This will be a long post, but it will save further explaining I hope, stuff that I had avoided as irrelevant in the original post...but since you ask ..
DarkPlatinum wrote:
Tue Jan 15, 2019 10:39 am
Why not try etcher to flash the image to the card?
I do use Etcher to flash the images to the SD cards, that is not the issue.

They work fine. but they are 16gb and I am trying to create a small archive image. Also if I would like to flash to one of the large stock of 4gb cards, I cannot, since a 16 gb image ain't going to fit a 4gb card without pishrink.
The sized used is only about 2.8 gb so using the 4g cards is great ..I can have one for each 'project (x-10, Home automation, SDR radio, Open WebRX, WebSDR, etc etc etc...)

Buy new cards I hear you say...well I broke my leg in a nasty motorcycle accident on 4th July, and still not back at work, and in 10 days I go back in for more surgery to have the leg broken again, have a new tibial nail fitted and a bone graft from my hip. This means I am not working, so am only surviving on government sickness benefit and still have the regular bills to pay..so I am not in position to buy new cards....feel free to send me any spare if you like... :)

DarkPlatinum wrote:
Tue Jan 15, 2019 10:39 am
Also why don't you just plug the SD card into another computer and copy it if your having problems?
Yes, I can do that on either a Windows machine or the Mac. I do not currently have any linux/ ubuntu machines set up ..and building one up just to create 2.5-3gb image of a 64 gb card is not something I really want to get in to .
But still that does not solve th problem of me wanting to create a small 'archive' disk image of this particular working system. If it was one or two disk images of 16gb instead of 3 then not a problem..but as i try and keep each 'step' of any OS build as an image, I can end up with a lot of images I can 'go back to'...so 20 images at 2.8gb is preferable to 20 images at 16gb




pcmanbob wrote:
Tue Jan 15, 2019 11:03 am
pishrink is no meant to be used directly on an SD card or on the pi.
That is OK, not trying to use it directly on the SD card. using it on the image created by dc3dd.
I did not know pishrink can't be used on the Pi. I have been using it successfully since I bought the raspberry Pi's back in July when I had my motorbike accident and started playing with them.

On a Fresh boot of Raspbian Desktop on another SD card, I ..
Create card image with dc3dd
Shrink it with pishrink
Burn back to SD with Etcher on the Mac when needed.

Since this was my first foray in to Pi stuff, I'd write (with Etcher) the basic fresh Stretch image to an SD card..Apt-get update/upgrade, Customise it to my requirements (Samba, Ssh enabled. bloat ware removed, etc etc etc,)
Then boot to a fresh desktop from another SD card, and dc3dd, pishrinbk and archive my own 'customs' image. SO I had a clean starting point to go back to.
Every time I'd add a new bit of software , be it _HA-Bridge, Home Assistant or whatever, I'd have my clean base img to go back to. I'd do a backup like that at each stage to save the rebuild from Fresh Stretch GUI or Lite....most of my stuff is running on lite headless, but want a copy of my GUI version too.




pcmanbob wrote:
Tue Jan 15, 2019 11:03 am
To use pishrink you first have to make a copy of the SD card as an img file using a desktop or laptop pc,
for example on my windows7 pc I would use win32 disk imager..
Why can I not do it on the Pi running Raspian Stretch Desktop ? it has been working fine these past 6 months . Yes I could do it on the Win 7 laptop, but since it seems (until now ) to have always worked fine on the Desktop Pi, I saw no reason to break out the laptop and use another OS




pcmanbob wrote:
Tue Jan 15, 2019 11:03 am
you then need to transfer this image to a pc running Linux, for example Ubuntu 16.10.
you then run pishrink on the img file on the pc like this .
Again,,,,,why do i have to run pishrink on another machine ? it seems to have been running fine until now on the Desktop Raspian


pcmanbob wrote:
Tue Jan 15, 2019 11:03 am

Code: Select all

sudo pishrink.sh [-s] imagefile.img [newimagefile.img]
which will then create a new smaller image from your original one.
see the read.me file on the github page https://github.com/Drewsif/PiShrink
Yes, that is exactly what I have been doing using the [-s] switch to stop auto expansion of the FS.




It is only that these last images, pishrink, when run on the image created using gdc3dd tells me that the image is a small as it can be. Be it an 8 or 16 gb image it says they cannot be made smaller, despite the fact that the used space is only 2.5gb.

When plugging in the any SD card (created by dc3dd, pishink, Etcher to burn) in a USB reader, in to the Pi (Desktop version) it wont even mount
I get an error window with the following:

Code: Select all

Error mounting /dev/sda2 at /media/pi/6bfc8851-cf63-4362-abf1-045dda421aad: Command-line `mount -t "ext4" -o "uhelper=udisks2,nodev,nosuid" "/dev/sda2" "/media/pi/6bfc8851-cf63-4362-abf1-045dda421aad"' exited with non-zero exit status 32: mount: wrong fs type, bad option, bad superblock on /dev/sda2,
       missing codepage or helper program, or other error

       In some cases useful info is found in syslog - try
       dmesg | tail or so.
doing as instructed dmesg | tail gives:


Code: Select all

pi@raspgui:~ $ dmesg | tail
[ 7130.068991] sd 0:0:0:0: [sda] Mode Sense: 03 00 00 00
[ 7130.069231] sd 0:0:0:0: [sda] No Caching mode page found
[ 7130.069242] sd 0:0:0:0: [sda] Assuming drive cache: write through
[ 7130.083475]  sda: sda1 sda2
[ 7130.083764] sda: p2 size 15466496 extends beyond EOD, enabling native capacity
[ 7130.089961]  sda: sda1 sda2
[ 7130.090268] sda: p2 size 15466496 extends beyond EOD, truncated
[ 7130.093127] sd 0:0:0:0: [sda] Attached SCSI removable disk
[ 7130.496147] FAT-fs (sda1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
[ 7130.609883] EXT4-fs (sda2): bad geometry: block count 1933312 exceeds size of device (1933311 blocks)
pi@raspgui:~ $ 

so we are back to the issue of the Partition outside the disk problem.

Which is what I'd like to work out how to fix.
fsck can't be used as per my first post because, fsck says something else is using the device, , but it wont umount either as it says the dev/sda is not mounted..as per my first post....

Hope this clarifies ...

pcmanbob
Posts: 6618
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Clone and “Error: Can't have a partition outside the disk!”

Tue Jan 15, 2019 12:17 pm

I have only ever tried to run pishrink on a pi once and if failed to produce a useable image , when I read the read.me file on the github page and it mentioned ubuntu I assumed it would only work on x86 pc's .

May be your best option would be to raise and issue giving as much detail about how you are attempting to use pishrink and that you are using it on a pi, directly on the github page that way Drew Bonasera the creator of pishrink could help you directly.

https://github.com/Drewsif/PiShrink/issues
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

npaisnel
Posts: 62
Joined: Sun Aug 05, 2018 4:23 pm

Re: Clone and “Error: Can't have a partition outside the disk!”

Tue Jan 15, 2019 1:05 pm

Worth a try, he might know, but it is not a pishrink issue. This all occurs BEFOR pishrink gets involved

Create an image with dc3dd
Transfer the image to my Mac
Put new clean SD card in "SD to USB" adapter
Put SD in Mac and write image to SD with Etcher
Put the USB reader with SD card in to Pi running Desktop Stretch.
Pi won't mount it and the "Cant have partition outside disk' and other errors as detailed appears on the Pi.


I am guessing that this error is what causes pishrink to trip up and say it cannot shrink the image from 8 or 16gb down to 2.8gb.

pcmanbob
Posts: 6618
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Clone and “Error: Can't have a partition outside the disk!”

Tue Jan 15, 2019 1:12 pm

npaisnel wrote:
Tue Jan 15, 2019 1:05 pm
Worth a try, he might know, but it is not a pishrink issue. This all occurs BEFOR pishrink gets involved

Create an image with dc3dd
Transfer the image to my Mac
Put new clean SD card in "SD to USB" adapter
Put SD in Mac and write image to SD with Etcher
Put the USB reader with SD card in to Pi running Desktop Stretch.
Pi won't mount it and the "Cant have partition outside disk' and other errors as detailed appears on the Pi.


I am guessing that this error is what causes pishrink to trip up and say it cannot shrink the image from 8 or 16gb down to 2.8gb.
That's a bit clearer now,
were are you creating the image file with dc3dd as you say you are moving the image to your mac ?
As when I create an image I would remove the SD card from the pi and then use a pc to create an image from the SD card and save that image file on the pc.

Can you post all of the error message please might help.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

npaisnel
Posts: 62
Joined: Sun Aug 05, 2018 4:23 pm

Re: Clone and “Error: Can't have a partition outside the disk!”

Tue Jan 15, 2019 1:44 pm

yes creating image on the pi using dc3dd

then use pishrink on the Pi too to shrink the image, then transfer the image to the Mac and write to another SD card using Etcher.


Think all the errors I have seen are up now.

If I put the newly created SD card back in to the Pi, in the USB/SD adapter, often when run-in PARTED on the Pi, it will show a Triangle with Exclamation mark on it next to one of th partitions...cant remember which...but have to go out now..will get back and confirm that later

pcmanbob
Posts: 6618
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Clone and “Error: Can't have a partition outside the disk!”

Tue Jan 15, 2019 1:52 pm

npaisnel wrote:
Tue Jan 15, 2019 1:44 pm
yes creating image on the pi using dc3dd

then use pishrink on the Pi too to shrink the image, then transfer the image to the Mac and write to another SD card using Etcher.


Think all the errors I have seen are up now.

If I put the newly created SD card back in to the Pi, in the USB/SD adapter, often when run-in PARTED on the Pi, it will show a Triangle with Exclamation mark on it next to one of th partitions...cant remember which...but have to go out now..will get back and confirm that later
OK its getting clearer....

So using dc3dd on the pi, are you trying to make an image of the SD card that is actually running the pi or do you have one SD card running pi and you are making an image of another SD card that is in a card reader attached to the pi.

and were are you saving the image file to.

sorry for all the questions but I am trying to get it straight in my head as to exactly what you are doing.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

npaisnel
Posts: 62
Joined: Sun Aug 05, 2018 4:23 pm

Re: Clone and “Error: Can't have a partition outside the disk!”

Tue Jan 15, 2019 5:32 pm

Yes

I have a fresh new SD card written from the image downloaded from RaspberryPi site, running the Rasp Desktop

I AM NOT trying to clone the running image.

I am trying to clone and shrink an SD card that is an SD to USB adapter.

That card in the adapter, that I am trying to clone is ‘My Customised ‘ desktop SD card. A desktop RaspberryPi Stretch image that I have installed stuff like SAMBA shares,SSH enabled, pishrink, GetTemp.sh, dc3dd and removed the bloatware stuff. It is down to about 2.8gb on a 64Gb card.
I want to image it and bring it down in size to fit 4 or 8gb cards.

pcmanbob
Posts: 6618
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Clone and “Error: Can't have a partition outside the disk!”

Tue Jan 15, 2019 7:46 pm

I presume you are saving the image file to SD card that the pi has booted from then.

I think you need to do some testing to figure out were and when the problem occurs.

This is what I would do, using a spare SD card ( 8GB will work ) that you don't mind writing over.

Using the small SD card I would install raspbian lite then boot the pi from it allowing the OS to to expand and use all the SD card, power down the pi and replace SD card with the one you were using to boot the pi when you were having problems cloning the SD cards.

now place the SD card with raspbian lite on it in the card reader and use dc3dd to make an image as before then do nothing else to the image file
( don't run pishrink on image file ) just copy it to your mac.

then try flashing this image back on to the SD card containing raspbian lite the same one you made the image from it should fit as its the same card.

if this works ok then we can say that the copy to image process is working correctly and move on.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

npaisnel
Posts: 62
Joined: Sun Aug 05, 2018 4:23 pm

Re: Clone and “Error: Can't have a partition outside the disk!”

Wed Jan 16, 2019 8:02 am

I have plenty of spare cards for this. Stock included
64
32
3 x16 ‘s
2 x 8,
4 x 4gb’s
2 x 2gb’s

I have been ‘on this’. trying to create this shrunk image with a number of different booted OS’s ( all Rasp desktop) using dc3dd in a CLI window.

Yes, correct, saving the dc3dd image to the SD card I am booting from.

It has just occurred to me. My initial copy of the 64gb card is not being done using dc3dd, That would not be possible, creating an image of a 64gb card while booted from a 32, and saving TO the 32.

My initial copy of the 64gb is being done ‘card to card’ using the built in SD CARD COPIER. Booted from any fresh desktop image on one of the spare cards and two other cards in USB-Micro SD adapters. ( the 64gb original and the destination)

I’ll try your method of writing a fresh image, cloning it and writing it back to the same card to see what happens.

But this error as in the thread title DOES NOT STOP an image being written to an SD
This error also DOES NOT STOP the written image from creating a bootable card.

What is happening is the creation process is creating an image that pishrink CANNOT shrink. The erroneous image CAN be written to an SD card and the error then appears on the written card. That written card IS bootable, but the error creates a card that is bootable, but has FS/partition table errors that means GPARTED or ‘parted’ from CLI shows it in error with partition outside the card


In the next few days I’ll zero out all the cards, except my ‘64gb Master’ and try again as it seems repairing the partition table as per the first post and link I put up is something that is maybe not possible. That is really what I think is the answer.

The joke of all this is, the card cloning process was supposed to be saving me time so I’d not need to setup a fresh system to my liking every time I needed a ‘new OS’ Could have created all my cards manually by now ! 😁😁

pcmanbob
Posts: 6618
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Clone and “Error: Can't have a partition outside the disk!”

Wed Jan 16, 2019 1:43 pm


It has just occurred to me. My initial copy of the 64gb card is not being done using dc3dd, That would not be possible, creating an image of a 64gb card while booted from a 32, and saving TO the 32.
Then that's not an image file its an exact copy of your SD card with 2 partitions on it.

pishrink will only work on a image file.

you need to put your 64GB SD card in a pc and make an image file ( for windows I would use windisk32 imager or on Linux dc3dd ) then you will have an image file of the whole SD card.

then you can run pishrink on that, but it will probably have to be on a Linux pc so you have the space for the original 64GB file and the new smaller file.

yes problem solving can some times take longer than the time you hopped the project would save.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Aydan
Posts: 688
Joined: Fri Apr 13, 2012 11:48 am
Location: Germany, near Lake Constance

Re: Clone and “Error: Can't have a partition outside the disk!”

Wed Jan 16, 2019 1:52 pm

I think the original problem is that you 2nd 64GB card is a bit smaller than the original card. This would cause the root partition to "stick over the end" of the cloned card. Running fsck on this partiton on the cloned card should give you an error in this regard.
also check the partition layout with fdisk -l and check that the end sector of the root partition is not larger than the block count of the sd card.

My suggestion:
before you clone the original card, shrink the root partition to e.g. 16GB (e.g. with gparted), and dd only until the end of the second partition.

npaisnel
Posts: 62
Joined: Sun Aug 05, 2018 4:23 pm

Re: Clone and “Error: Can't have a partition outside the disk!”

Wed Jan 16, 2019 2:32 pm

Aydan wrote:
Wed Jan 16, 2019 1:52 pm
I think the original problem is that you 2nd 64GB card is a bit smaller than the original card.
npaisnel wrote:
Wed Jan 16, 2019 8:02 am
I have plenty of spare cards for this. Stock included
64
32
3 x16 ‘s
2 x 8,
4 x 4gb’s
2 x 2gb’s
Sorry, that above from me was meant to be that, that is my complete stock of cards..the 64 gb is not a 'spare' it is the only one.




pcmanbob wrote:
Wed Jan 16, 2019 1:43 pm

It has just occurred to me. My initial copy of the 64gb card is not being done using dc3dd, That would not be possible, creating an image of a 64gb card while booted from a 32, and saving TO the 32.
Then that's not an image file its an exact copy of your SD card with 2 partitions on it.
Ah, terminology ! I called what dc3dd produces an 'Image File' simply because it creates a single file...with the extension .img
It produces a file of type img so I called it an image file



pcmanbob wrote:
Wed Jan 16, 2019 1:43 pm
pishrink will only work on a image file.
I can confidently say your wrong there using your definition of an image file.

Pishrink does work with what I have been calling an image file (an image of the whole disk with both partitions)
I know this because I have been creating dc3dd .img files, pishrinking them, storing them and re -writing them to Micro SD, and bootign from and using them since i started this venture in to the Pi.
It is only this clone of the 64gb Raspbian Desktop this last week that has caused problems.

I will try and get back to this in the next few days. I am scheduled for this bloody operation on my leg on the 24th of this month, so 8 days times, and since I have not been fit to do outdoor work for a few months, I have been unable to do any hedge cutting/ grass mowing, or mechanical repair stuff for 6 months. So the farm I rent is a bit of a mess. Desperately using daylight hours, to catch up a bit before they break my leg again and I am laid up for another few months :(


What i was really hoping is to get help with is how to fix the error , along the lines of this link...

https://gparted.org/h2-fix-msdos-pt.php ... side-disk


Problem is, the table printed usign the command from that link above

Code: Select all

sudo fdisk -l -u /dev/sdb
gives a differetn table structure on the Pi than on that linked example.

As far as I can see, all I need to do to fix this error is manually re -write the partition table to correct it . The difference in the table in the link and that in the Pi is one of the columns in the table printed...Size or Block...

Any way , it is not raining , it is still light, I must get back outside and finish mowing the bottom paddock!

User avatar
rpdom
Posts: 14976
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Clone and “Error: Can't have a partition outside the disk!”

Wed Jan 16, 2019 2:44 pm

npaisnel wrote:
Wed Jan 16, 2019 2:32 pm
mowing the bottom paddock!
There's a euphemism I hadn't heard before. :lol:

pcmanbob
Posts: 6618
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Clone and “Error: Can't have a partition outside the disk!”

Wed Jan 16, 2019 2:52 pm

I can confidently say your wrong there using your definition of an image file.
Image

clearly its an image file filename.img a single file that contains an image of the SD card that has 2 partitions on it fat32 & ext4

When you use win32diskimager or dc3dd to copy your SD card it produces an image file that contains an image of the SD card that has 2 partitions on it fat32 & ext4, so pishrink is able to shrink the image removing unused space.

When you use the raspbian copy feature to copy the SD card you clone the existing SD card on to the new SD card this is not an image file it is an exact copy from one SD card to the other SD card,

the second SD card will contain 2 partitions on it fat32 & ext4, pishrink can't shrink this because there is no file with an img extension on the SD card, it is a bootable fully working SD card.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Aydan
Posts: 688
Joined: Fri Apr 13, 2012 11:48 am
Location: Germany, near Lake Constance

Re: Clone and “Error: Can't have a partition outside the disk!”

Wed Jan 16, 2019 3:07 pm

npaisnel wrote:
Wed Jan 16, 2019 2:32 pm
Aydan wrote:
Wed Jan 16, 2019 1:52 pm
I think the original problem is that you 2nd 64GB card is a bit smaller than the original card.
npaisnel wrote:
Wed Jan 16, 2019 8:02 am
I have plenty of spare cards for this. Stock included
64
32
3 x16 ‘s
2 x 8,
4 x 4gb’s
2 x 2gb’s
Sorry, that above from me was meant to be that, that is my complete stock of cards..the 64 gb is not a 'spare' it is the only one.
Even worse, if you clone a 64GB card onto a 32 GB card, you break the filesystem, because half the blocks allocated to the file system are missing.
It was just pure luck that no blocks of the filesystem were allocated into the second half of the card.
That's why I suggested to resize the root partition before cloning. a resize will reallocate used blocks which are outside the new partition size into the new partition size.
Just rewriting the partition table does not fix your problem.

npaisnel
Posts: 62
Joined: Sun Aug 05, 2018 4:23 pm

Re: Clone and “Error: Can't have a partition outside the disk!”

Wed Jan 16, 2019 3:55 pm

Started raining so tractor mowing has had to stop,

So back to this.
pcmanbob wrote:
Wed Jan 16, 2019 2:52 pm

clearly its an image file filename.img a single file that contains an image of the SD card that has 2 partitions on it fat32 & ext4

When you use win32diskimager or dc3dd to copy your SD card it produces an image file that contains an image of the SD card that has 2 partitions on it fat32 & ext4, so pishrink is able to shrink the image removing unused space.

When you use the raspbian copy feature to copy the SD card you clone the existing SD card on to the new SD card this is not an image file it is an exact copy from one SD card to the other SD card,

the second SD card will contain 2 partitions on it fat32 & ext4, pishrink can't shrink this because there is no file with an img extension on the SD card, it is a bootable fully working SD card.
Yes, fully understand all of that.

I mis understood the previous post of yours to mean that only a file that is an image of a single partition is called an image file. I thought you were then saying that the file produced by dc3dd is not called an image file...which i thought was odd..since it has the img extension.

Anyway , I am not trying to use pishrink directly on a card, i am only trying to use it on .img files.




Yes, I could use GPARTED to shrink the 64gb card to a smaller size and then dc3dd that ...and then pishrinkf. But since that 64gb SD card is my only customised Rasp Desktop SD, I did not want to fuck with it and risk screwing the file system if something should go wrong with the GPARTED partition size change.

So I booted from a clean 8gb card with a fresh rasbpian desktop image on it.
Then using the SD Card copy that is built in to Raspbian Desktop, I cloned the 64gb card to the 32 gb card.
I had previously tried to use the SD Copy program to copy from 64gb straight to a 4gb card...but it would not do it. I guessed it would not do it because it was a too big a card size difference.

So I decided to use the SD copy program to clone for 63 gb to 32 gb card. That worked perfectly and I could boot from the cloned 32.

I then re booted from the 64 Gb card and used dc3dd to copy the 32gb card to an image file.

Yes, I could have used GPARTED to reduce the partition size of the 32, but since my standard (and always working work flow until now) was to use dc3dd and them pishrink I saw no reason to do it a different way. I had also sometimes seen GPARTED refuse to shrink a partition , then slider just grey out and will not allow making the SD card partition smaller, where dc3dd'ing it and pishrinking it alway worked.


Aydan wrote:
Wed Jan 16, 2019 3:07 pm

Just rewriting the partition table does not fix your problem.
Maybe in this case it wont for some reason, but doing that is what is described with this particular error message. “Error: Can't have a partition outside the disk!” in the article below.
Or are you saying that the people that wrote this article https://gparted.org/h2-fix-msdos-pt.php ... tside-disk have got it wrong ?



any way rather than keep talking about it, I'll have another go at it

npaisnel
Posts: 62
Joined: Sun Aug 05, 2018 4:23 pm

Re: Clone and “Error: Can't have a partition outside the disk!”

Wed Jan 16, 2019 4:22 pm

OK, so here we go
Etcher on my Mac to create a new install of Raspbian Desktop on a 16gb card
Updated and upgraded from the GUI
GPARTED installed.
Reboot and check for updates/ upgrades again...all good.

Now insert my 'Master 64gb ' MicroSD (at I want to create an img file of) in to a USB adapter.
Put that in the running Pi
GPARTED sees it , and no errors.

Yes, OK I could just resize the partition ...but i am wary about doing that as a lot offsetting up has done in to building that card and i don't want to risk fucking it

So since I do not want to risk doing that, I want to make a copy of it and i don't have another 64gb card....???

What? use SD Card Copier to copy it to a smaller card?

That is what i was doing before
I'll try this again

so the SD Card Copier is now running...64 gb to an 8gb.
The 64gb card has less than 3gb of data according to GPARTED

nope...wont do it..
Insufficient space. Backup aborted

OK, re booted to the 64 gb and found an image file i had previously created still in my home folder.
Deleted that and now trying a SD Card Copier copy of the 64 down to an 8
Last edited by npaisnel on Wed Jan 16, 2019 4:36 pm, edited 1 time in total.

Aydan
Posts: 688
Joined: Fri Apr 13, 2012 11:48 am
Location: Germany, near Lake Constance

Re: Clone and “Error: Can't have a partition outside the disk!”

Wed Jan 16, 2019 4:28 pm

Just to clarify:
what is the filesystem size of your original SD card? (df -h)
If that is bigger than what fits on your new sd card, then you have to resize at least the file system before cloning.

fixing the partition table will not magically fix/resize your broken filesystem.

npaisnel
Posts: 62
Joined: Sun Aug 05, 2018 4:23 pm

Re: Clone and “Error: Can't have a partition outside the disk!”

Wed Jan 16, 2019 4:38 pm

Aydan wrote:
Wed Jan 16, 2019 4:28 pm
Just to clarify:
what is the filesystem size of your original SD card? (df -h)
If that is bigger than what fits on your new sd card, then you have to resize at least the file system before cloning.

fixing the partition table will not magically fix/resize your broken filesystem.
No idea...what ever it was by default when Etcher wrote the original Raspbian Desptop image to the 64Gb card.


I thought SD Card Copier was supposed to deal with all that when copying to a smaller card?

npaisnel
Posts: 62
Joined: Sun Aug 05, 2018 4:23 pm

Re: Clone and “Error: Can't have a partition outside the disk!”

Wed Jan 16, 2019 5:03 pm

OK, so the SD Card Copier worked fine ..no errors
the 64GB card copied to the 8gb card.

i can boot from the 8gb card and it works correctly.

But boot back to the original 64gb card and examine the 8gb card (that SD Card Copier created ) in GPARTED and this is the result

SD Copier error.jpg
SD Copier error.jpg (135.82 KiB) Viewed 1192 times

So my issue is stemming from the fact that SD Card Copier is not doing its job correctly and copying/cloning to a smaller card
Last edited by npaisnel on Wed Jan 16, 2019 5:08 pm, edited 1 time in total.

npaisnel
Posts: 62
Joined: Sun Aug 05, 2018 4:23 pm

Re: Clone and “Error: Can't have a partition outside the disk!”

Wed Jan 16, 2019 5:07 pm

gparted.jpg
gparted.jpg (70.6 KiB) Viewed 1186 times
error.jpg
error.jpg (68.61 KiB) Viewed 1186 times

npaisnel
Posts: 62
Joined: Sun Aug 05, 2018 4:23 pm

Re: Clone and “Error: Can't have a partition outside the disk!”

Wed Jan 16, 2019 5:11 pm

Aydan wrote:
Wed Jan 16, 2019 4:28 pm
Just to clarify:
what is the filesystem size of your original SD card? (df -h)

Code: Select all

pi@raspgui:~ $ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2        59G  2.7G   53G   5% /
devtmpfs        460M     0  460M   0% /dev
tmpfs           464M     0  464M   0% /dev/shm
tmpfs           464M   13M  452M   3% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           464M     0  464M   0% /sys/fs/cgroup
/dev/sda1        44M   23M   21M  52% /boot
tmpfs            93M     0   93M   0% /run/user/1000
pi@raspgui:~ $ 
This is what the SD Card Copier then creates

Code: Select all

pi@raspgui:~ $ sudo fdisk -l -u /dev/sda
Disk /dev/sda: 7.4 GiB, 7969177600 bytes, 15564800 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: 0xfde85379

Device     Boot Start      End  Sectors  Size Id Type
/dev/sda1        8192    96663    88472 43.2M  e W95 FAT16 (LBA)
/dev/sda2       98304 15564798 15466495  7.4G 83 Linux
Last edited by npaisnel on Wed Jan 16, 2019 5:18 pm, edited 1 time in total.

Return to “Troubleshooting”