Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Limiting the capacity of SD cards for the pi

77 views
Skip to first unread message

The Natural Philosopher

unread,
Sep 17, 2023, 5:11:39 AM9/17/23
to
On 17/09/2023 09:58, Bob Latham wrote:
> Hi,
>
> I build images for projects on 4GB cards so that I can save a
> completed image without using too much disc space. My problem comes
> when I try to burn a new card from the saved image. Often it will not
> fit because there are small differences in the size of the cards.
>
> Does anyone know of a way to reduce the capacity of an SD card so
> that I can make a 4GB card maybe 3.5GB which would mean all cards
> could easily manage it and reduce the size of the save image.
>
>
https://superuser.com/questions/610819/how-to-resize-img-file-created-with-dd

has a long and detailed description of how to do this...

...basically 'parted' to shrink the partitions and 'truncate' to shrink
the dd'ed image.

I have no idea if this method works, as I have never tried it

Another method cited that again I have no experience of is Pishrink -
https://github.com/Drewsif/Pishrink

This looks at a cursory glance to be a script that automates the process.

Let me know if this works as I will need a similar script in due course

> Thanks.
>
> Bob.
>

--
"The great thing about Glasgow is that if there's a nuclear attack it'll
look exactly the same afterwards."

Billy Connolly

The Natural Philosopher

unread,
Sep 17, 2023, 6:16:11 AM9/17/23
to
On 17/09/2023 10:58, Bob Latham wrote:
> In article <ue6fs9$ad15$1...@dont-email.me>,
> The Natural Philosopher <t...@invalid.invalid> wrote:
>> On 17/09/2023 09:58, Bob Latham wrote:
>
>>> Does anyone know of a way to reduce the capacity of an SD card so
>>> that I can make a 4GB card maybe 3.5GB which would mean all cards
>>> could easily manage it and reduce the size of the save image.
>>>
>
>> https://superuser.com/questions/610819/how-to-resize-img-file-created-with-dd
>
>> has a long and detailed description of how to do this...
>
>> ...basically 'parted' to shrink the partitions and 'truncate' to
>> shrink the dd'ed image.
>
>> I have no idea if this method works, as I have never tried it
>
>> Another method cited that again I have no experience of is
>> Pishrink - https://github.com/Drewsif/Pishrink
>
>> This looks at a cursory glance to be a script that automates the
>> process.
>
>> Let me know if this works as I will need a similar script in due
>> course
>
> Much appreciate your help, thanks.
>
> Unfortunately, my knowledge is not great and both of those articles
> very quickly went way passed my understanding.
>
> I *think* they both assume I have a linux pc, I don't, I have a W10
> PC.
>

Ah. I never thought of that. You could install Linux in a virtual machine.


> For another project I recently looked at getting linux to run virtual
> on my PC but again I quickly ran out of knowledge and couldn't do it.
>
Oh. Mm.
Its non trivial getting virtualBox set up if you are not especially
technical.

HOWEVER you should be able to get a live Linux working by installing it
on a DVD or USB stick and booting from that.

Or installing Linux on some old piece of hardware left over from the
Resurrection and the Roman Empire...

> Articles mostly assume far more knowledge than I have.
>

Tell me about it.

> I was hoping to simply reduce the size of the SD card before it was
> even formatted. Maybe that's not possible.
>
Well I don't think you can do THAT. What you need is an installation on
e.g. a 2GB card that can never exceed the size of the 4GB target.

Frankly why not bite the bullet and install 4GB images onto 8/16GB SD
cards as these are as cheap as 4GB these days?


> Thanks anyway.
>
> Bob.
>

--
I was brought up to believe that you should never give offence if you
can avoid it; the new culture tells us you should always take offence if
you can. There are now experts in the art of taking offence, indeed
whole academic subjects, such as 'gender studies', devoted to it.

Sir Roger Scruton

Ian

unread,
Sep 17, 2023, 7:48:37 AM9/17/23
to
On 2023-09-17, Bob Latham <b...@sick-of-spam.invalid> wrote:

> I build images for projects on 4GB cards so that I can save a
> completed image without using too much disc space. My problem comes
> when I try to burn a new card from the saved image. Often it will not
> fit because there are small differences in the size of the cards.
>
> Does anyone know of a way to reduce the capacity of an SD card so
> that I can make a 4GB card maybe 3.5GB which would mean all cards
> could easily manage it and reduce the size of the save image.

As it happens, I've just had to do that to reduce a 16GB image on a 32GB
SD card to < 8GB. I did it just using a Pi and a USB SDcard adapter, old
school style.

All as root on the Pi:

1. Clone the SD card you're trying to shrink (using dd, Win32DiskImager
or whatever you normally use to read/write SD card images), just
in case.

2. Insert the cloned SD card into the USB SDcard adapter connected to
a Pi. It should appear as /dev/sdc or somesuch (dmesg should show
it being picked up). I'll assume /dev/sdc for this.

3. Mount the OS partition (second one) on the local Pi:

# mkdir /mnt/x
# mount /dev/sd2 /mnt/x

4. Tar up the OS partition to the local Pi. Note this assumes there's
plenty of free space on the Pi filesystem!

# cd /mnt/x
# tar -czf ~/xxx.tar.gz .

5. Unmount the OS parition:

# cd
# umount /mnt/x

6. Use fdisk to delete and recreate the second partition (ONLY!) on
the SDC card:

# fdisk /dev/sdc

p ## shows current partiton table, mine looked like this:

Disk /dev/sdc: 29.7 GiB, 31914983424 bytes, 62333952 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: 0xd9b3f436

Device Boot Start End Sectors Size Id Type
/dev/sdc1 8192 532479 524288 256M c W95 FAT32 (LBA)
/dev/sdc2 532480 31116287 30583808 14.6G 83 Linux


(still in fdisk):

d ## Delete second partition
2

n
p
2
532480 ## original start sector of the second partition from above
+7G ## Or however big you want it to be
y ## Wipe filesystem signature

p ## Check it looks right:

Disk /dev/sdc: 29.7 GiB, 31914983424 bytes, 62333952 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: 0xd9b3f436

Device Boot Start End Sectors Size Id Type
/dev/sdc1 8192 532479 524288 256M c W95 FAT32 (LBA)
/dev/sdc2 532480 15212543 14680064 7G 83 Linux

w ## Do it

7. Create filesyetem in new partition:

# mkfs -t ext4 /dev/sdc2

8. Mount the new (empty) partition:

# mount /dev/sd2 /mnt/x

9. Restore the OS files into it:

# cd /mnt/x
# tar -xzf ~/xxx.tar.gz

10. Unmount it:

# cd
# umount /mnt/x

11. Now you can create an image file of the reduced boot and OS partitions
that can be written to a smaller SD card. To do this I have a short script
that computes the size in MB from the last sector field of the fdisk
output (messy but it seems to work). Again you'll need plenty of space
wherever you want to put the new image:

# last_sector=$(echo "p" | fdisk /dev/sdc | awk '/^\/dev\/sdc/ { print $3 }' | sort -n | tail -1)
# n_bytes="$(((last_sector+1)*512))"
# n_mb="$(((n_bytes-1)/1048576+1))"
# check="$((n_mb*1048576/512))"
# echo "Last sector: ${last_sector}, ${n_mb} MB, writing ${check} sectors..."

# dd if=/dev/sdc bs=1048576 count=${n_mb} | gzip > ~/newcard.img.gz


(E&OE)


Don't forget to delete the temporary tarfile.



--
Ian

"Tamahome!!!" - "Miaka!!!"

The Natural Philosopher

unread,
Sep 17, 2023, 7:50:24 AM9/17/23
to
On 17/09/2023 12:28, Bob Latham wrote:
> In article <ue6jl8$aull$1...@dont-email.me>,
> The Natural Philosopher <t...@invalid.invalid> wrote:
>> On 17/09/2023 10:58, Bob Latham wrote:
>>> In article <ue6fs9$ad15$1...@dont-email.me>,
>>> The Natural Philosopher <t...@invalid.invalid> wrote:
>>>> On 17/09/2023 09:58, Bob Latham wrote:
>
>>> I *think* they both assume I have a linux pc, I don't, I have a
>>> W10 PC.
>
>> Ah. I never thought of that. You could install Linux in a virtual
>> machine.
>
>>> For another project I recently looked at getting linux to run
>>> virtual on my PC but again I quickly ran out of knowledge and
>>> couldn't do it.
>>>
>> Oh. Mm. Its non trivial getting virtualBox set up if you are not
>> especially technical.
>
>> HOWEVER you should be able to get a live Linux working by
>> installing it on a DVD or USB stick and booting from that.
>
> Oh yes, I remember doing that many years ago, so it's still possible.
> I might give that a go.
>
>> Or installing Linux on some old piece of hardware left over from
>> the Resurrection and the Roman Empire...
>
>>> Articles mostly assume far more knowledge than I have.
>
>> Tell me about it.
>
>>> I was hoping to simply reduce the size of the SD card before it
>>> was even formatted. Maybe that's not possible.
>>>
>> Well I don't think you can do THAT. What you need is an
>> installation on e.g. a 2GB card that can never exceed the size of
>> the 4GB target.
>
>> Frankly why not bite the bullet and install 4GB images onto 8/16GB
>> SD cards as these are as cheap as 4GB these days?
>
> That's *exactly* what I am doing and then expanding to fill on the
> 16GB card.
>
> I'm hitting the size problem only because I save a build in stages.
> 1) OS up and running.
> 2) OS + samba running.
> 3) Apache or mpd ... running
> 4) Pihole or MediaPlayer Running.
>
> By doing that, if I'm testing beta versions of say media player then
> I don't need to build from scratch.
>
> But if when i'm building I don't use the smallest 4GB I have and
> build something slightly bigger it will not go on a smaller 4GB card
> later for the next test.
>
> Bob.
>
You could do what I have been half doing, and build a script that turns
a raw installation into my customised one.


--
If you tell a lie big enough and keep repeating it, people will
eventually come to believe it. The lie can be maintained only for such
time as the State can shield the people from the political, economic
and/or military consequences of the lie. It thus becomes vitally
important for the State to use all of its powers to repress dissent, for
the truth is the mortal enemy of the lie, and thus by extension, the
truth is the greatest enemy of the State.

Joseph Goebbels




The Natural Philosopher

unread,
Sep 17, 2023, 10:40:36 AM9/17/23
to
On 17/09/2023 15:18, Bob Latham wrote:
> In article
> <slrnugdpsj.vum.${send-direct-email-to-new...@vm46.home.jusme.com>,
> Ian
> <${send-direct-email-to-news1021-at-jusme-dot-com-if-you-must}@jusme.com> wrote:
>
>> 1. Clone the SD card you're trying to shrink (using dd,
>> Win32DiskImager or whatever you normally use to read/write SD
>> card images), just in case.
>
> Yes. Done.
>
>> 2. Insert the cloned SD card into the USB SDcard adapter connected
>> to a Pi.
>
> Yes.

That is a second SD card adapter plugged into the Pis USB port

>
>> It should appear as /dev/sdc or somesuch (dmesg should
>> show it being picked up).
>
> So sorry, I've no idea how I would see that? I was logged in to the
> pi via putty before I plugged the device in but nothing appeared.
>
OK, 'sudo mount' would show what it was and where it was..


> I'm only using a headless light version of the pios, is that my
> problem or is it just ignorance?
>
Just ignorance, but its not hard to get there.


In linux all disks systems look like *files* in the directory /dev/
The dir command in linux is 'ls' so :

'ls /dev' should show your disk in there somewhere
The SD card you are running on will be /dev/mmcblk0 and its two partitions
/dev/mmcblk0p1 and /dev/mmcblk0p2. These will be 'mounted' on /boot,
and /

mount | grep mm

is a command uou cvan use to see where they are mounted - the '| grep
mm' means 'select only lines from the output containing 'mm'
e.g.

$mount | grep mm
/dev/mmcblk0p2 on / type ext4 (rw,noatime)
/dev/mmcblk0p1 on /boot type vfat
(rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)

Now if you plug another SD card into the system via a USB SD card reader
that should be automatically mounted somewhere.

My guess would be in a media subdirectory of your home directory.

so

$mount | grep media
should tell you what it is called.

In Linux it is conventional that the whole disk will be files as
/dev/something, and partitions on it will be
/dev/somethinga or
/dev/somethingb or
/dev/somethingp1

etc...

These are all the *device names*you will need in order to manipulate the
partitions and the raw SD card




>
> Thanks.
>
> Bob.
>

--
“A leader is best When people barely know he exists. Of a good leader,
who talks little,When his work is done, his aim fulfilled,They will say,
“We did this ourselves.”

― Lao Tzu, Tao Te Ching

Mrtn

unread,
Sep 17, 2023, 10:45:11 AM9/17/23
to
Bob Latham <b...@sick-of-spam.invalid> writes:

