Page 1 of 1

[SOLVED] Modify Default Files, etc.

Posted: 06 Jun 2011, 19:27
by DoomUs
I'd like to alter porteus such that the

Code: Select all

/lib/modules/`uname -r`/kernel/drivers/net/
folder is either empty, or removed entirely. My goal is to remove networking capability.

As I understand, porteus constructs some of its filesystems at boot time. Is there a mechanism to alter the ISO to exclude certain modules? or can anyone suggest any other method for dis-allowing network connection/communication?

Thanks.

Re: Modify Default Files, etc.

Posted: 06 Jun 2011, 19:43
by fanthom
@DoomUs
"Is there a mechanism to alter the ISO to exclude certain modules?"
unfortunately not.
you can create /porteus/rootcopy/etc/modprobe.d/blacklist.net file and list all network drivers there or better remaster 000-kernel.xzm and remove /lib/modules/`uname -r`/kernel/drivers/net/ completely.

Cheers

Re: Modify Default Files, etc.

Posted: 06 Jun 2011, 21:03
by DoomUs
Cool, thanks for your advice. As for
remaster 000-kernel.xzm and remove /lib/modules/`uname -r`/kernel/drivers/net/ completely.
How does this work, how do I go about this? Is there documentation that details a similar process?

Re: Modify Default Files, etc.

Posted: 06 Jun 2011, 22:14
by Ahau
remaster 000-kernel.xzm and remove /lib/modules/`uname -r`/kernel/drivers/net/ completely.How does this work, how do I go about this? Is there documentation that details a similar process?
This is easiest to do from within Porteus, because the tools are built in.

Go to your USB drive, CD drive, and find the file /porteus/base/000-kernel.xzm. Copy it to another location to work on it (this location should be on a linux filesystem -- ext2, ext3, etc., so that symlinks and permissions are preserved --your porteus desktop will work).

From a command line, follow these steps:
cd ~/Desktop
mkdir 000-temp
xzm2dir 000-kernel.xzm 000-temp
cd 000-temp/lib/modules/'uname -r'/kernel/drivers
rm -r net
cd ~/Desktop
rm 000-kernel.xzm
dir2xzm 000-temp 000-kernel.xzm

Or, from GUI,
Right click on the module (on your desktop)
select extract xzm module
navigate into the 000-kernel folder that is created, to 000-kernel/lib/modules/`uname -r`/kernel/drivers/
delete the 'net' folder
go back to your desktop, delete the 000-kernel.xzm module
right click on the 000-kernel folder, and select 'convert to xzm module'

You now have a remastered 000-kernel.xzm module on your desktop. Overwrite it to your /porteus/base/000-kernel.xzm, and your kernel module is now missing the 'net' folder.

If you are building this into a new ISO rather than a flash drive, then you should copy all of the files from the ISO to another location, like your desktop, switch out the 000-kernel.xzm modules (put your new one in /porteus/base and delete the old one), then run the make_iso.sh script inside the /porteus folder (the one in your temporary location). That will take all of the files in those /porteus and /boot folders and create an ISO image out of them, which you can burn to a CD.

Re: Modify Default Files, etc.

Posted: 06 Jun 2011, 23:51
by brokenman
If you want to be totally clean ... the initrd also contain references to the net modules you are removing. Something like: grep net /mnt/live/linuxrc should give you an idea of what to look for. You'll need to unpack the initrd:

Code: Select all

cp initrd.xz /tmp
xz -d /tmp/initrd.xz   #decompress initrd
mkdir /tmp/loop
mount -o loop /tmp/initrd /tmp/loop   # mount initrd on loopback
vi /tmp/loop/linuxrc   # or use whatever to edit
umount /tmp/loop
cd /tmp
xz --check=crc32 --x86 --lzma2 initrd   # repack your initrd

Re: [SOLVED] Modify Default Files, etc.

Posted: 01 Jan 2013, 03:07
by brokenman
Looks like fanthom has changed the format.

file /tmp/initrd
/tmp/initrd: ASCII cpio archive (SVR4 with no CRC)

cpio -t < /tmp/initrd ## Get file list
cpio --help

Re: [SOLVED] Modify Default Files, etc.

Posted: 01 Jan 2013, 14:51
by fanthom
since 2.0 rc1 we are using initramfs instead of initrd so all files are packed into CPIO archive.

to unpack:

Code: Select all

xz -d < initrd.xz | cpio -i
to pack everything back:

Code: Select all

find | cpio -H newc -o | xz --check=crc32 --x86 --lzma2 > ../initrd.xz
i'm using simple script for this task:

Code: Select all

#!/bin/bash

cd `pwd`
if [ -e initrd.xz ]; then
    xz -d < initrd.xz | cpio -i
    rm initrd.xz
else
    find | cpio -H newc -o | xz --check=crc32 --x86 --lzma2 > ../initrd.xz
fi

Re: [SOLVED] Modify Default Files, etc.

Posted: 10 Apr 2013, 22:20
by UrUtusUbU
thanks fanthom very useful.