How to reduce the size of Debian Live image

How to do things, solutions, recipes, tutorials
Message
Author
mcewanw
Posts: 3169
Joined: Thu 16 Aug 2007, 10:48
Contact:

#21 Post by mcewanw »

Hello Toni

Yes, I've now logged into official Linux Mint and the /etc/init/tty*.conf files are there afterall.

Thanks. I'll try to deactive MDM and see if that makes the difference. Not that it matters - I think I would just leave things as it is with official Linux Mint. I'm only really looking at it because my partner needs 64bit version to use viber.

I had a quick look at Porteus 64bit initrd.xz and it seems to be quite a bit different than the 32bit one (no long list of kernel modules being loaded in for loop, for example and of course the official Porteus initrd doesn't have 'porteus' changed to 'live' or 'casper' in MintPup case).

William
github mcewanw

User avatar
saintless
Posts: 3862
Joined: Sat 11 Jun 2011, 13:43
Location: Bulgaria

FEDORA LIVE

#22 Post by saintless »

Just a few notes for Keisha, William and anyone else interested to work on Fedora puppy lookalike system.
Fedora Live CD is much different from Debian or Ubuntu but after some reading I think it shouldn't be so hard to make it smaller and boot it as frugal install with persistence and some simple remastering script.
This iso for example is a good base for testing:
Fedora-Live-SoaS-i686-23-10.iso - 676 Mb
https://download.fedoraproject.org/pub/ ... -23-10.iso
Inside the iso there is as script livecd-iso-to-disk to make bootable usb with persistence from the iso. It works for USB (and for hard drive partition if you make it bootable first), but it is not so hard to make frugal install manually if you have grub or grub4dos already installed.
How to use livecd-iso-to-disk script with persistence save file read here:
https://docs.fedoraproject.org/en-US/Fe ... tence.html

How to make frugal install with persistence manually:
Download the iso and extract LiveOS folder at top of ext partition (probably works with vfat and maybe ntfs but I can't confirm this without testing). In my case the partition is sda1 mounted as /mnt/sda1 and I use grub4dos.
Then go inside /mnt/sda1/LiveOS and copy there /isolinux/initrd0.img and /isolinux/vmlinuz0 from Fedora live cd.
Lets make save file from command line:

Code: Select all

dd if=/dev/zero of=/mnt/sda1/LiveOS/overlay-LIVE count=150 bs=1M
Note it doesn't contain any filesystem. Fedora persistence works different using Device mapper snapshots - saving block device/sectors.
count=150 is for 150Mb save file which should be fine for removing programs only. Increase the size to count=2000 (2Gb) or more if you are going to install programs.
It is important to add label LIVE to /dev/sda1 (mounted as /mnt/sda1) or persistence will not work:

Code: Select all

e2label /dev/sda1 LIVE
e2label /dev/sda1
LIVE
Get the UUID of /dev/sda1:

Code: Select all

blkid
/dev/sda1: UUID="2bfd8e4b-7ffc-485c-a07f-546d50b4bce5" TYPE="ext3" LABEL="LIVE"
Rename the save file /mnt/sda1/LiveOS/overlay-LIVE to /mnt/sda1/LiveOS/overlay-LIVE-2bfd8e4b-7ffc-485c-a07f-546d50b4bce5
Note it is 2bfd8e4b-7ffc-485c-a07f-546d50b4bce5 for me but it will be different for you. Change it with the correct uuid number.

This is what you should have in /mnt/sda1/LiveOS now:

Code: Select all

root@debian:~# ls /mnt/sda1/LiveOS
livecd-iso-to-disk         squashfs.img osmin.img     vmlinuz0    initrd0.img     overlay-LIVE-2bfd8e4b-7ffc-485c-a07f-546d50b4bce5
I'm not sure you need osmin.img but it is very small file anyway and it is better to keep it.
Now it is time to add menu entry in grub4dos menu.lst (correct the UUID and the (hd0,0) part with yours):

Code: Select all

title FEDORA-LIVE sda1 persistence in /LiveOS/
root=(hd0,0) 
kernel /LiveOS/vmlinuz0 root=live:UUID=2bfd8e4b-7ffc-485c-a07f-546d50b4bce5 rootfstype=ext3 rw rd.live.image rd.live.overlay=UUID=2bfd8e4b-7ffc-485c-a07f-546d50b4bce5 quiet rhgb rd.luks=0 rd.md=0 rd.dm=0
initrd /LiveOS/initrd0.img 
Reboot and boot Fedora frugal with persistence in /mnt/sda1/LiveOS/overlay-LIBE-2bfd8e4b-7ffc-485c-a07f-546d50b4bce5 save file.
When the display manager appears press Ctrl+Alt+F2 and login there from command line as root or as liveuser - no password needed for both, just press enter to login. Probably you can login from the display manager but Xorg doesn't work on my old machine and I can't even see the login prompt so I have to use console login.
Your boot partition /dev/sda1 is mounted as /run/initramfs/live
Now you can start removing programs with dnf. This is a good start to make the base smaller without xorg and start building fresh base after that:

Code: Select all

sudo dnf remove xinit
Then get a text file with the installed programs:

Code: Select all

dnf list installed > /list.txt
Read the installed packages with nano:

Code: Select all

nano /list.txt
And try to remove all you don't need without breaking the network connection.
You can install programs with:

Code: Select all

dnf update
dnf install package-name
Search packages with:

Code: Select all

dnf search package-name
I'm sure there are many other options. Use "dnf --help" to learn all.

It will take you some time but it shouldn't be too difficult to make smaller base without xorg and simple script for remastering the system in smaller squashfs using rsync command doing some cleaning and zerosizing at the same time.

Some important notes about the way Fedora live works. The initrd img file is builded with dracut (I know nothing about it and can't even extract the content yet) and the persistence is managed by DM_snapshot. The save file doesn't have file system as you can see from the above dd command.
DM snapshot operates on block device/sector level (not on file system level). This means you can't mount the save file and you can't read or change its content. This save file will work only with one squashfs system module - in our example this is - /mnt/sda1/LiveOS/squashfs.img If you change the module trying to use the same save file probably the boot will crash. So after remastering the system in new module you have to start with new made save file for the new remastered module.
On the other hand squashfs.img containes /LiveOS folder with 4Gb ext3fs.img inside which containes the actual file system.
I might be wrong but Fedora Live boots this way:
After loading squashfs.img the system mounts the included inside ext3fs.img attaching loop device to it and second loop devise for the save file. Then the system combines the two devices creating copy-on-write device in /dev/mapper/ and mounts this device RW in some mount point. This is how I understand the process from reading information about DM snapshot but I might be wrong.

It seems complicated way to run live cd with persistence but this is the official Fedora way and without knowing enough about the system structure this is what you should use first to create smaller base.

Then you can try to use overlayfs or to build aufs or unionfs module and to adapt some more flexible way to boot the system (as live-boot or porteus-boot or puppy-boot...). In general live-boot and porteus-boot will start Fedora main module with kernel from Debian Jessie if you make some changes and after making new squashfs module from ext3fs.img content. It works from limited testing but i'm sure a lot of problems will come later running Fedora live with different kernel or patched kernel.

Maybe I will update this thread with more information later but I can't promise anything. Just posting my one day experience with Fedora live.

Edit: Just few links for testing later. Seems Fedora live cd now can use overlayfs with some dracut patches which sounds much better:
https://github.com/FGrose/dracut/commit ... 84df147abc
https://github.com/dracutdevs/dracut/is ... -160260094
https://github.com/FGrose/livecd-tools/ ... so-to-disk

Toni
Last edited by saintless on Mon 04 Apr 2016, 07:21, edited 1 time in total.

mcewanw
Posts: 3169
Joined: Thu 16 Aug 2007, 10:48
Contact:

#23 Post by mcewanw »

Hi Toni,

In my own quick read yesterday I also obtained the impression that Fedora live methodology was somewhat limiting. Seemed like the save file needed to be quite large and would erode away slowly during writes and deletions. I can't say I understand how its save file works. I should try it out to follow on from your post, but I've currently started out on a programming project I've put off for over a year and any distraction would probably result in me never getting on with that! Nevertheless I am tempted to be distracted and hopefully Keisha will be.

Many Thanks,

William
github mcewanw

Keisha
Posts: 469
Joined: Tue 18 Nov 2014, 05:43

#24 Post by Keisha »

Thanks Toni.

I doubt I will create the Puppified Fedora, but...maybe.

You and Fred might want to look at my post at
http://murga-linux.com/puppy/viewtopic. ... 285#897285

about a rox-filer Trash applet from November 2015 which creates good xdg trash folder entries.

I find it extremely useful in a mixed rox-filer + thunar environment.
“A wise man can learn more from a foolish question than a fool can learn from a wise answer.â€￾ --Bruce Lee

User avatar
saintless
Posts: 3862
Joined: Sat 11 Jun 2011, 13:43
Location: Bulgaria

#25 Post by saintless »

Keisha wrote:You and Fred might want to look at my post at
http://murga-linux.com/puppy/viewtopic. ... 285#897285
Link posted in DD-Jessie thread, thanks.
My previous post updated with links how to use overlayfs instead dm_snapshot in Fedora Live and it sounds better.

Toni

User avatar
saintless
Posts: 3862
Joined: Sat 11 Jun 2011, 13:43
Location: Bulgaria

#26 Post by saintless »

The Fedora live experiment ends here for me for now:
http://kazzascorner.com.au/saintless/Ex ... edora-PRA/
https://github.com/MintPup/FedoraPup
Only for advanced users who can setup the system from command line and who like to experiment with Fedora frugal with options to save in file or directory using PRA kernel and working dnf package manager. Some boot messages are in Russian but I prefer to use PRA boot scripts untouched.
Make sure to read this before trying to test the Fedora-PRA setup.

Edit: Just to make it clear from the start:
Fedora boots with systemd.

Toni

Keisha
Posts: 469
Joined: Tue 18 Nov 2014, 05:43

#27 Post by Keisha »

:) Duly noted.
“A wise man can learn more from a foolish question than a fool can learn from a wise answer.â€￾ --Bruce Lee

Keisha
Posts: 469
Joined: Tue 18 Nov 2014, 05:43

#28 Post by Keisha »

...and downloaded :wink:
“A wise man can learn more from a foolish question than a fool can learn from a wise answer.â€￾ --Bruce Lee

Post Reply