> In article
> <slrnugdpsj.vum.${send-direct-email-to-new...@vm46.home.jusme.com>,
> Ian
> <${send-direct-email-to-news1021-at-jusme-dot-com-if-you-must}@jusme.com> wrote:
<cut>
>> It should appear as /dev/sdc or somesuch (dmesg should
>> show it being picked up).
>
> So sorry, I've no idea how I would see that? I was logged in to the
> pi via putty before I plugged the device in but nothing appeared.

In putty try typing:
dmesg
(and hit enter)
or
sudo dmesg
(and hit enter)
if you're not logged in as root.

Ian

unread,
Sep 17, 2023, 10:57:42 AM9/17/23
to
Yes, that's about it. I see this from dmesg after the SD card is inserted:

[ 4259.125974] usb-storage 1-1.1.3:1.0: USB Mass Storage device detected
[ 4259.127272] scsi host0: usb-storage 1-1.1.3:1.0
[ 4260.181673] scsi 0:0:0:0: Direct-Access Generic STORAGE DEVICE 9325 PQ: 0 ANSI: 0
[ 4260.183483] scsi 0:0:0:1: Direct-Access Generic STORAGE DEVICE 9325 PQ: 0 ANSI: 0
[ 4260.185400] scsi 0:0:0:2: Direct-Access Generic STORAGE DEVICE 9325 PQ: 0 ANSI: 0
[ 4260.187328] scsi 0:0:0:3: Direct-Access Generic STORAGE DEVICE 9325 PQ: 0 ANSI: 0
[ 4260.223150] sd 0:0:0:2: [sdc] Attached SCSI removable disk
[ 4260.224466] sd 0:0:0:0: [sda] Attached SCSI removable disk
[ 4260.227173] sd 0:0:0:3: [sdd] Attached SCSI removable disk
[ 4260.232037] sd 0:0:0:1: [sdb] Attached SCSI removable disk
[ 4346.699670] sd 0:0:0:2: [sdc] 62333952 512-byte logical blocks: (31.9 GB/29.7 GiB)
[ 4346.707646] sdc: sdc1 sdc2
[ 4346.720048] sdc: sdc1 sdc2


If you're running any kind of desktop environment that may get in the way and mount the SD
card in odd places, though if you're running a minimal system that shouldn't be an issue.

All the commands are standard Linux ones, so should be present.

I suggest you do "sudo bash" if you're not logging in as root, makes things simpler :)

The Natural Philosopher

unread,
Sep 17, 2023, 11:46:49 AM9/17/23
to
On 17/09/2023 16:17, Bob Latham wrote:
> In article <ue7352$dmc3$1...@dont-email.me>,
> The Natural Philosopher <t...@invalid.invalid> wrote:
>> On 17/09/2023 15:18, Bob Latham wrote:
>>> In article
>>> <slrnugdpsj.vum.${send-direct-email-to-new...@vm46.home.jusme.com>,
>>> Ian
>>> <${send-direct-email-to-news1021-at-jusme-dot-com-if-you-must}@jusme.com> wrote:
>>>
>>>> 1. Clone the SD card you're trying to shrink (using dd,
>>>> Win32DiskImager or whatever you normally use to read/write
>>>> SD card images), just in case.
>>>
>>> Yes. Done.
>>>
>>>> 2. Insert the cloned SD card into the USB SDcard adapter
>>>> connected to a Pi.
>>>
>>> Yes.
>
>> That is a second SD card adapter plugged into the Pis USB port
>
> Yes it is.
>
>
>>>> It should appear as /dev/sdc or somesuch (dmesg should show
>>>> it being picked up).
>>>
>>> So sorry, I've no idea how I would see that? I was logged in to
>>> the pi via putty before I plugged the device in but nothing
>>> appeared.
>>>
>> OK, 'sudo mount' would show what it was and where it was..
>
> sudo mount gives me a half a page of text no meaning to me.
>
> But after some googling I did find the command :
>
> lsblk
>
> That shows this...
>
> NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
> sda 8:0 1 3.6G 0 disk
> +-sda1 8:1 1 256M 0 part
> +-sda2 8:2 1 3.4G 0 part
> mmcblk0 179:0 0 14.8G 0 disk
> +-mmcblk0p1 179:1 0 256M 0 part /boot
> +-mmcblk0p2 179:2 0 14.6G 0 part /
>
> Despite one website telling me that sda would be the machines hard
> disc I worked out that it wasn't. sda is the sd inserted via usb.
> mmcblk0 is the harddrive.
>

This is a Pi. It likes to be different

> So I tried to go a bit further...
>
> mkdir /mnt/x
> gave Permission denied.
> sudo mkdir /mnt/x
> sudo mount /dev/sda2 /mnt/x
> cd /mnt/x
> all the above seemed to work.
>
> tar -czf ~/xxx.tar.gz
> gave
> Cowardly refusing to create an empty archive.
>
> I thought maybe I was supposed to substitute some items in that
> command.
>
yes.

man tar will tell you te tar commands,.

I think what you want is tar cfz <directory> <output file>

But a GUI has mane me lazy and I cant remember

>
>>> I'm only using a headless light version of the pios, is that my
>>> problem or is it just ignorance?
>>>
>> Just ignorance, but its not hard to get there.
>
> Thanks for the help it is appreciated.
>
>
>> In linux all disks systems look like *files* in the directory /dev/
>> The dir command in linux is 'ls' so :
>
>> 'ls /dev' should show your disk in there somewhere The SD card you
>> are running on will be /dev/mmcblk0 and its two partitions
>> /dev/mmcblk0p1 and /dev/mmcblk0p2.
>
> That looks correct.
>
>> These will be 'mounted' on /boot, and /
>
>> mount | grep mm
>
>> is a command uou cvan use to see where they are mounted - the '|
>> grep mm' means 'select only lines from the output containing 'mm'
>> e.g.
>
> That's clever: :-)
>
>> $mount | grep mm /dev/mmcblk0p2 on / type ext4 (rw,noatime)
>> /dev/mmcblk0p1 on /boot type vfat
>> (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)
>
>> Now if you plug another SD card into the system via a USB SD card
>> reader that should be automatically mounted somewhere.
>
>> My guess would be in a media subdirectory of your home directory.
>
>> so
>
>> $mount | grep media should tell you what it is called.
>
> That doesn't come back with anything, no error, nothing.
>
So its miunted somwheer else.
>> In Linux it is conventional that the whole disk will be files as
>> /dev/something, and partitions on it will be /dev/somethinga or
>> /dev/somethingb or /dev/somethingp1
>
>> etc...
>
>> These are all the *device names*you will need in order to
>> manipulate the partitions and the raw SD card
>
> Thanks for that, I'm learning, slowly.
>
> I think the usb device sd is /dev/sda with the main partition
> /dev/sda2 does that sound correct?

Yes. If its a PI card /dev/sda1 will be the thing that ends up as /boot
- which is a msdos partioned thing. VFAT I think


"mount | grep sda" will tell you where they ended up.

--
Climate is what you expect but weather is what you get.
Mark Twain

Ian

unread,
Sep 17, 2023, 12:57:28 PM9/17/23
to
On 2023-09-17, Bob Latham <b...@sick-of-spam.invalid> wrote:

>> > tar -czf ~/xxx.tar.gz
>> > gave
>> > Cowardly refusing to create an empty archive.
>> >
>> > I thought maybe I was supposed to substitute some items in that
>> > command.

Nothing needs substituting, you're just missing the "." as the final parameter:

> # tar -czf ~/xxx.tar.gz .

(That says what to put in the tarball, "." means the current directory)

Mrtn

unread,
Sep 17, 2023, 1:11:46 PM9/17/23
to
Bob Latham <b...@sick-of-spam.invalid> writes:

> In article <87wmwoc...@no-email.invalid>,
> Mrtn <mr...@no-email.invalid> wrote:
>> Bob Latham <b...@sick-of-spam.invalid> writes:
>
>> > In article
>> > <slrnugdpsj.vum.${send-direct-email-to-new...@vm46.home.jusme.com>,
>> > Ian
>> > <${send-direct-email-to-news1021-at-jusme-dot-com-if-you-must}@jusme.com>
>> > wrote:
>> <cut>
>> >> It should appear as /dev/sdc or somesuch (dmesg should
>> >> show it being picked up).
>> >
>> > So sorry, I've no idea how I would see that? I was logged in to the
>> > pi via putty before I plugged the device in but nothing appeared.
>
>> In putty try typing:
>> dmesg
<cut>
>
> That gave me a huge list of text but I'm not sure where that helps me.

You already solved the problem, so it is no longer useful. You already
discovered that your USB device is /dev/sda.

However, as someone already hinted before me, typing dmesg in putty
should tell you that, if you type it just after inserting the USB in the
port.

Since the horse already left the stable, you can put all this in the
afterburner.

Ian

unread,
Sep 17, 2023, 2:22:01 PM9/17/23
to
On 2023-09-17, Bob Latham <b...@sick-of-spam.invalid> wrote:

> I'll have another go tomorrow.

Good luck!

Be sure to do it all from a root shell, not via individual sudo
calls btw, some of the commands need to be in the same shell as
previous ones, and sudo breaks that.

Martin Gregorie

unread,
Sep 17, 2023, 6:55:00 PM9/17/23
to
Now you know how to mount a disk, you need to know how to find Linux
commands that can help you do what you want to do with the RPi. For the
rest of this info to work, you need to know how to login as the default
user AND how to log in as root:

1 the 'man name' command shows you a page (which can be very long) that
tells you what 'name' does and how to use it, Name can be anything
from a command to a Linux system call or function.

2 the "apropos 'text' command shows you a list of commands whose manual
pages have 'text' in their first line of their manual pages.

3 Using the 'apropos' and 'man' commands is the fastest way I know of of
finding a standard issue Linux program that will do what you need it to
do and finding out how to use it,

4 If you like reading books rather than screens, consider getting a copy
of "UNIX in a Nutshell" or "Linux in a Nutshell" - both are concise
references to the way UNIX/Linux works and how to use it.

There's also "Unix Systems Programming for SVR4" which, although quite
old now, is still a useful guide to writing programs and applications
in C.

Computer Nerd Kev

unread,
Sep 17, 2023, 7:08:01 PM9/17/23
to
Bob Latham <b...@sick-of-spam.invalid> wrote:
> Hi,
>
> I build images for projects on 4GB cards so that I can save a
> completed image without using too much disc space. My problem comes
> when I try to burn a new card from the saved image. Often it will not
> fit because there are small differences in the size of the cards.
>
> Does anyone know of a way to reduce the capacity of an SD card so
> that I can make a 4GB card maybe 3.5GB which would mean all cards
> could easily manage it and reduce the size of the save image.

Using Tar as suggested is one option. If you still want to use raw
image files where the partitioning is already done for you, then
what I've done for that is create a blank disk image file of the
size I want (using dd reading from /dev/zero), then partition that
and copy over the system files before writing that image to a real
SD card.

I've also had success with simply creating a partition table with
blank space at the end of an SD card. If you just copy over as much
data as will fit on the smaller SD card, it should still work if
the partitions had all ended before the space ran out. Resizing
the last partition on the existing card should work too (make a
backup first). But doing the work on a file instead of a real card
is probably safer and less confusing. Faster too, especially if
you create it in /tmp so the write operations all happen in RAM,
provided you have enough.

--
__ __
#_ < |\| |< _#

R.Wieser

unread,
Sep 18, 2023, 2:42:57 AM9/18/23
to
Computer Nerd Kev (and others),

> I've also had success with simply creating a partition table
> with blank space at the end of an SD card.

I've got the same problem as the OP, and also thought of the above as the
simpelest solution to the problem.

Question : I'm using an OS image (bullseye, bullseye lite) as can be
downloaded here :

https://www.raspberrypi.com/software/operating-systems/

Is there a possibility to edit it in such a way that it will automatically
reserve some space (dummy partition or otherwise) at the end of the SD card
?

Regards,
Rudy Wieser


Ian

unread,
Sep 18, 2023, 4:29:53 AM9/18/23
to
On 2023-09-17, Bob Latham <b...@sick-of-spam.invalid> wrote:
> Oh dear. I have zero understanding of that. I'm not going to manage
> this am I?

If you follow the instructions exactly, and it all works (!), you should
be able to manage it. If things are different for your setup (quite
likely, unfortunately), then some understanding will be needed to figure
out how to keep on track...


>> Be sure to do it all from a root shell, not via individual sudo
>> calls btw, some of the commands need to be in the same shell as
>> previous ones, and sudo breaks that.

If you log in to the pi as "pi", then issue commands prefixed with "sudo"
so they run as root (administrator), each command runs in its own "shell",
which terminates when the command completes. This means the effects of
some commands don't persist from one call to another, e.g.:

$ sudo pwd
/home/ian

$ sudo cd /tmp

$ sudo pwd
/home/ian ## pwd not changed!


If you log in as "root", or get a root shell by calling "sudo bash",
things work as expected:

$ sudo bash

# pwd
/home/ian

# cd /tmp

# pwd
/tmp


(Note the convention of using "$" to indicate commands that are executed
as a normal user, and '#' for those executed as root. On sane systems,
this reflects the shell prompt).

The Natural Philosopher

unread,
Sep 18, 2023, 5:15:40 AM9/18/23
to
On 17/09/2023 18:11, Mrtn wrote:
> Since the horse already left the stable, you can put all this in the
> afterburner.

What a wonderful mixed metaphor..
I smell a rat.
I feel it in the air.
We must nip it in the bud...
--
It’s easier to fool people than to convince them that they have been fooled.
Mark Twain



The Natural Philosopher

unread,
Sep 18, 2023, 5:22:33 AM9/18/23
to
On 17/09/2023 21:02, Bob Latham wrote:
> In article
> <slrnugegu8.vum.${send-direct-email-to-new...@vm46.home.jusme.com>,
>> On 2023-09-17, Bob Latham <b...@sick-of-spam.invalid> wrote:
>
>>> I'll have another go tomorrow.
>
>> Good luck!
>
>> Be sure to do it all from a root shell, not via individual sudo
>> calls btw, some of the commands need to be in the same shell as
>> previous ones, and sudo breaks that.
>
> Oh dear. I have zero understanding of that. I'm not going to manage
> this am I?
>
> Bob.
>

Yes you are. One step at a time.

There is a super user account that can do everything. It's called root.
There are two easy ways you can get to 'be root'

One is 'sudo bash', and the other is 'su -'

Both will ask for a password - in the first case it will be yours, in
the second case it will be root's.

Root doesn't come with a password set by default, so the first thing you
need to do is to give it one...

'sudo passwd' will ask for YOUR password, then ask you to type in one
for root, twice. To make sure of whatever.

Then 'su - ' will work, every time.

One of the first things I do is set a root password, because I hate
using sudo when I have a lot of configuration work to do.

Chris Elvidge

unread,
Sep 18, 2023, 5:28:10 AM9/18/23
to
On 18/09/2023 10:22, The Natural Philosopher wrote:
> On 17/09/2023 21:02, Bob Latham wrote:
>> In article
>> <slrnugegu8.vum.${send-direct-email-to-new...@vm46.home.jusme.com>,
>>
>> Ian
>> <${send-direct-email-to-news1021-at-jusme-dot-com-if-you-must}@jusme.com>
>> wrote:
>>> On 2023-09-17, Bob Latham <b...@sick-of-spam.invalid> wrote:
>>
>>>> I'll have another go tomorrow.
>>
>>> Good luck!
>>
>>> Be sure to do it all from a root shell, not via individual sudo
>>> calls btw, some of the commands need to be in the same shell as
>>> previous ones, and sudo breaks that.
>>
>> Oh dear. I have zero understanding of that. I'm not going to manage
>> this am I?
>>
>> Bob.
>>
>
> Yes you are. One step at a time.
>
> There is a super user account that can do everything. It's called root.
> There are two easy ways you can get to 'be root'
>
> One is 'sudo bash', and the other is 'su -'

'sudo -i' always works for me.

>
> Both will ask for a password - in the first case it will be yours, in
> the second case it will be root's.
>
> Root doesn't come with a password set by default, so the first thing you
> need to do is to give it one...
>
> 'sudo passwd' will ask for YOUR password, then ask you to type in one
> for root, twice. To make sure of whatever.
>
> Then 'su - ' will work, every time.
>
> One of the first things I do is set a root password, because I hate
> using sudo when I have a lot of configuration work to do.
>
>



--
Chris Elvidge, England
FIVE DAYS IS NOT TOO LONG TO WAIT FOR A GUN

The Natural Philosopher

unread,
Sep 18, 2023, 5:46:27 AM9/18/23
to
On 17/09/2023 23:54, Martin Gregorie wrote:
> Using the 'apropos' and 'man' commands is the fastest way I know of of
> finding a standard issue Linux program that will do what you need it to
> do and finding out how to use it,

I would argue it is the slowest.

It's like reading the whole workshop manual of your new car to find out
where the button is to open the fuel flap.

One of the worst features of both Unix and Linux has always been
documentation

The first time we got a SUN server equipped with system V unix, and
discovered that LPR had gone, and we have no way to make it print to its
parallel port, was such a nightmare for the company that I drove into
town at lunchtime, and went to the university bookstore and paid £55 for
a book on SUNS unix V, because it had one line of about 300 characters
in it which was 'how you enable printing on a system V Unix parallel port'

Today we have CUPS which hides all the ugliness. Just like we have
window managers to hide all the ugliness of X windows.

These days I never use man at all. If I can't remember the command
syntax I google it and chances are someone else has documented a crib
that does what I need it to do.

Like I ripped a CD onto my server and all the song title filenames came
with underscores instead of spaces.

Try invoking 'apropos spaces' .

But googling 'change underscores to spaces in linux file names' got me
three lines of bash that simply WORKED

The problem is 'man' tells you how the command works in enough detail to
warrant suicide.

It doesn't tell you whether or not the command will, in the end perform
the task you want.

Like my problem was how to get my Pi to look like an ethernet device
when plugged into a host computer, set that interface to a static
address and then issue DHCP data to the host computer.

It is not immediately obvious that 'dnsmasq' has anything to do with
DHCP at all, or that on a Pi you have to add a magic spell to a file in
the boot partition to enable the 'I am really an ethernet device' option.

The great thing about the web is that someone somewhere has most
probably done it all before, and if they haven't, and you have to puzzle
it out, then documenting it yourself is a kind thing to do for the next
poor sucker.

The greatest frustration I had working with Apple OS/X was that no one
documented anything. The attitude was 'reinstall OS/X. If it doesn't
work then it cant be done'

Linux and unix documentation has always been command based rather than
task based. And unless you have someone in your company who reads
through and memorises every single command and its syntax, knowing which
command to use is always the problem before you even get to work out the
syntax.




--
“I know that most men, including those at ease with problems of the
greatest complexity, can seldom accept even the simplest and most
obvious truth if it be such as would oblige them to admit the falsity of
conclusions which they have delighted in explaining to colleagues, which
they have proudly taught to others, and which they have woven, thread by
thread, into the fabric of their lives.”

― Leo Tolstoy

The Natural Philosopher

unread,
Sep 18, 2023, 5:54:10 AM9/18/23
to
On 18/09/2023 08:50, Bob Latham wrote:
> In article <ue8042$il0u$1...@dont-email.me>,
> Thank you for that information. Scary stuff. I've done what I've done
> so far by googling for answers and a little experimenting. I'm
> neither clever nor an academic.
>
> I wanted to learn how to write code for tcpip comms for another
> platform, I was advised to get a book called "Unix Network
> Programming". It's a thick book and cost a lot of money. I got to
> about page 3 before I was out of my depth and beyond rescue. That's
> why I have not got any linux books.
>

LOL. Don't ever pick up a book on Philosophy. I think it was
Wittgenstein who said 'If you have not bought a book on philosophy, got
as far as page 3, and then immediately thrown it into a corner of the
room. you have no aptitude for philosophy'

I too have ceased buying Unix and linux books - the Web is by far the
quickest way, or asking here.

In general you can learn far more my grabbing 'a simple TCP/IP client
for Linux' as source code, compiling and debugging it than a dozen books
will teach you.

Just keep muddling along and be grateful that these days you can buy a
fully operational multi user multitasking computer that will run a full
linux distro for £15 when back in the day it was nearer £15,000...

--
Karl Marx said religion is the opium of the people.
But Marxism is the crack cocaine.

Pancho

unread,
Sep 18, 2023, 6:05:39 AM9/18/23
to
On 18/09/2023 10:54, The Natural Philosopher wrote:

>
> LOL. Don't ever pick up a book on Philosophy. I think it was
> Wittgenstein who said 'If you have not bought a book on philosophy, got
> as far as page 3, and then immediately thrown it into a corner of the
> room. you have no aptitude for philosophy'
>
> I too have ceased buying Unix and linux books - the Web is by far the
> quickest way, or asking here.
>
> In general you can learn far more my grabbing 'a simple TCP/IP client
> for Linux' as source code, compiling and debugging it than a dozen books
> will teach you.
>
> Just keep muddling along and be grateful that these days you can buy a
> fully operational multi user multitasking computer that will run a full
> linux distro for £15 when back in the day it was nearer £15,000...
>

It was never £15,000. Back in 1992 a reasonable PC cost about £2000.

Prior to Linux, late 80s, Xenix ran impressively on a 386. The writing
was on the wall for minis.

The Natural Philosopher

unread,
Sep 18, 2023, 6:06:50 AM9/18/23
to
On 18/09/2023 09:00, Bob Latham wrote:
> In article <6507...@news.ausics.net>,
> Computer Nerd Kev <n...@telling.you.invalid> wrote:
>
>> Using Tar as suggested is one option. If you still want to use raw
>> image files where the partitioning is already done for you, then
>> what I've done for that is create a blank disk image file of the
>> size I want (using dd reading from /dev/zero), then partition that
>> and copy over the system files before writing that image to a real
>> SD card.
>
> I think I understand the principle there (just), but dear me.
> What is dd?

I think it stands for 'direct disk' Unix was written in the days long
before even a CRT terminal was common and so its commands were
deliberately short.

What it does is ignore the niceties of partitions and files and just
copy a disk sector by sector into a file or vice versa. Conventionally
the files are *.img extensions and, if copied back onto a fresh disk (or
SD card) will recreate not only the files, but the partitions
informations was well (and in the case of Intel machines, the boot
sector as well)


> What is /dev/zero is that a drive?
>

It is a pseudo file, which is infinitely long and contains an infinite
source of binary zeroes.

Whatever you do to it, how ever many characters you read from it, they
will all always be zero.

Unix tried to make everything look like a file, so this is a special
file that looks like a file, acts like a file but contains no data, or
if you prefer an infinite amount of data guaranteed to be 0.

There is another pseudo file called /dev/null, which is an infinite sink
of data. A write only file. If you have a program that insists on
chattering output to you that yo really don't care about you can
'redirect' its output to /dev/null

If only such a thing existed for my Australian cousin....

...
> No idea how to create a partition table. Wouldn't know where to start.
>
There is a command called 'parted' (PARTitionEDitor) that allows you to
do exactly that.
> Thanks for trying to help me but you're way above my level.
>
No, he is not. Only just above your level. One step and a time


--
Those who want slavery should have the grace to name it by its proper
name. They must face the full meaning of that which they are advocating
or condoning; the full, exact, specific meaning of collectivism, of its
logical implications, of the principles upon which it is based, and of
the ultimate consequences to which these principles will lead. They must
face it, then decide whether this is what they want or not.

Ayn Rand.

The Natural Philosopher

unread,
Sep 18, 2023, 6:22:11 AM9/18/23
to
Back in the early 80s, you needed a PDP/11 to run Unix. They were about
£15,000
Or a VAX. They were a LOT more. The Internet ran on VAXes to start with.

Xenix was much later . And it wasn't a whole lot of cop. The best 'PC
Unix' was SCO and if you wanted BSD you bought a SUN SPARC, but that
was long after the PDP era.

The fact that a PI Zero is probably a better computer than a VAX was
back in the day is - astonishing.

All it lacks is a hard drive.

Chris Elvidge

unread,
Sep 18, 2023, 6:23:13 AM9/18/23
to
On 18/09/2023 11:07, Bob Latham wrote:
> In article <ue9577$1mres$1...@dont-email.me>,
> Chris Elvidge <ch...@mshome.net> wrote:
>
>> 'sudo -i' always works for me.
>
> Thanks. I've seen that before in the distant past. Didn't understand
> why it might be different to just sudo.
>
> Bob.
>

'-i' forces a login shell, as in runs target user's .login,
.bash_profile or .profile, and .bashrc
see: 'man sudo'


--
Chris Elvidge, England
I WILL NOT SELL MIRACLE CURES

Chris Elvidge

unread,
Sep 18, 2023, 6:34:18 AM9/18/23
to
On a 'new' copy on an SD card, /boot/cmdline.txt finishes with:
init=/usr/lib/raspberrypi-sys-mods/firstboot

If you either remove that bit (not recommended), or edit
/usr/lib/raspberrypi-sys-mods/firstboot to remove (or comment out) the
bulk of the 'do_resize' function (add return just after the definition)
before you start the Pi for the first time, you may be lucky.
You can use (g)parted to resize the partition manually (obviously on
another machine).

Pancho

unread,
Sep 18, 2023, 7:17:42 AM9/18/23
to
On 18/09/2023 11:22, The Natural Philosopher wrote:
> On 18/09/2023 11:05, Pancho wrote:
>> On 18/09/2023 10:54, The Natural Philosopher wrote:
>>
>>>
>>> LOL. Don't ever pick up a book on Philosophy. I think it was
>>> Wittgenstein who said 'If you have not bought a book on philosophy,
>>> got as far as page 3, and then immediately thrown it into a corner of
>>> the room. you have no aptitude for philosophy'
>>>
>>> I too have ceased buying Unix and linux books - the Web is by far the
>>> quickest way, or asking here.
>>>
>>> In general you can learn far more my grabbing 'a simple TCP/IP client
>>> for Linux' as source code, compiling and debugging it than a dozen
>>> books will teach you.
>>>
>>> Just keep muddling along and be grateful that these days you can buy
>>> a fully operational multi user multitasking computer that will run a
>>> full linux distro for £15 when back in the day it was nearer £15,000...
>>>
>>
>> It was never £15,000. Back in 1992 a reasonable PC cost about £2000.
>>
>> Prior to Linux, late 80s, Xenix ran impressively on a 386. The writing
>> was on the wall for minis.
>
> Back in the early 80s, you needed a PDP/11 to run Unix. They were about
> £15,000
> Or a VAX. They were a LOT more. The Internet ran on VAXes to start with.
>

OK, I know you meant Unix, but you said Linux.

> Xenix was much later . And it wasn't a whole lot of cop. The best 'PC
> Unix' was SCO  and if you wanted BSD you bought a SUN SPARC, but that
> was long after the PDP era.
>

I can't remember if it was SCO or Xenix, I just remember being impressed
how quick a 386 PC was compared to minis.

> The fact that a PI Zero is probably a better computer than a VAX was
> back in the day is - astonishing.
>

The rPi3 is hugely faster, than a VAX 11/780, probably the rPi Zero too.
Somewhere between 10-20 times as fast running old software, to a 1000
times as fast if you allow for modern software.

Back in the late 1980s, the company I worked for bankrupted themselves
by trying to develop an Ingress SQL database driven multiuser system on
VAX minis. The hardware just wasn't powerful enough. This was around the
time of the MicroVAX 2000. There was discussion of giving every user
their own MicroVax 2000, which sounded OK to me at the time, but in
hindsight I don't know how they would have distributed the central
database access.

Anyway, I left the company, before it went tits up.

> All it lacks is a hard drive.
>
>
Is the SD card, not a hard drive?

Ian

unread,
Sep 18, 2023, 7:24:47 AM9/18/23
to
On 2023-09-18, Bob Latham <b...@sick-of-spam.invalid> wrote:

> On stage 3. mkdir /mnt/x
> I got: Cannot create directory, file exists.
> I presume that is from my attempts yesterday.
> How would I remove that file/directory or whatever it is?

Yes, probably.

rmdir /mnt/x would work (if it's still empty, which it should be),
but that's not necessary.

> Anyway I ignored it and persisted with
> mount /dev/sda2 /mnt/x
>
> seemed to work, no error.
>
> Stage 4.
> cd /mnt/x worked fine.
> tar -czf ~/xxx.tar.gz .
> this went away for more than 18 minutes, I thought it had crashed.
> Got 22 lines of this...
>
> tar: ./var/lib/samba/private/msg.sock/ nnnnn socket ignored.

That's fine. Sockets are what running processes use to talk to each
other, they live in the filesystem so they can be found. It makes
no sense to "archive" them, so they're ignored by tar.


> eventually machine came back.

Yes, these things take time...

> stage 6
> fdisk /dev/sda2
>
> I ASSUME sda2 is correct ???

It should be /dev/sda for your environment.

/dev/sda is the whole disc. /dev/sda1 is the first partition (a subset
of the whole disc), /dev/sda2 the second partition. fdisk is about
manipulating partitions, so needs to work on the whole disc.
(The partition table is in the first sector/block of the disc)

Ahem A Rivet's Shot

unread,
Sep 18, 2023, 7:30:07 AM9/18/23
to
On Mon, 18 Sep 2023 10:46:23 +0100
The Natural Philosopher <t...@invalid.invalid> wrote:

> On 17/09/2023 23:54, Martin Gregorie wrote:
> > Using the 'apropos' and 'man' commands is the fastest way I know of of
> > finding a standard issue Linux program that will do what you need it
> > to do and finding out how to use it,
>
> I would argue it is the slowest.
>
> It's like reading the whole workshop manual of your new car to find out
> where the button is to open the fuel flap.

Indeed the man pages are reference material, on a good system they
are complete and correct and occupy a similar position to the datasheet for
an IC - essential when you need the precise detail.

They are not and never were intended to be tutorials any more than
a complete set of TTL datasheets will tell you which chips to use and how
to connect them in order to construct a clock.

--
Steve O'Hara-Smith
Odds and Ends at http://www.sohara.org/
Host: Beautiful Theory meet Inconvenient Fact
Obit: Beautiful Theory died today of factual inconsistency

Ahem A Rivet's Shot

unread,
Sep 18, 2023, 7:30:08 AM9/18/23
to
On Mon, 18 Sep 2023 11:05:38 +0100
Pancho <Pancho...@proton.me> wrote:

> Prior to Linux, late 80s, Xenix ran impressively on a 386. The writing
> was on the wall for minis.

I used to run Xenix on a 15MHz 80286 system, it worked fine.

Ahem A Rivet's Shot

unread,
Sep 18, 2023, 8:00:04 AM9/18/23
to
On Mon, 18 Sep 2023 12:17:39 +0100
Pancho <Pancho...@proton.me> wrote:

> I can't remember if it was SCO or Xenix, I just remember being impressed
> how quick a 386 PC was compared to minis.

SCO bought Xenix from Microsoft, later the product became SCO Unix
after the SysVR4 changes were merged into it.

Ahem A Rivet's Shot

unread,
Sep 18, 2023, 8:00:08 AM9/18/23
to
On Mon, 18 Sep 2023 11:06:48 +0100
The Natural Philosopher <t...@invalid.invalid> wrote:

> On 18/09/2023 09:00, Bob Latham wrote:

> > I think I understand the principle there (just), but dear me.
> > What is dd?
>
> I think it stands for 'direct disk' Unix was written in the days long
> before even a CRT terminal was common and so its commands were
> deliberately short.

It's far more obscure than that :)

The dd name was a joke reference to the IBM JCL command DD (data
definition). Originally dd was the universal data format conversion tool
capable of converting between ASCII and EBCDIC, adjusting parity,
converting case, swapping bytes (endian conversion) and dealing with moving
data between block structured devices/files with different block sizes
performing block padding as needs be.

It can still do all of this (check the conv section of man dd)
should you ever find a need to do *any* of it.

The Natural Philosopher

unread,
Sep 18, 2023, 8:23:34 AM9/18/23
to
On 18/09/2023 12:14, Bob Latham wrote:
> In article <5ae559...@sick-of-spam.invalid>,
> Bob Latham <b...@sick-of-spam.invalid> wrote:
>> In article
>> <slrnugdpsj.vum.${send-direct-email-to-new...@vm46.home.jusme.com>,
>>> 1. Clone the SD card you're trying to shrink (using dd,
>>> Win32DiskImager or whatever you normally use to read/write SD
>>> card images), just in case.
>
> Right. I have got quite a bit further but stumped now. :-)
>
> I typed sudo passwd <ret>
>
> It asked for a new password x2
>
> Never asked for existing password for pi user oddly.
>

Sudo sorta remembers you for a time. Very confusing. I dont remember it
douing that tears ago..

> after that su - worked fine.
>
>
> On stage 3. mkdir /mnt/x
> I got: Cannot create directory, file exists.
> I presume that is from my attempts yesterday.
> How would I remove that file/directory or whatever it is?
>
rmdir /mnt/x

> Anyway I ignored it and persisted with
> mount /dev/sda2 /mnt/x
>
> seemed to work, no error.
>
> Stage 4.
> cd /mnt/x worked fine.
> tar -czf ~/xxx.tar.gz .
> this went away for more than 18 minutes, I thought it had crashed.

next time use cvzf to get it to tell you what its doing.

> Got 22 lines of this...
>
> tar: ./var/lib/samba/private/msg.sock/ nnnnn socket ignored.
>
I wonder why id did that? patently that is not something worth backing
up, but nevertheless...

> eventually machine came back.
>
> stage 5
>
> cd
> umount /mnt/x
>
> seemed to go fine.
>
looks OK

>
> stage 6
> fdisk /dev/sda2


>
> I ASSUME sda2 is correct ???
>
No. partititons are applied to the WHOLE disk which is /dev/sda


so fdisk /dev/sda

https://tldp.org/HOWTO/Partition/fdisk_partitioning.html

> P
>
> Lots of text and red writing about 'ext4' signatures...
>
> Then a table very similar to your example but after the line:
> Disk identifier: 0x9b19dd1d
>
> I did not get the 3 lines
>
> Device Boot start End sectors size Id Type
> /dev...
> /dev...
>
> Just didn't happen.
>
> Help !
>

Ok just one misstep, but defiinitely three steps forward

You remind me of just how weird and crappy Unix at the command line
seemed, back when I first had to do stuff with it

>
> Thanks.
>
> Bob.
>

--
A lie can travel halfway around the world while the truth is putting on
its shoes.

The Natural Philosopher

unread,
Sep 18, 2023, 8:25:44 AM9/18/23
to
I'd say it was quite an easy drive, but it isn't really suitable for the
sorts of crap we used to put on an PDP/11. That drive was spinning all
day with half a dozen of us doing stuff on it


--
“It is hard to imagine a more stupid decision or more dangerous way of
making decisions than by putting those decisions in the hands of people
who pay no price for being wrong.”

Thomas Sowell

The Natural Philosopher

unread,
Sep 18, 2023, 8:27:46 AM9/18/23
to
On 18/09/2023 12:59, Ahem A Rivet's Shot wrote:
> On Mon, 18 Sep 2023 12:17:39 +0100
> Pancho <Pancho...@proton.me> wrote:
>
>> I can't remember if it was SCO or Xenix, I just remember being impressed
>> how quick a 386 PC was compared to minis.
>
> SCO bought Xenix from Microsoft, later the product became SCO Unix
> after the SysVR4 changes were merged into it.
>
Ah. My bad, I was thinking of Venix, not Xenix. Venix was a heap of crap
but would run on a 286...just about

Sco Unix was a damned good platform for a small company 'minicomputer'

It even had TCP/IP ... eventually!

Ahem A Rivet's Shot

unread,
Sep 18, 2023, 8:30:03 AM9/18/23
to
On Mon, 18 Sep 2023 12:14:47 +0100
Bob Latham <b...@sick-of-spam.invalid> wrote:

> I typed sudo passwd <ret>
>
> It asked for a new password x2
>
> Never asked for existing password for pi user oddly.

There's some authorisation caching in sudo, so if you have recently
given your password for a sudo command sudo remembers this and doesn't ask
again.

The Natural Philosopher

unread,
Sep 18, 2023, 8:30:16 AM9/18/23
to
On 18/09/2023 12:57, Ahem A Rivet's Shot wrote:
> On Mon, 18 Sep 2023 11:06:48 +0100
> The Natural Philosopher <t...@invalid.invalid> wrote:
>
>> On 18/09/2023 09:00, Bob Latham wrote:
>
>>> I think I understand the principle there (just), but dear me.
>>> What is dd?
>>
>> I think it stands for 'direct disk' Unix was written in the days long
>> before even a CRT terminal was common and so its commands were
>> deliberately short.
>
> It's far more obscure than that :)
>
> The dd name was a joke reference to the IBM JCL command DD (data
> definition). Originally dd was the universal data format conversion tool
> capable of converting between ASCII and EBCDIC, adjusting parity,
> converting case, swapping bytes (endian conversion) and dealing with moving
> data between block structured devices/files with different block sizes
> performing block padding as needs be.
>
> It can still do all of this (check the conv section of man dd)
> should you ever find a need to do *any* of it.
>
*shudder*. I find myself unaccountably smiling at your post. It brings
back memories of really old fashioned computer days.


--
“The urge to save humanity is almost always only a false face for the
urge to rule it.”
– H. L. Mencken

Chris Elvidge

unread,
Sep 18, 2023, 8:39:36 AM9/18/23
to
On 18/09/2023 13:27, The Natural Philosopher wrote:
> On 18/09/2023 12:59, Ahem A Rivet's Shot wrote:
>> On Mon, 18 Sep 2023 12:17:39 +0100
>> Pancho <Pancho...@proton.me> wrote:
>>
>>> I can't remember if it was SCO or Xenix, I just remember being impressed
>>> how quick a 386 PC was compared to minis.
>>
>> SCO bought Xenix from Microsoft, later the product became SCO Unix
>> after the SysVR4 changes were merged into it.
>>
> Ah. My bad, I was thinking of Venix, not Xenix. Venix was a heap of crap
> but would run on a 286...just about
>
> Sco Unix was a damned good platform for a small company 'minicomputer'
>
> It even had TCP/IP ... eventually!
>

We had it running on one of the first 486s. Database for hospitals
around the region (St Barts)


--
Chris Elvidge, England
TEACHER IS NOT A LEPER

Ian

unread,
Sep 18, 2023, 8:43:01 AM9/18/23
to
On 2023-09-18, Bob Latham <b...@sick-of-spam.invalid> wrote:
> I've now got passed stage 10 and looking at 11.
>
> Lots of questions now...
>
> Do I need to create a script from your text or can I just copy and
> paste line by line?

You can just copy/paste the lines. When you paste the "echo" one check
that the reported number of MB is reasonable, and that the number of
sectors being copied is bigger than the last sector shown, before
proceeding to the 'dd'


> How do I change where to put the new image?
>
> Any suggestions where to put it?
>
> Can I just copy out the image using samba with something I
> understand. :-)

The file name after the "| gzip >" is where the target image will go.
It can be any file path, so if you have external filestore mounted with
samba it can go there directly. There should be enough space on the live
SD card if you remove the tarfile first, the copy it off wherever you
need it.


> How do I delete the tarfile and where is it?

The tarfile is ~/xxx.tar.gz, you can remove it with:

# rm ~/xxx.tar.gz

"~/" is a shortcut for your "home directory". As root, this is /root,
so the file is actually /root/xxx.tar.gz. The same applies to the final
image: "~/newcard.img.gz" is /root/newcard.img.gz.


> Why did we use a tarfile, was it just to reduce the storage size?

The tarfile was used to hold a copy of the OS files while you shrunk
the parition. Think of it as zipping up the contents of a disc before
replacing it with a new one, then restoring the content from the zipfile.


Final note, I "gzip" (compress) the final image as this saves a lot of
space (8GB down to 2.3GB in my case). You'll need to uncompress it
before writing it to a new card with Win32DiskImager. 7zip can do this
on Windows, if that's how you do it. If you don't want it compressed
(and have the space), you can omit the gzip from the last command:

# dd if=/dev/sdc bs=1048576 count=${n_mb} > ~/newcard.img


To pick up on the "dd" thread, that command reads from the input file
(if=...), in blocks of 1MB (bs=...) and copies ${n_mb} blocks (count=...).
It send the output to "stdout" (nominally the terminal), but we pipe
this through gzip to compress it (| gzip", and then direct the output of
gzip to the target file (> ~/newcard.img).

R.Wieser

unread,
Sep 18, 2023, 8:44:01 AM9/18/23
to
Chris,

> You can use (g)parted to resize the partition manually (obviously on
> another machine).

I was/am trying to evade multi-step solutions. Especially ones that cannot
be automated.

Regards,
Rudy Wieser


Ahem A Rivet's Shot

unread,
Sep 18, 2023, 9:30:04 AM9/18/23
to
On Mon, 18 Sep 2023 13:27:44 +0100
The Natural Philosopher <t...@invalid.invalid> wrote:

> Sco Unix was a damned good platform for a small company 'minicomputer'
>
> It even had TCP/IP ... eventually!

SCO Xenix had MICNET, a LAN based on UUCP over directly connected
serial ports. With it running you could cd .. from / and find a directory of
machines on the network. It wasn't fast or standard but it worked.

The Natural Philosopher

unread,
Sep 18, 2023, 9:31:22 AM9/18/23
to
There was a legal business that had it on a 386 running the while firm
with about 25 screens on. Cost was a few hours a day to pop tapes in the
backup. and a thousand quid support contract with the software authors .

Then a board decision to put a PC on everyone's desk at about £1500 a
DESK was made with an annual support contract of about £10,000

--
The higher up the mountainside
The greener grows the grass.
The higher up the monkey climbs
The more he shows his arse.

Traditional

The Natural Philosopher

unread,
Sep 18, 2023, 9:47:53 AM9/18/23
to
On 18/09/2023 14:04, Ahem A Rivet's Shot wrote:
> On Mon, 18 Sep 2023 13:27:44 +0100
> The Natural Philosopher <t...@invalid.invalid> wrote:
>
>> Sco Unix was a damned good platform for a small company 'minicomputer'
>>
>> It even had TCP/IP ... eventually!
>
> SCO Xenix had MICNET, a LAN based on UUCP over directly connected
> serial ports. With it running you could cd .. from / and find a directory of
> machines on the network. It wasn't fast or standard but it worked.
>
Blimey. I missed THAT one.
UUCP was something that I spent a large part of my life installing and
setting up. It was, for a time, the only way to get "Internet" email in
the UK

--
The New Left are the people they warned you about.

Martin Gregorie

unread,
Sep 18, 2023, 10:40:10 AM9/18/23
to
On Mon, 18 Sep 2023 08:50:44 +0100, Bob Latham wrote:

> In article <ue8042$il0u$1...@dont-email.me>,
> Martin Gregorie <mar...@mydomain.invalid> wrote:
>> Now you know how to mount a disk, you need to know how to find Linux
>> commands that can help you do what you want to do with the RPi. For the
>> rest of this info to work, you need to know how to login as the default
>> user AND how to log in as root:
>
>> 1 the 'man name' command shows you a page (which can be very long)
>> that tells you what 'name' does and how to use it, Name can be
>> anything from a command to a Linux system call or function.
>
>> 2 the "apropos 'text' command shows you a list of commands whose
>> manual pages have 'text' in their first line of their manual pages.
>
>> 3 Using the 'apropos' and 'man' commands is the fastest way I know
>> of of finding a standard issue Linux program that will do what you
>> need it to do and finding out how to use it,
>
>> 4 If you like reading books rather than screens, consider getting a
>> copy of "UNIX in a Nutshell" or "Linux in a Nutshell" - both are
>> concise references to the way UNIX/Linux works and how to use it.
>
>> There's also "Unix Systems Programming for SVR4" which, although
>> quite old now, is still a useful guide to writing programs and
>> applications in C.
>
> Thank you for that information. Scary stuff. I've done what I've done so
> far by googling for answers and a little experimenting. I'm neither
> clever nor an academic.
>
> I wanted to learn how to write code for tcpip comms for another
> platform, I was advised to get a book called "Unix Network Programming".
> It's a thick book and cost a lot of money. I got to about page 3 before
> I was out of my depth and beyond rescue. That's why I have not got any
> linux books.
>
First question: can you write C (or C++ or Rust, ...) already?

If not, I'd recommend the ANSI edition of "The C Programming Language" by
Kernighan and Richie (They are the authors of C).

"The Practise of Programming" by Kernighan and Pike" is also good to have:
if you're starting to program because it describes how to write well laid
out and documented C code that's easy for other programmers (including
yourself in 10 years time) to read, understand and modify. A lot of what
it says is directly applicable to other block structured languages such
as Java, Algol 60, Algol 68, Pascal and even PL/I. It may even help you to
write better programs in other languages such as Perl, Python, Fortran,
COBOL and assemblers.

And, if you find that you need tried and tested chunks of code to slot
into some project you're developing, its worth knowing about both
"Software Tools in Pascal" (Kernighan and Pike) and
"Algorithms" (Sedgewick). The latter isn't cheap, but then good books
about programming languages and algorithms seldom are. Both these provide
runnable example code written in Pascal, which is easy to transcribe
directly into C and/or Java (Personal experience) because it was written
as a teaching language for use in Computer Science courses.


--

Martin | martin at
Gregorie | gregorie dot org

Ian

unread,
Sep 18, 2023, 12:05:18 PM9/18/23
to
On 2023-09-18, Bob Latham <b...@sick-of-spam.invalid> wrote:

> I strongly suspect my settings somewhere but the decompressed file
> isn't dramatically smaller than the original.
>
> Original = 3,805,184 KB
> new file = 3,411,968 KB
>
> I targeted getting down from 4GB to 3GB as more than 1GB was empty.

Well done!

If that's the compressed file size then it seems about right - there should
be the same amount of content, just now it's in a smaller container.

Charlie Gibbs

unread,
Sep 18, 2023, 12:11:30 PM9/18/23
to
On 2023-09-18, The Natural Philosopher <t...@invalid.invalid> wrote:

> On 17/09/2023 18:11, Mrtn wrote:
>
>> Since the horse already left the stable, you can put all this in the
>> afterburner.
>
> What a wonderful mixed metaphor..
> I smell a rat.
> I feel it in the air.
> We must nip it in the bud...

The Heinlein novel "Starman Jones" had a character who mixed metaphors
with great aplomb. I remember sayings like "Let sleeping dogs bury
their own dead," and "Let's strike while the iron is in the fire and
let the bridges fall where they may!"

--
/~\ Charlie Gibbs | They offer a huge range of
\ / <cgi...@kltpzyxm.invalid> | world-class vulnerabilities
X I'm really at ac.dekanfrus | that only Microsoft can provide.
/ \ if you read it the right way. | -- druck <ne...@druck.org.uk>

Charlie Gibbs

unread,
Sep 18, 2023, 12:11:31 PM9/18/23
to
On 2023-09-18, Ahem A Rivet's Shot <ste...@eircom.net> wrote:

> On Mon, 18 Sep 2023 11:06:48 +0100
> The Natural Philosopher <t...@invalid.invalid> wrote:
>
>> On 18/09/2023 09:00, Bob Latham wrote:
>>
>>> I think I understand the principle there (just), but dear me.
>>> What is dd?
>>
>> I think it stands for 'direct disk' Unix was written in the days long
>> before even a CRT terminal was common and so its commands were
>> deliberately short.
>
> It's far more obscure than that :)
>
> The dd name was a joke reference to the IBM JCL command DD (data
> definition). Originally dd was the universal data format conversion tool
> capable of converting between ASCII and EBCDIC, adjusting parity,
> converting case, swapping bytes (endian conversion) and dealing with moving
> data between block structured devices/files with different block sizes
> performing block padding as needs be.
>
> It can still do all of this (check the conv section of man dd)
> should you ever find a need to do *any* of it.

Speaking of IBM ancestry, that sounds a bit like the IBM utility DEBE
(Does Everything But Eat), which let you do a lot of the same things
from a mainframe console. I ported a version of it to a couple of
Univac mainframes. Lots of fun.

Charlie Gibbs

unread,
Sep 18, 2023, 12:11:32 PM9/18/23
to
On 2023-09-18, The Natural Philosopher <t...@invalid.invalid> wrote:

> These days I never use man at all. If I can't remember the command
> syntax I google it and chances are someone else has documented a crib
> that does what I need it to do.
>
> Like I ripped a CD onto my server and all the song title filenames came
> with underscores instead of spaces.
>
> Try invoking 'apropos spaces' .
>
> But googling 'change underscores to spaces in linux file names' got me
> three lines of bash that simply WORKED

Nice man pages (e.g. rsync) contain a section labeled "EXAMPLES".
Too bad they're few and far between.

Charlie Gibbs

unread,
Sep 18, 2023, 12:11:32 PM9/18/23
to
On 2023-09-18, The Natural Philosopher <t...@invalid.invalid> wrote:

> LOL. Don't ever pick up a book on Philosophy. I think it was
> Wittgenstein who said 'If you have not bought a book on philosophy, got
> as far as page 3, and then immediately thrown it into a corner of the
> room. you have no aptitude for philosophy'

:-)

> I too have ceased buying Unix and linux books - the Web is by far the
> quickest way, or asking here.
>
> In general you can learn far more my grabbing 'a simple TCP/IP client
> for Linux' as source code, compiling and debugging it than a dozen books
> will teach you.

Still, if you'd really like a written reference, it's hard to go wrong
with Beej's Guide to Network Programming (https://beej.us/guide/bgnet/).
I know it filled in a lot of blanks in my head when I started programming
TCP/IP applications.

The Natural Philosopher

unread,
Sep 18, 2023, 12:18:11 PM9/18/23
to
On 18/09/2023 17:11, Charlie Gibbs wrote:
> On 2023-09-18, The Natural Philosopher <t...@invalid.invalid> wrote:
>
>> LOL. Don't ever pick up a book on Philosophy. I think it was
>> Wittgenstein who said 'If you have not bought a book on philosophy, got
>> as far as page 3, and then immediately thrown it into a corner of the
>> room. you have no aptitude for philosophy'
>
> :-)
>
>> I too have ceased buying Unix and linux books - the Web is by far the
>> quickest way, or asking here.
>>
>> In general you can learn far more my grabbing 'a simple TCP/IP client
>> for Linux' as source code, compiling and debugging it than a dozen books
>> will teach you.
>
> Still, if you'd really like a written reference, it's hard to go wrong
> with Beej's Guide to Network Programming (https://beej.us/guide/bgnet/).
> I know it filled in a lot of blanks in my head when I started programming
> TCP/IP applications.
>

The sneaking suspicion I have had all my life since I first enocountered
it, that BSD 'sockets' were a truly awful way to interact with a network
device was borne out in my attempts to get networking working on the
PICO with the LWIP library. Badly documented it may have been, but the
overall ideas were a lot easier to get to grips with.



--
“There are two ways to be fooled. One is to believe what isn’t true; the
other is to refuse to believe what is true.”

—Soren Kierkegaard

Ahem A Rivet's Shot

unread,
Sep 18, 2023, 1:00:06 PM9/18/23
to
On Mon, 18 Sep 2023 17:18:10 +0100
The Natural Philosopher <t...@invalid.invalid> wrote:

> The sneaking suspicion I have had all my life since I first enocountered
> it, that BSD 'sockets' were a truly awful way to interact with a network
> device

Look into System V streams if you want to see a truly awful way to
interact with a network device.

The Natural Philosopher

unread,
Sep 18, 2023, 3:35:37 PM9/18/23
to
On 18/09/2023 17:34, Ahem A Rivet's Shot wrote:
> On Mon, 18 Sep 2023 17:18:10 +0100
> The Natural Philosopher <t...@invalid.invalid> wrote:
>
>> The sneaking suspicion I have had all my life since I first enocountered
>> it, that BSD 'sockets' were a truly awful way to interact with a network
>> device
>
> Look into System V streams if you want to see a truly awful way to
> interact with a network device.
>
I did, once. :-)

