[CALUG] Rolling your own distro, building an img file
Thomas Delrue
thomas at epistulae.net
Tue Apr 7 11:21:53 EDT 2020
I will need something a bit more robust for this :)
Basically, my use case is that I want to produce - similar to how you
download Raspbian - .img files that can be flashed onto any SD card,
inserted into a Pi (which will not be mine) and then you have a live
system.
It's specifically for being able to hand these .img files to others
people and have them insert it into their pi and just run with it (and
no, I'm not testing the gullibility of people to see who will have their
Pi's join my botnet :P ).
I guess I could start with what's in a Raspbian .img file already,
modify that and then create a .img file from my modified thing.
Looking at what's in the IMG file is simple:
---BEGIN---
$> fdisk -l /path/to/file.img
$> Disk raspbian-buster-lite.img: 1.74 GiB, 1849688064 bytes, 3612672
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: 0x738a4d67
Device Boot Start End Sectors Size
Id Type
2020-02-13-raspbian-buster-lite.img1 8192 532479 524288 256M
c W95 FAT32 (LBA)
2020-02-13-raspbian-buster-lite.img2 532480 3612671 3080192 1.5G
83 Linux
$> # NOTE: start of Linux Partition at block 532480 & sector size of 512
$> # Thus offset mounting by 512 * 532480 to mount partition 1 (0-based)
$> mount -o loop,offset=272629760 /pathto/file.img /tmp/img
$> pushd /tmp/im
$> ls -l
total 88
drwxr-xr-x 2 root root 4096 Feb 13 10:56 bin
drwxr-xr-x 2 root root 4096 Feb 13 11:09 boot
drwxr-xr-x 4 root root 4096 Feb 13 10:51 dev
drwxr-xr-x 79 root root 4096 Feb 13 11:09 etc
drwxr-xr-x 3 root root 4096 Feb 13 10:55 home
drwxr-xr-x 16 root root 4096 Feb 13 10:58 lib
drwx------ 2 root root 16384 Feb 13 11:09 lost+found
drwxr-xr-x 2 root root 4096 Feb 13 10:51 media
drwxr-xr-x 2 root root 4096 Feb 13 10:51 mnt
drwxr-xr-x 3 root root 4096 Feb 13 10:55 opt
drwxr-xr-x 2 root root 4096 Feb 8 21:47 proc
drwx------ 2 root root 4096 Feb 13 10:51 root
drwxr-xr-x 4 root root 4096 Feb 13 10:51 run
drwxr-xr-x 2 root root 4096 Feb 13 10:58 sbin
drwxr-xr-x 2 root root 4096 Feb 13 10:51 srv
drwxr-xr-x 2 root root 4096 Feb 8 21:47 sys
drwxrwxrwt 2 root root 4096 Feb 13 11:09 tmp
drwxr-xr-x 10 root root 4096 Feb 13 10:51 usr
drwxr-xr-x 11 root root 4096 Feb 13 10:51 var
----END---
The thing I don't know how to do is that last bit: create a new .img file :)
Either I need to stuff more things in there (which means I need to grow
that image and the partition - which seems like the wrong approach) or I
need to get everything from there out, into a new directory, then create
a new .img that combines the boot partition (partition 0) and the
contents of this new directory (that contains my modified stuff).
I'm looking for how - for instance - the raspbian, or Debian, or any
distro, create these things... :)
On 4/7/20 09:58, Chuck Frain wrote:
> I might be underthinking this, but what I do when I get
> images customized for a Pi device is create an image from the SD card
> with some disk imaging tool. I also use this as my backup solution.
>
> On Tue, Apr 7, 2020 at 7:40 AM Thomas Delrue <thomas at epistulae.net
> <mailto:thomas at epistulae.net>> wrote:
>
> Hi,
>
> I'm sorta trying to roll my own distro for Raspberry Pi's. Fear not, I'm
> totally basing it off of Raspbian but I want to add some additional
> stuff on top of Raspbian that isn't there. And I want to make it so that
> when I burn an IMG of my "my own distro" onto a new SD card, it's got
> everything I know I'll want in there, already in it!
>
> Basically, what I'd like to do is make it so that I have an .img file
> with everything already in it and that - just like raspbian - expands on
> first boot to take up the entire volume.
>
> Unfortunately, I have no idea how to get started with this, at all,
> hence:
> does anyone have any pointers they could share?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.unknownlamer.org/pipermail/calug/attachments/20200407/e9d71438/attachment.sig>
More information about the CALUG
mailing list