[SOLVED] Modify Default Files, etc.

New features which should be implemented in Porteus; suggestions are welcome. All questions or problems with testing releases (alpha, beta, or rc) should go in their relevant thread here, rather than the Bug Reports section.
DoomUs
White ninja
White ninja
Posts: 21
Joined: 06 Jun 2011, 17:04
Location: New Mexico

[SOLVED] Modify Default Files, etc.

Post#1 by DoomUs » 06 Jun 2011, 19:27

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.
Last edited by DoomUs on 10 Jun 2011, 15:30, edited 1 time in total.

User avatar
fanthom
Moderator Team
Moderator Team
Posts: 5666
Joined: 28 Dec 2010, 02:42
Distribution: Porteus Kiosk
Location: Poland
Contact:

Re: Modify Default Files, etc.

Post#2 by fanthom » 06 Jun 2011, 19:43

@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
Please add [Solved] to your thread title if the solution was found.

DoomUs
White ninja
White ninja
Posts: 21
Joined: 06 Jun 2011, 17:04
Location: New Mexico

Re: Modify Default Files, etc.

Post#3 by DoomUs » 06 Jun 2011, 21:03

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?

User avatar
Ahau
King of Docs
King of Docs
Posts: 1331
Joined: 28 Dec 2010, 15:18
Distribution: LXDE & Xfce 32/64-bit
Location: USA

Re: Modify Default Files, etc.

Post#4 by Ahau » 06 Jun 2011, 22:14

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.
Please take a look at our online documentation, here. Suggestions are welcome!

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Re: Modify Default Files, etc.

Post#5 by brokenman » 06 Jun 2011, 23:51

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
How do i become super user?
Wear your underpants on the outside and put on a cape.

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Re: [SOLVED] Modify Default Files, etc.

Post#6 by brokenman » 01 Jan 2013, 03:07

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
How do i become super user?
Wear your underpants on the outside and put on a cape.

User avatar
fanthom
Moderator Team
Moderator Team
Posts: 5666
Joined: 28 Dec 2010, 02:42
Distribution: Porteus Kiosk
Location: Poland
Contact:

Re: [SOLVED] Modify Default Files, etc.

Post#7 by fanthom » 01 Jan 2013, 14:51

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
Please add [Solved] to your thread title if the solution was found.

UrUtusUbU
Black ninja
Black ninja
Posts: 73
Joined: 21 Apr 2012, 00:19
Distribution: Hannah Montana Linux
Location: inmygrave

Re: [SOLVED] Modify Default Files, etc.

Post#8 by UrUtusUbU » 10 Apr 2013, 22:20

thanks fanthom very useful.

Post Reply