--
Gun Control: The law that ensures that only criminals have guns.

druck

unread,
Sep 18, 2023, 3:54:42 PM9/18/23
to
On 18/09/2023 09:29, Ian wrote:
> If you log in as "root", or get a root shell by calling "sudo bash",
> things work as expected:

sudo -i

is quicker to type.

---druck

Ahem A Rivet's Shot

unread,
Sep 18, 2023, 4:30:05 PM9/18/23
to
On Mon, 18 Sep 2023 20:35:34 +0100
The Natural Philosopher <t...@invalid.invalid> wrote:

> On 18/09/2023 17:34, Ahem A Rivet's Shot wrote:
> > On Mon, 18 Sep 2023 17:18:10 +0100
> > The Natural Philosopher <t...@invalid.invalid> wrote:
> >
> >> The sneaking suspicion I have had all my life since I first
> >> enocountered it, that BSD 'sockets' were a truly awful way to interact
> >> with a network device
> >
> > Look into System V streams if you want to see a truly awful way
> > to interact with a network device.
> >
> I did, once. :-)

I had the misfortune of using it as transport for an early
fault tolerant distributed database application. It was interesting.

Computer Nerd Kev

unread,
Sep 18, 2023, 6:47:08 PM9/18/23
to
Bob Latham <b...@sick-of-spam.invalid> wrote:
> In article <6507...@news.ausics.net>,
> Computer Nerd Kev <n...@telling.you.invalid> wrote:
>
>> Using Tar as suggested is one option. If you still want to use raw
>> image files where the partitioning is already done for you, then
>> what I've done for that is create a blank disk image file of the
>> size I want (using dd reading from /dev/zero), then partition that
>> and copy over the system files before writing that image to a real
>> SD card.
>
> I think I understand the principle there (just), but dear me.
> What is dd?
> What is /dev/zero is that a drive?

dd is basically the standard image file (etc.) reader/writer
program on Linux. I thought you might have been using it already,
but since reading more posts I see you were doing everything from
Windows. TNF has already described dd and /dev/zero in ample
detail.

> I'd love to do it but don't have anywhere near enough knowledge to do
> it?

The aim is just to create an empty file which some Linux
programs can then use pretending that it's a physical drive, then
when everything's set up that file's contents can be copied over to
a physical drive. The complicated part is really in copying the
system files into the empty image file first. Resizing partitions
would be easier for you.

>> I've also had success with simply creating a partition table with
>> blank space at the end of an SD card. If you just copy over as much
>> data as will fit on the smaller SD card, it should still work if
>> the partitions had all ended before the space ran out. Resizing
>> the last partition on the existing card should work too (make a
>> backup first). But doing the work on a file instead of a real card
>> is probably safer and less confusing. Faster too, especially if
>> you create it in /tmp so the write operations all happen in RAM,
>> provided you have enough.
>
> No idea how to create a partition table. Wouldn't know where to start.
>
> Thanks for trying to help me but you're way above my level.

Resizing the last parition isn't difficult in a program like
GParted (which will need to run on Linux). What might be confusing
then is that your disk imager program will probably still create an
image file that's too big to fit on smaller SD cards. The image
_can_ still work on smaller cards because the data in the
unpartitioned section at the end of the image file is now ignored
in use anyway, but you'll have to convince your image file writer
program to just write as much data as will fit. That might be
easy or it might be impossible, depending on the program.

The last time I used image file writers on Windows was for floppy
disk images, so I'm not sure whether modern ones are suitable for
this. With dd you can use the "bs" and "count" options to stop it
reading/writing data from/to the image file at the end of the last
partition (if you get your maths right to work out where that is in
bytes and divide that by the "bs" value in bytes to use for the
"count" value - this is one of dd's less convenient aspects).

--
__ __
#_ < |\| |< _#

Computer Nerd Kev

unread,
Sep 18, 2023, 7:11:40 PM9/18/23
to
The Natural Philosopher <t...@invalid.invalid> wrote:
> The first time we got a SUN server equipped with system V unix, and
> discovered that LPR had gone, and we have no way to make it print to its
> parallel port, was such a nightmare for the company that I drove into
> town at lunchtime, and went to the university bookstore and paid ?55 for
> a book on SUNS unix V, because it had one line of about 300 characters
> in it which was 'how you enable printing on a system V Unix parallel port'
>
> Today we have CUPS which hides all the ugliness.

Wow, I gave up on CUPS a few years ago when they changed things and
I couldn't find any documentation on the web to explain how to make
it work the way I had it before. Now I'm using lprng, which is also
faster, although I'll admit that I'd have to check the docs again
to remember how to set up a new printer.

Maybe it's all a secret effort to bring about the paperless society
by force? :)

The Natural Philosopher

unread,
Sep 19, 2023, 3:02:35 AM9/19/23
to
su - is even quicker

The Natural Philosopher

unread,
Sep 19, 2023, 4:00:09 AM9/19/23
to
On 19/09/2023 08:32, Bob Latham wrote:
> In article <6508...@news.ausics.net>,
> Computer Nerd Kev <n...@telling.you.invalid> wrote:
>
>> dd is basically the standard image file (etc.) reader/writer
>> program on Linux. I thought you might have been using it already,
>> but since reading more posts I see you were doing everything from
>> Windows.
>
> Yes, windows to you but I'm in the Black Country so it's Winders
> around here. :-)
>
Oh well in that case just give the pi an 'ecky thump' and it will behave


--
"Strange as it seems, no amount of learning can cure stupidity, and
higher education positively fortifies it."

- Stephen Vizinczey


The Natural Philosopher

unread,
Sep 19, 2023, 5:19:48 AM9/19/23
to
On 19/09/2023 09:21, Bob Latham wrote:
> In article <uebke4$28kuk$1...@dont-email.me>,
> The Natural Philosopher <t...@invalid.invalid> wrote:
>> On 19/09/2023 08:32, Bob Latham wrote:
>>> In article <6508...@news.ausics.net>,
>>> Computer Nerd Kev <n...@telling.you.invalid> wrote:
>>>
>>>> dd is basically the standard image file (etc.) reader/writer
>>>> program on Linux. I thought you might have been using it already,
>>>> but since reading more posts I see you were doing everything from
>>>> Windows.
>>>
>>> Yes, windows to you but I'm in the Black Country so it's Winders
>>> around here. :-)
>
>> Oh well in that case just give the pi an 'ecky thump' and it will behave
>
> :-)
>
> I though that expression was Yorkshire is that where you are?
>
> Bob.
>
Nay lad, Oi be in Safferk, innit? Land of Queen Boudicca, et al...

--
In theory, there is no difference between theory and practice.
In practice, there is.
-- Yogi Berra

Ian

unread,
Sep 19, 2023, 5:23:46 AM9/19/23
to
On 2023-09-19, Bob Latham <b...@sick-of-spam.invalid> wrote:

> Yes, windows to you but I'm in the Black Country so it's Winders
> around here. :-)

Bostin! (ex-Mancunian, now living in Wolverhampton).

Chris Elvidge

unread,
Sep 19, 2023, 6:16:10 AM9/19/23
to
On 19/09/2023 08:02, The Natural Philosopher wrote:
> On 18/09/2023 20:54, druck wrote:
>> On 18/09/2023 09:29, Ian wrote:
>>> If you log in as "root", or get a root shell by calling "sudo bash",
>>> things work as expected:
>>
>> sudo -i
>>
>> is quicker to type.
>>
>> ---druck
>>
> su - is even quicker
>

'su -' needs a password entered (on my system(s))


--
Chris Elvidge, England
I WILL NOT USE ABBREV.

The Natural Philosopher

unread,
Sep 19, 2023, 7:07:05 AM9/19/23
to
On 19/09/2023 11:16, Chris Elvidge wrote:
> On 19/09/2023 08:02, The Natural Philosopher wrote:
>> On 18/09/2023 20:54, druck wrote:
>>> On 18/09/2023 09:29, Ian wrote:
>>>> If you log in as "root", or get a root shell by calling "sudo bash",
>>>> things work as expected:
>>>
>>> sudo -i
>>>
>>> is quicker to type.
>>>
>>> ---druck
>>>
>> su - is even quicker
>>
>
> 'su -' needs a password entered (on my system(s))
>
>
so does sudo...on mine

--
"When one man dies it's a tragedy. When thousands die it's statistics."

Josef Stalin


Chris Elvidge

unread,
Sep 19, 2023, 8:27:32 AM9/19/23
to
OK. If you look into usr/lib/raspberrypi-sys-mods/firstboot there's a line:
TARGET_END=$((ROOT_DEV_SIZE - 1))

Change that -1 to whatever you want (e.g. ROOT_DEV_SIZE/2 for a root
partition roughly half the SD card size).
Remember $ROOT_DEV_SIZE is in 512 byte sectors.
See: /sys/block/mmcblk0/size

--
Chris Elvidge, England
MY MOM IS NOT DATING JERRY SEINFELD

R.Wieser

unread,
Sep 19, 2023, 9:00:43 AM9/19/23
to
Chris,

> OK. If you look into usr/lib/raspberrypi-sys-mods/firstboot there's a
> line:
> TARGET_END=$((ROOT_DEV_SIZE - 1))
[snip]

Teriffic ! Thats the kind of solution I was hoping for. Thanks. :-)

Regards,
Rudy Wieser


druck

unread,
Sep 19, 2023, 4:21:30 PM9/19/23
to
On 18/09/2023 23:46, Computer Nerd Kev wrote:
> Resizing the last parition isn't difficult in a program like
> GParted (which will need to run on Linux). What might be confusing
> then is that your disk imager program will probably still create an
> image file that's too big to fit on smaller SD cards.
It's quite easy to resize the partition file, do a:-

sudo fdisk -l <imagefile>

You'll get something like

Device Boot Start End Sectors Size Id Type
backup.img1 8192 532479 524288 256M c W95 FAT32 (LBA)
backup.img2 532480 15597567 15065088 7.2G 83 Linux

Take the end value of the last partition add 1 and multiply by 512 to
convert from sectors to bytes, then do the calculation again as this is
a destructive action and can't be undone. When you are sure of the
number resize the file using:-

truncate <imagefile> <size>

> The last time I used image file writers on Windows was for floppy
> disk images, so I'm not sure whether modern ones are suitable for
> this. With dd you can use the "bs" and "count" options to stop it
> reading/writing data from/to the image file at the end of the last
> partition (if you get your maths right to work out where that is in
> bytes and divide that by the "bs" value in bytes to use for the
> "count" value - this is one of dd's less convenient aspects).

With dd you don't have to worry, if the source image is bigger than the
destination SD card, dd will just ignore the extra data. But it's still
better to make the file the right size.

---druck

The Natural Philosopher

unread,
Sep 20, 2023, 8:15:40 AM9/20/23
to
On 20/09/2023 13:09, Bob Latham wrote:
> cd/media/usb-drive/

Thats your problem Lady.

cd /
THEN
umount

You cant unmount a drive you are sitting in


--
“Those who can make you believe absurdities, can make you commit
atrocities.”

― Voltaire, Questions sur les Miracles à M. Claparede, Professeur de
Théologie à Genève, par un Proposant: Ou Extrait de Diverses Lettres de
M. de Voltaire

Andy Burns

unread,
Sep 20, 2023, 8:52:53 AM9/20/23
to
Bob Latham wrote:

> Not got a linux machine only PIs doing little jobs.

What is an rPi, other than a Linux machine?

Andy Burns

unread,
Sep 20, 2023, 8:54:14 AM9/20/23
to
Bob Latham wrote:

> Are you saying that's why it doesn't seem to have done anything even
> though I eventually typed # cd before umount. It then appeared to
> dismount to me?

typing "cd" by itself, takes you back to your home directory, so then
your shell didn't have the mounted usb disk open.

Tauno Voipio

unread,
Sep 20, 2023, 9:15:46 AM9/20/23
to
On 19.9.2023 13.16, Chris Elvidge wrote:
> On 19/09/2023 08:02, The Natural Philosopher wrote:
>> On 18/09/2023 20:54, druck wrote:
>>> On 18/09/2023 09:29, Ian wrote:
>>>> If you log in as "root", or get a root shell by calling "sudo bash",
>>>> things work as expected:
>>>
>>> sudo -i
>>>
>>> is quicker to type.
>>>
>>> ---druck
>>>
>> su - is even quicker
>>
>
> 'su -' needs a password entered (on my system(s))


So should all other methods to aquire superuser privileges.

There seems to be around RaspiOS setups with one user
permitted in the /etc/sudoers without password.

--

-TV

The Natural Philosopher

unread,
Sep 20, 2023, 9:41:15 AM9/20/23
to
On 20/09/2023 13:46, Bob Latham wrote:
> In article <ueenp9$2u313$1...@dont-email.me>,
> The Natural Philosopher <t...@invalid.invalid> wrote:
>> On 20/09/2023 13:09, Bob Latham wrote:
>>> cd/media/usb-drive/
>
>> Thats your problem Lady.
>
>> cd /
>> THEN
>> umount
>
>> You cant unmount a drive you are sitting in
>
> Are you saying that's why it doesn't seem to have done anything even
> though I eventually typed
> # cd
> before umount. It then appeared to dismount to me?
>

That's right. If you are sitting on the mounted mount point, it cant get
off!
It will say 'busy'


> Or are you just confirming my brain wobble was correct?
>

Not sure which wobble that was...

> Bob.
>

--
"The great thing about Glasgow is that if there's a nuclear attack it'll
look exactly the same afterwards."

Billy Connolly

The Natural Philosopher

unread,
Sep 20, 2023, 9:41:37 AM9/20/23
to
A pi PICO?

--
“I know that most men, including those at ease with problems of the
greatest complexity, can seldom accept even the simplest and most
obvious truth if it be such as would oblige them to admit the falsity of
conclusions which they have delighted in explaining to colleagues, which
they have proudly taught to others, and which they have woven, thread by
thread, into the fabric of their lives.”

― Leo Tolstoy

The Natural Philosopher

unread,
Sep 20, 2023, 9:43:04 AM9/20/23
to
Well, being linux, you have the choice. If you want to run the whole
shebang as root, you can!

Ahem A Rivet's Shot

unread,
Sep 20, 2023, 11:00:03 AM9/20/23
to
On Wed, 20 Sep 2023 16:15:44 +0300
Tauno Voipio <tauno....@notused.fi.invalid> wrote:

> On 19.9.2023 13.16, Chris Elvidge wrote:

> > 'su -' needs a password entered (on my system(s))
>
>
> So should all other methods to aquire superuser privileges.

With sudo it depends entirely on what is in /etc/sudoers.

> There seems to be around RaspiOS setups with one user
> permitted in the /etc/sudoers without password.

This is possible sudoers supports a NOPASSWD keyword - this is
mostly useful for automation and laziness.

The Natural Philosopher

unread,
Sep 20, 2023, 12:44:31 PM9/20/23
to
On 20/09/2023 16:36, Bob Latham wrote:
> In article <ueespp$2v1m1$1...@dont-email.me>,
> The Natural Philosopher <t...@invalid.invalid> wrote:
>
>
>> That's right. If you are sitting on the mounted mount point, it
>> cant get off! It will say 'busy'
>
> Right but that's not the reason the whole thing did nothing *after* I
> corrected that ????
>
> Bob.
>
I thought you said you unmounted it after that

--
Socialism is the philosophy of failure, the creed of ignorance and the
gospel of envy.

Its inherent virtue is the equal sharing of misery.

Winston Churchill


Richard Harnden

unread,
Sep 20, 2023, 2:34:03 PM9/20/23
to
On 19/09/2023 12:07, The Natural Philosopher wrote:
> On 19/09/2023 11:16, Chris Elvidge wrote:
>> On 19/09/2023 08:02, The Natural Philosopher wrote:
>>> On 18/09/2023 20:54, druck wrote:
>>>> On 18/09/2023 09:29, Ian wrote:
>>>>> If you log in as "root", or get a root shell by calling "sudo bash",
>>>>> things work as expected:
>>>>
>>>> sudo -i
>>>>
>>>> is quicker to type.
>>>>
>>>> ---druck
>>>>
>>> su - is even quicker
>>>
>>
>> 'su -' needs a password entered (on my system(s))
>>
>>
> so does sudo...on mine
>

sudo wants /your/ password,
su wants /root's/ password.

You can set up sudo to not need a password.
You shouldn't need to know root's password.

Martin Gregorie

unread,
Sep 20, 2023, 3:04:43 PM9/20/23
to
On Wed, 20 Sep 2023 14:21:47 +0100, Bob Latham wrote:

> In article <kn08bj...@mid.individual.net>,
> Andy Burns <use...@andyburns.uk> wrote:
>> Bob Latham wrote:
>
>> > Are you saying that's why it doesn't seem to have done anything even
>> > though I eventually typed # cd before umount. It then appeared to
>> > dismount to me?
>
>> typing "cd" by itself, takes you back to your home directory,
>
> Yes, that was my thinking.
>
>> so then your shell didn't have the mounted usb disk open.
>
> For me that leads to other questions..
> 1. Was it the correct thing to do?
>
> 2. After that did I need to umount?
>
> 3. I understand that being 'on' or 'in' an external drive means you
> cannot dismount it but was trying what stopped the process from working?
>
> Bob.

re point 2: if you want to see what storage is mounted, run 'df' to get a
list of all mounted partitions (file systems). This shows names of the
file systems, they size in 1K blocks, the space used and available in each
file system and the path to the fire system from '/'.





--

Martin | martin at
Gregorie | gregorie dot org

druck

unread,
Sep 20, 2023, 4:15:10 PM9/20/23
to
On 20/09/2023 13:09, Bob Latham wrote:
> Not got a linux machine only PIs doing little jobs.

Pi's running Linux are a Linux machine!

> I got an SD card and formatted it to fat32. I copied an image file to
> it that I had created last week and worked.
>
> Put it in a reader and plugged the reader into a PI I use as a spare
> for pi-hole and my intranet.
>
> Read my notes from Monday and a video on youtube ..
>
> $ sudo -1
> sudo: unable to resolve host intranet-pihole2: Name or service not
> known.

I think you need to ensure you select email and terminal fonts can
distinguish between i, l, and 1. The command is:-

sudo -i

That's a lower case letter i.

> # fdisk -l
>
> This gave me a list but mostly ram discs but my usb was there.
>
> From the video I typed...
>
> # mkdir /media/usb-drive
> # mount /dev/sda1 /media/usb-drive/
> # mount | grep sda1 (no idea, it's in the video)
> # cd /media/usb-drive/
> # ls
> # sudo fdisk -l <imagefile>
>
> Did the sums.
>
> # truncate <imagefile> -s 3896508416
>
> The '-s' caught me out but I got there eventually.
>
> The PI went away for not long maybe 10 seconds and came back.

You've truncated the image file, but you've not mentioned resizing the
partition sizes first. Without that step all you will be doing is not
writing some of partition to a new card, and the last partition will
still overlap the end, which things do not like.

> Thinking I'd done it, I wanted to get it back into a PC to take a
> look. I needed to dismount the usb, how ?????
>
> # umount /media/usb-drive (best guess)
> target is busy.
>
> This went on for half an hour or so. Surely it can't still be...
>
> I started to type this post and then I had a brain wobble. Have I got
> to get off it first?
>
> # cd
> # umount /media/usb-drive

If you have a terminal current directory set to the drive being
dismounted (or files open on it) this will happen. If you still cant
unmount after cd and closing any applications which you think may have
files open, you can do:-

umount -l /media/usb-drive

> Used win32diskimager and burnt an sd card. At this point I was
> guessing that I would now see a smaller 2nd partition and an
> unallocated area that I wouldn't get on these 4GB cards but would on
> larger cards.
>
> I ran partition wizard.
>
> No change there either that I could see. 2nd partition was still most
> of the drive and a good third was empty. No unallocated area.
>
> I either don't understand this or I've done (not done) something
> wrong.
>
> Any ideas?

Did you alter the partition table before truncating?

---druck

Ahem A Rivet's Shot

unread,
Sep 20, 2023, 5:00:05 PM9/20/23
to
On Wed, 20 Sep 2023 19:34:01 +0100
Richard Harnden <richard...@gmail.com> wrote:

> sudo wants /your/ password,
> su wants /root's/ password.
>
> You can set up sudo to not need a password.
> You shouldn't need to know root's password.

For owner operated machines with only one human user it makes
little difference.

In a multi user environment sudo can be set up to give quite
precise capabilities to groups of users and allow accurate tracking of who
does what with their privileges - it can however be irritatingly hard to
prevent every way of escaping to a shell while still providing useful tools.

The Natural Philosopher

unread,
Sep 21, 2023, 3:34:47 AM9/21/23
to
On 20/09/2023 19:34, Richard Harnden wrote:

> You can set up sudo to not need a password.
> You shouldn't need to know root's password.

Ah. You must be a New Socialist.
To preface a personal preference with 'should'

"c. 1200, from Old English sceolde, past tense of sceal (see shall).
Preserves the original notion of "obligation" that has all but dropped
from shall"

'Should' implies a debt or moral obligation. I do not feel morally
obliged to leave root's password unset nor do I feel you have any legal
right or moral authority to lay that trip on me!

The Natural Philosopher

unread,
Sep 21, 2023, 3:35:34 AM9/21/23
to
On 20/09/2023 20:04, Martin Gregorie wrote:

> re point 2: if you want to see what storage is mounted, run 'df' to get a
> list of all mounted partitions (file systems). This shows names of the
> file systems, they size in 1K blocks, the space used and available in each
> file system and the path to the fire system from '/'.
>
df -h presents the information in a more digestible form

--
"Anyone who believes that the laws of physics are mere social
conventions is invited to try transgressing those conventions from the
windows of my apartment. (I live on the twenty-first floor.) "

Alan Sokal

Martin Gregorie

unread,
Sep 21, 2023, 7:00:38 AM9/21/23
to
On Thu, 21 Sep 2023 08:35:32 +0100, The Natural Philosopher wrote:

> On 20/09/2023 20:04, Martin Gregorie wrote:
>
>> re point 2: if you want to see what storage is mounted, run 'df' to get
>> a list of all mounted partitions (file systems). This shows names of
>> the file systems, they size in 1K blocks, the space used and available
>> in each file system and the path to the fire system from '/'.
>>
> df -h presents the information in a more digestible form

Good suggestion. I seem to remember that this used to be the default
display format.

Martin Gregorie

unread,
Sep 21, 2023, 7:15:46 AM9/21/23
to
On Wed, 20 Sep 2023 21:54:58 +0100, Ahem A Rivet's Shot wrote:

> On Wed, 20 Sep 2023 19:34:01 +0100 Richard Harnden
> <richard...@gmail.com> wrote:
>
>> sudo wants /your/ password,
>> su wants /root's/ password.
>>
>> You can set up sudo to not need a password.
>> You shouldn't need to know root's password.
>
> For owner operated machines with only one human user it makes
> little difference.
>
> In a multi user environment sudo can be set up to give quite
> precise capabilities to groups of users and allow accurate tracking of
> who does what with their privileges - it can however be irritatingly
> hard to prevent every way of escaping to a shell while still providing
> useful tools.

I always set up a root password as a backstop to prevent miscreants from
getting into systems on my LAN if they manage to sneak through my
firewall. Similarly, I encrypt a small partition as a way of preventing a
stolen machine from being booted (and as a depository for storing
passwords for internal user logins and external applications).

Yes, I know this isn't totally secure, but its probably good enough to
prevent a common or garden thief from using the machine or selling it to
anybody who doesn't know enough to reformat the disk and install Winders
on it.

Martin Gregorie

unread,
Sep 21, 2023, 11:55:15 AM9/21/23
to
On Thu, 21 Sep 2023 12:26:47 +0100, Bob Latham wrote:

> In article <uefjsc$33fp6$1...@dont-email.me>,
> druck <ne...@druck.org.uk> wrote:
>> On 20/09/2023 13:09, Bob Latham wrote:
>> > Not got a linux machine only PIs doing little jobs.
>
>> Pi's running Linux are a Linux machine!
>
> Ok, how about don't have a Linux desktop PC.
>
Have you got a desKtop or laptop with either

- a built-in CD drive

- a reasonably fast USB socket and either a portable USB hard disk or a
40GB USB stick.

If so, download a bootable Linux image onto it. Most PCs and laptops can
find and boot the Linux image you just downloaded and run it damaging the
existing OS (probably Windows) and associated filing system.

Now you can boot the PC from the Linux image, stick the SD card containing
the Pi's filing system into a vacant USB slot on the PC and it should show
up on your desktop, ready to be mounted and its contents inspected and
altered as needed.

Once you've finished with it, remember to unmount the PI's SD card before
you pull it out of its slot on the PC, close down Linux, disconnect the
device containing the Linux image and reboot from the PC as usual.

The Natural Philosopher

unread,
Sep 22, 2023, 4:38:51 AM9/22/23
to
On 21/09/2023 12:26, Bob Latham wrote:
>> You've truncated the image file, but you've not mentioned resizing
>> the partition sizes first. Without that step all you will be doing
>> is not writing some of partition to a new card, and the last
>> partition will still overlap the end, which things do not like.
> I'm sure you're correct but once again I've reached the limits of
> understanding. 😄 I read back on the whole thread and see if I can
> work out how resize a partition, no idea at the moment.
>

Yeah. That image file is now like a half empty bag of sugar with the top
cut off. It is not a half sized bag.
The partition is in a sense a container, and if you have left the part
of it that defines how big it is,but removed half of it, then the
computer will try and access parts that no longer exist.

This is (as the Book says) a Bad Thing.

--
Labour - a bunch of rich people convincing poor people to vote for rich
people by telling poor people that "other" rich people are the reason
they are poor.

Peter Thompson

The Natural Philosopher

unread,
Sep 24, 2023, 7:31:04 AM9/24/23
to
On 24/09/2023 11:00, Bob Latham wrote:
> In article <uejjqn$3j1j$1...@dont-email.me>,
> The Natural Philosopher <t...@invalid.invalid> wrote:
>> On 21/09/2023 12:26, Bob Latham wrote:
>
>>>> You've truncated the image file, but you've not mentioned
>>>> resizing the partition sizes first. Without that step all you
>>>> will be doing is not writing some of partition to a new card,
>>>> and the last partition will still overlap the end, which things
>>>> do not like.
>>> I'm sure you're correct but once again I've reached the limits of
>>> understanding. # I read back on the whole thread and see if I can
>>> work out how resize a partition, no idea at the moment.
>>>
>
>> Yeah. That image file is now like a half empty bag of sugar with
>> the top cut off. It is not a half sized bag. The partition is in
>> a sense a container, and if you have left the part of it that
>> defines how big it is,but removed half of it, then the computer
>> will try and access parts that no longer exist.
>
> I've spent a few days looking at this trying to understand what
> you're telling me and i just don't get it. Would someone please
> explain to me where i'm going wrong both in procedure and
> understanding.
>
> One of my problems is clearly understanding terminology used.
A very common problem.

>
> Druck talks about resizing the 'partition file'. I thought this was
> the image containing two partitions used to burn onto an SD card. I
> now don't think that's the case, so what is it and where is it?
>
I think that is sloppy semantics. The thing is to resize the partiton
in the *image* file to allow the image file to be shrunk

>
> Is any of the following correct?
>
> My problem is that I end up with an SD card image with two
> partitions, the second one is usually at least half empty. I presume
> there is no point messing with the very small first partition?
>
Not really.

> I need to end the second partition earlier/shorter and change the
> last part of the image file to unallocated.
>
Or delete it entirely

> When I've done that I can chop the end of the image file off.
>
Oh I see. Yes. exactly so
]
> So the bit Druck described the other day using
> "truncate <imagefile> -s <size>"
>
> Is that the bit that chops off the newly unallocated end of the file?
>
Probably
Its a bit like a chainsaw, is truncate

> If so, (and if it isn't I'm really lost), then what I've not done is
> end the second partition earlier creating an unallocated area?
>
Probably. You need 'parted' to do that. Or an equivalent windows program.

And it all gets fairly messy

That's why I am investigating using a file based backup system rather
than imaging the entire card. Sadly its very slow


> I'm dreading asking this but is that the bit Ian described and he and
> TNP patiently talked/coached me through last week?
>
I didnt touch on parted. I am not very good with it anyway, and if the
blind lead the blind, they both shall fall into the ditch...

And parted will only work ON the Pi..or another linux system, but that
does suggest another approach,

1. START with parted to shrink the partition on the PI to a bit more
than it needs to run
2. Then dd the entire card to an image file
3. Then truncate it.

Actually within Linux I found this

"If you wish to shrink an ext2 partition, first use resize2fs to shrink
the size of filesystem. Then you may use fdisk(8) to shrink the size of
the partition. When shrinking the size of the partition, make sure you
do not make it smaller than the new size of the ext2 filesystem! "

This is probably a way to go, to start with a smaller partition before
dd-ing. THEN you can truncate reasonably safely.

But I personally don't find *any* of these methods easy, or quick.


> I build images a lot and I need whatever system I use to be
> reasonably quick to perform. Ian's procedure is very time consuming
> and if that's needed then this isn't really practical for my needs.
>
Remind me again what you are trying to achieve...is it to replicate
safely onto SD cards of varying sizes the exact same image?
If so, time taken to prepare the image is not so serious.
And my system of copying the files over, then creating a smaller
'virtual disk image' which will expand to fill the card on booting, may
serve.

How this would/will work is this:

0/.Probably start by connecting a USB drive to the pi and using that as
a big scratch area
1/. Create an empty disk image on it by copying zeroes from /dev/zero to
a disk image file.
2/. use fdisk or parted to create the small VFAT and the larger ext4
partitions
3/. mount the two partitions as loopback devices
4/. COPY the /boot file system onto the vfat partition
5/. COPY the root filesystem onto the ext4 partition
6/. Label the two file systems identically with what is in /etc/fstab
7/. Optionally add scripts to the first boot to resize the partition to
the full card size.
You will now have a disk image less than the smallest card you ever want
to use, that you can dd at will onto any new SD card.

It will take a long time to prepare this image, but once you have it,
installing it will be very fast..



> It's all been very worth it from a learning POV at the very least.
>
> Thanks.
>
> Cheers,
>
> Bob.
>

--
“It is dangerous to be right in matters on which the established
authorities are wrong.”

― Voltaire, The Age of Louis XIV

The Natural Philosopher

unread,
Sep 24, 2023, 7:53:13 AM9/24/23
to
I had another thought on this.
I am not sure if it would work, or not.
Let's say you have a clone image of the whole SD card on a desktop computer.

You should be able to mount its two partitions on that computer.
You then create a small empty disk image file and partition that with
whatever tools your OS has, labelling the new partitions to have the
*same id as the old ones*, and mount those two partitions as well.
You copy all the files in the cloned image partitions to the new image
partitions. This will be fast because you are not using the Pi to do it

And you have a new image file smaller than any SD card you ever intend
to use.

This should be scriptable.

--
“The ultimate result of shielding men from the effects of folly is to
fill the world with fools.”

Herbert Spencer

Chris Elvidge

unread,
Sep 24, 2023, 11:00:09 AM9/24/23
to
On 17/09/2023 09:58, Bob Latham wrote:
> Hi,
>
> I build images for projects on 4GB cards so that I can save a
> completed image without using too much disc space. My problem comes
> when I try to burn a new card from the saved image. Often it will not
> fit because there are small differences in the size of the cards.
>
> Does anyone know of a way to reduce the capacity of an SD card so
> that I can make a 4GB card maybe 3.5GB which would mean all cards
> could easily manage it and reduce the size of the save image.
>
>
> Thanks.
>
> Bob.
>

Can you edit a file in the ext4 partition of the SD card after burning
with raw image but before you put it in the SD slot of the Pi for first
boot?
If so, edit the firstboot file in usr/lib/raspberrypi-sys-mods/
directory of the second (ext4) partition.
Edit the line TARGET_END=$((ROOT_DEV_SIZE - 1))
Change the 1 to 1048576
That will make the automatic expansion of the root file system at first
boot to leave approx. 512Mb (0.5Gb) space at the end on the SD card. I.e
reduce the 4Gb down to 3.5Gb

Alternatively, do you have access to machine with a full version of
Raspbian? I.e. with graphical desktop.
Install gparted (using apt).
Put target SD card in USB adapter and insert into USB port. It will show
as /dev/sda if no other disks in USB.
Run gparted as root to shrink the second partition (ext4) of the SD card
(sda).


--
Chris Elvidge, England
I WILL NOT SELL LAND IN FLORIDA

druck

unread,
Sep 25, 2023, 4:11:03 PM9/25/23
to
On 24/09/2023 11:00, Bob Latham wrote:
> In article <uejjqn$3j1j$1...@dont-email.me>,
> The Natural Philosopher <t...@invalid.invalid> wrote:
>> On 21/09/2023 12:26, Bob Latham wrote:

> Druck talks about resizing the 'partition file'. I thought this was
> the image containing two partitions used to burn onto an SD card. I
> now don't think that's the case, so what is it and where is it?

That is the case, but it is step 2 of a 2 part process.

Step 1 is to use a partition editor (gparted or parted) to resize the
ext4 partition in the image file, as described earlier in the thread.

> So the bit Druck described the other day using
> "truncate <imagefile> -s <size>"

That's step 2

> Is that the bit that chops off the newly unallocated end of the file?

Yes

> If so, (and if it isn't I'm really lost), then what I've not done is
> end the second partition earlier creating an unallocated area?

Yes

---druck

The Natural Philosopher

unread,
Sep 26, 2023, 8:04:33 AM9/26/23
to
On 26/09/2023 09:21, Bob Latham wrote:
> In article <uespgl$234t2$1...@dont-email.me>,
> druck <ne...@druck.org.uk> wrote:
>> On 24/09/2023 11:00, Bob Latham wrote:
>>> In article <uejjqn$3j1j$1...@dont-email.me>,
>
>>> Is that the bit that chops off the newly unallocated end of the
>>> file?
>
>> Yes
>
>>> If so, (and if it isn't I'm really lost), then what I've not done
>>> is end the second partition earlier creating an unallocated area?
>
>> Yes
>
> Thanks druck that is encouraging.
>
> So I need to use either gparted or parted. Do they operate on an
> image file (ready to be burnt to an sd card) or do they work on a
> drive with working partitions (but obviously not the OS drive)?
>
Both.

I think you need to 'loop mount' the image to operate on it

You do need a working linux machine to utilise them though - they are
not windows tools

Booting a live CD/DVD/USB drive linux system will net you all you need
for the duration.

If you have an old machine you can install linux on it might help a lot
learning your way around the tools, or a Pi with a screen and keyboard
is just as good, ifd a tad slower

> Hope my terminology is good enough to be understood.
>
It is.

> Thanks.
>
> Bob.
>

--
If I had all the money I've spent on drink...
..I'd spend it on drink.

Sir Henry (at Rawlinson's End)

The Natural Philosopher

unread,
Sep 26, 2023, 9:41:28 AM9/26/23
to
On 26/09/2023 13:56, Bob Latham wrote:
> In article <ueuhcf$2g1lp$3...@dont-email.me>,
> The Natural Philosopher <t...@invalid.invalid> wrote:
>> On 26/09/2023 09:21, Bob Latham wrote:
>>> In article <uespgl$234t2$1...@dont-email.me>,
>>> druck <ne...@druck.org.uk> wrote:
>>>> On 24/09/2023 11:00, Bob Latham wrote:
>>>>> In article <uejjqn$3j1j$1...@dont-email.me>,
>>>
>>>>> Is that the bit that chops off the newly unallocated end of the
>>>>> file?
>>>
>>>> Yes
>>>
>>>>> If so, (and if it isn't I'm really lost), then what I've not done
>>>>> is end the second partition earlier creating an unallocated area?
>>>
>>>> Yes
>>>
>>> Thanks druck that is encouraging.
>>>
>>> So I need to use either gparted or parted. Do they operate on an
>>> image file (ready to be burnt to an sd card) or do they work on a
>>> drive with working partitions (but obviously not the OS drive)?
>>>
>> Both.
>
>> I think you need to 'loop mount' the image to operate on it
>
> loop mount ??????
>
>> You do need a working linux machine to utilise them though - they
>> are not windows tools
>
>> Booting a live CD/DVD/USB drive linux system will net you all you
>> need for the duration.
>
> I'm sure you're right, it would help if I had a Linux machine proper.
>
> I'll look into a disc boot device of some sort. There's an old XP
> machine upstairs which my wife has decided should go to the tip. If I
> start using it now .......
>
> Trying to get my head around all of this, I have this morning gone
> through Ian's procedure again. It was easy the second time and
> knowing what to expect. I was hoping I could see how Druck's chain
> saw suggestion would help but I don't see it yet.
>
> Interesting though..
> Before Ian's procedure partition 2 was
> 3.4GB and 69% used = 2.34 GB data.
>
> After Ian's procedure P2 was
> 3.0GB and 55% used = 1.65 GB data.
>
> I don't see how all the data can be there?
>
> To say I don't understand would be a big understatement.
>
> Would the procedure be any faster if the files were just copied from
> part2 to safe area and copied back to the new partition rather than
> using Tar?
>
Probably not, sadly

> It's the tar up and down and the saving of the new image which is so
> slow it makes it impractical.
>
Indeed. I let my rsync* backup run overnight.

*another way to copy files in this instance


> Thanks.
>
> Bob.
>

--
It’s easier to fool people than to convince them that they have been fooled.
Mark Twain



Martin Gregorie

unread,
Sep 26, 2023, 10:28:20 AM9/26/23
to
On Tue, 26 Sep 2023 13:56:13 +0100, Bob Latham wrote:

> I'm sure you're right, it would help if I had a Linux machine proper.
>
Take a look at eBay for used laptops, especially Lenovo ones: all Lenovos
will run Linux and have USB sockets and their Thinkpad series are solid
and well made machines:

- my first laptop was a Lenovo R61i which served me well for 12 years,
until its hard disk died in 2017. Its still usable as well as faster
since I replaced the dead disk with a 120GB SSD (by 2017 you couldn't
buy hard drives smaller than 500GB but the R61i hardware can't handle
disks bigger than 220GB, hence the small SSD which is still big enough
to holds everything that was on the dead disk.(spread sheet and word
processing programs, GIMP image editor, C and Java compilation systems,
Evolution mail client, Google Earth, ...

- Currently I'm using a Lenovo T440 that's at least 7 years old (I bought
it off eBay in 2017 (400GB HDD, 8GB RAM) and it is running Fedora Linux.
It also boots happily from a USB-connected HDD or CD disk. It does
everything I need and is fairly rugged 1600x900 with a decent screen, SD
card socket and a couple of USB sockets.

eBay has 'em from GBP 40.00 to GBP 120.00 as well as

> I'll look into a disc boot device of some sort. There's an old XP
> machine upstairs which my wife has decided should go to the tip. If I
> start using it now .......
>
Most modern desktops and laptops should boot from a USB CD drive, and if
the CD drive isn't read-only, most PCs should should download a bootable
Linux disk image and write it to a CD or USB stick, which should be at
least 30-40GB.

I hope the above gives you some useful ideas.

The Natural Philosopher

unread,
Sep 26, 2023, 12:14:35 PM9/26/23
to
Id be very careful with some ebay laptops. Laptops unfortunately DIE. I
have a fully electrically functioning HP one except the case has turned
to rubble., I kid you not. The plastic has simply crumbled. It probably
biodegraded...I paid £200+ for a refurbished one with some sort of
guarantee at 'laptops direct'. Ive boght several things from them, all
refurbed or sale price and they have never sold me shit

Current best offering is this

https://www.laptopsdirect.co.uk/refrubished-asus-e210ma-celeron-n4020-4gb-64gb-11.6-inch-windows-11-laptop-a2-e210ma-gj181ws/version.asp

£119 is not to much to spend on a cheap lappie


--
Karl Marx said religion is the opium of the people.
But Marxism is the crack cocaine.

Björn Lundin

unread,
Sep 26, 2023, 3:41:33 PM9/26/23
to
On 2023-09-26 16:28, Martin Gregorie wrote:
> On Tue, 26 Sep 2023 13:56:13 +0100, Bob Latham wrote:
>
>> I'm sure you're right, it would help if I had a Linux machine proper.
>>
> Take a look at eBay for used laptops,


Or thin clients.
I bought a Hp T510 and a fujitsu Futuro s720 for less than 20 euros
CPU like a RPI 4 but AMD or Via, 4 gb RAM and a very small Sata flash
(16 GB). But runs well with 2.5" hdd via usb (or sata)

Runs Linux well, uses ubuntu. I also got a mini-mac, Core2Duo with 4 Gb
ram for that kind of money. (30 euros I think)

Also runs Ubuntu well

Those above are 64-bit.
I got some very cheap 32 bits as well - running debian



--
/Björn

The Natural Philosopher

unread,
Sep 26, 2023, 11:45:24 PM9/26/23
to
Very good prices there.

I am not sure I would trust a machine that cheap.

Björn Lundin

unread,
Sep 27, 2023, 3:57:05 AM9/27/23
to
On 2023-09-27 05:45, The Natural Philosopher wrote:
> On 26/09/2023 20:41, Björn Lundin wrote:
>> On 2023-09-26 16:28, Martin Gregorie wrote:
>>> On Tue, 26 Sep 2023 13:56:13 +0100, Bob Latham wrote:
>>>
>>>> I'm sure you're right, it would help if I had a Linux machine proper.
>>>>
>>> Take a look at eBay for used laptops,
>>
>>
>> Or thin clients.
>> I bought a Hp T510 and a fujitsu Futuro s720 for less than 20 euros
>> CPU like a RPI 4 but AMD or Via, 4 gb RAM and a very small Sata flash
>> (16 GB). But runs well with 2.5" hdd via usb (or sata)
>>
>> Runs Linux well, uses ubuntu. I also got a mini-mac, Core2Duo with 4
>> Gb ram for that kind of money. (30 euros I think)
>>
>> Also runs Ubuntu well
>>
>> Those above are 64-bit.
>> I got some very cheap 32 bits as well - running debian
>>
>>
>>
> Very good prices there.
>
> I am not sure I would trust a machine that cheap.

But you trust a 5 euro rpi zero with a cf-card?

These machine have no moving parts (fanless and flashdisk)
I stuck spare hdd in them.
But then again, they are part of my build farm, so they do not contain
anything that important, they get code from github when needed

The idea was to find x64 boxes that could build my system
with a small energy footprint. so I also scaled down the CPU, locked it
at 800 Mhz preventing it to go to 1.65 GHz


--
/Björn

Pancho

unread,
Sep 27, 2023, 4:04:01 AM9/27/23
to
On 26/09/2023 20:41, Björn Lundin wrote:

>
>
> Or thin clients.
> I bought a Hp T510 and a fujitsu Futuro s720 for less than 20 euros
> CPU like a RPI 4 but AMD or Via, 4 gb RAM and a very small Sata flash
> (16 GB). But runs well with 2.5" hdd via usb (or sata)
>
> Runs Linux well, uses ubuntu. I also got a mini-mac, Core2Duo with 4 Gb
> ram for that kind of money. (30 euros I think)
>
> Also runs Ubuntu well
>
> Those above are 64-bit.
> I got some very cheap 32 bits as well - running debian
>
>
>
The concern is power consumption, and that they are too old to support
stuff like Wake on Lan.

If you use a core duo for significant periods of time, and don't need a
room heater, it is cheaper to buy something modern and low power.

It is only if you want a computer that is only turned on occasionally,
that such deals start to make sense.


Pancho

unread,
Sep 27, 2023, 4:08:29 AM9/27/23
to
On 27/09/2023 08:57, Björn Lundin wrote:

>
> But you trust a 5 euro rpi zero with a cf-card?
>
> These machine have no moving parts (fanless and flashdisk)
> I stuck spare hdd in them.
> But then again, they are part of my build farm, so they do not contain
> anything that important, they get code from github when needed
>
> The idea was to find x64 boxes that could build my system
> with a small energy footprint. so I also scaled down the CPU, locked it
> at 800 Mhz preventing it to go to 1.65 GHz
>

What power does it consume at the plug?

Björn Lundin

unread,
Sep 27, 2023, 4:16:16 AM9/27/23
to
its an AMD GX-217GA and they have TDP 15W
But I think it is less if running at half speed.

But power consumption at the plug I don't know

--
/Björn

Björn Lundin

unread,
Sep 27, 2023, 4:22:54 AM9/27/23
to
On 2023-09-27 10:03, Pancho wrote:
> On 26/09/2023 20:41, Björn Lundin wrote:
>
>>
>>
>>
> The concern is power consumption, and that they are too old to support
> stuff like Wake on Lan.

Some do have wake-on-Lan. The fujitsu does.

>
> If you use a core duo for significant periods of time, and don't need a
> room heater, it is cheaper to buy something modern and low power.

the core2duo (minimac) has a TDW of 65 W, so that was most for fun.
Not used, The fujitsu and HP is used quite a bit.

And even if I buy something even less power-hungry, that will cost me more.
And electricity is included in my rent.


> It is only if you want a computer that is only turned on occasionally,
> that such deals start to make sense.

And that is the case



https://www.parkytowers.me.uk/thin/hp/t510/
says the HP consumes 19w at plug
while the fujitsu consumes 11 W

https://www.parkytowers.me.uk/thin/Futro/s720/



But this is a bit off the raspberry pi topic




--
/Björn

The Natural Philosopher

unread,
Sep 27, 2023, 6:02:20 AM9/27/23
to
On 27/09/2023 08:57, Björn Lundin wrote:
> On 2023-09-27 05:45, The Natural Philosopher wrote:
>> On 26/09/2023 20:41, Björn Lundin wrote:
>>> On 2023-09-26 16:28, Martin Gregorie wrote:
>>>> On Tue, 26 Sep 2023 13:56:13 +0100, Bob Latham wrote:
>>>>
>>>>> I'm sure you're right, it would help if I had a Linux machine proper.
>>>>>
>>>> Take a look at eBay for used laptops,
>>>
>>>
>>> Or thin clients.
>>> I bought a Hp T510 and a fujitsu Futuro s720 for less than 20 euros
>>> CPU like a RPI 4 but AMD or Via, 4 gb RAM and a very small Sata flash
>>> (16 GB). But runs well with 2.5" hdd via usb (or sata)
>>>
>>> Runs Linux well, uses ubuntu. I also got a mini-mac, Core2Duo with 4
>>> Gb ram for that kind of money. (30 euros I think)
>>>
>>> Also runs Ubuntu well
>>>
>>> Those above are 64-bit.
>>> I got some very cheap 32 bits as well - running debian
>>>
>>>
>>>
>> Very good prices there.
>>
>> I am not sure I would trust a machine that cheap.
>
> But you trust a 5 euro rpi zero with a cf-card?
>
yes, because its new, and didn't cost 500 when it was new ten years ago...

> These machine have no moving parts (fanless and flashdisk)
> I stuck spare hdd in them.

So is my disintegrated laptop...

> But then again, they are part of my build farm, so they do not contain
> anything that important, they get code from github when needed
>
> The idea was to find x64 boxes that could build my system
> with a small energy footprint. so I also scaled down the CPU, locked it
> at 800 Mhz preventing it to go to 1.65 GHz
>
Well low power means Arm - best MIPS for yer buck there is.



>

--
The theory of Communism may be summed up in one sentence: Abolish all
private property.

Karl Marx


The Natural Philosopher

unread,
Sep 27, 2023, 6:03:04 AM9/27/23
to
On 27/09/2023 09:03, Pancho wrote:
> If you use a core duo for significant periods of time, and don't need a
> room heater, it is cheaper to buy something modern and low power.

Yes, I noticed that too!

--
Any fool can believe in principles - and most of them do!



It is loading more messages.
0 new messages