Results 1 to 5 of 5

Thread: Want to create a tiny server distro

  1. #1
    Junior Member
    Join Date
    Feb 2006
    Posts
    3

    Want to create a tiny server distro

    Hi,

    I want to create a very, very small Knoppix distribution. All it needs to have is hardware support (including PCMCIA network devices), DHCP server and Samba server. I'm basically wanting to make a bootable CD that will enable a PC/Laptop to act as a NAS device.

    Can anyone suggest how best to go about this? I've been through one of the remastering howtos, but it starts with a full-blown GUI source. What I really want to do is start with a minimal install and add the packages I need.

    Thanks in advance for any suggestions!

    Iain

  2. #2
    Junior Member
    Join Date
    Feb 2004
    Posts
    3
    NOTE: I have not tried this (yet) so I really don't know how well it will work. However, you could try knoppifying a basic debian install-- Fabian has apparenlty done this (http://www.knoppix.net/wiki/Knoppix_From_Scratch).

    Finding the Knoppix specific deb packages has, for me, been a problem so I wrote the following perl script to extract the needed deb's from a running Knoppix session.

    Good luck.

    --greg

    Code:
    #!/usr/bin/perl -w
    ########################################################################
    
    =head1 NAME
    
    deb_digger.pl
    
    =head1 SYNOPSIS
    
    B<deb_digger.pl> <wanted package> [base dir]
    
    Where <wanted package> is the package to extract and [base dir] is 
    the (optional) directory to save the extracted deb file to.
    
    =head1 DESCRIPTION
    
    Attempts to extract and rebuild a usable Debian package using nothing 
    more than the files/metadata for an installed Debian package. 
    
    The motivation for this has to do with wanting to create a custom
    Knoppix-from-scratch live CD without having to either pare down an 
    existing knoppix CD or build up a minimalist derivative such as DSL.
    
    Ideally, I'd like to extract the Knoppix specific packages from a live Knoppix 
    session ala:
    
      for i in `dpkg-query -W --showformat='${Package}\n' | grep -i knoppix` ;
        do
        echo "### $i #######################################"
        perl deb_digger.pl $i
        echo ""
      done
    
    and apply the resulting deb files to a vanilla Debian install.
    
    =head1 LIMITATIONS
    
    This will neither slice, dice or make Julianne fries. But wait, if you 
    act now you won't get a bonus set of ginzu steak knifes or a pocket 
    fisherman either.  
    
    =head1 AUTHOR
    
    gsiems
    
    =head1 HISTORY
    
    2006.02.07 Created.
    
    =cut
    
    ########################################################################
    
    use strict;
    
    my $wanted_package = $ARGV[0] || die "Usage: $0 <wanted package> [base dir]\n";
    my $base_dir       = $ARGV[1] || './dug_up_debs';
    
    my %deb = get_deb_data($wanted_package);
    
    # control file
    $deb{control} = get_control_file($wanted_package);
    die "No control file found for $wanted_package.\n" unless ($deb{control});
    
    # file list
    my @file_list = get_file_list($wanted_package);
    die "No list file found for $wanted_package.\n" unless (@file_list);
    push @{$deb{list}}, @file_list;
    
    # MD5's
    my @md5sums = get_md5sums($wanted_package);
    die "No MD5's for $wanted_package.\n" unless (@md5sums);
    push @{$deb{md5sums}}, @md5sums;
    
    # What shall we name the deb?
    my $deb_dir = "$base_dir/${wanted_package}";
    for (qw(version architecture)) {
    	$deb_dir .= '-' . $deb{$_} if ($deb{$_});
    }
    
    `rm -rf ${deb_dir}` if (-d ${deb_dir});
    
    #######################################
    # Write/copy/create the control.tar.gz pieces
    `mkdir -p ${deb_dir}/DEBIAN`;
    
    # write the control, list, and md5sums files
    write_file("${deb_dir}/DEBIAN/control", '644', $deb{control});
    write_file("${deb_dir}/DEBIAN/list",    '644', @{$deb{list}});
    write_file("${deb_dir}/DEBIAN/md5sums", '644', @{$deb{md5sums}});
    
    # copy any other files found in /var/lib/dpkg/info/
    foreach (`ls /var/lib/dpkg/info/${wanted_package}.*`) {
    	chomp;
    	my $file_name = filename($_);
    	my $target = "${deb_dir}/DEBIAN/" . (split /\./, $file_name)[-1];
    	`cp -p ${_} ${target}` unless (-e $target);
    }
    
    #######################################
    # Write/copy/create the data.tar.gz pieces
    foreach my $source (@{$deb{list}}) {
    	chomp $source;
    	my (undef, undef, $mode, undef, $uid, $gid) = stat $source;
    
    	my $target = "${deb_dir}/${source}";
    	if (-d $source) {
    		`mkdir -p $target`;
    		chmod $mode, $target;
    		`chown $uid.$gid $target`;
    	} elsif (-f $source) {
    		`cp -p $source $target`;
    	}
    }
    
    #######################################
    `dpkg-deb --build ${deb_dir}`;
    
    #######################################################################
    
    sub filename {
    	my $filename = (split /\//, $_[0])[-1];
    	return $filename;
    }
    
    sub read_file {
    	my ($source) = @_;
    	open(IN, '<', $source) || die "Could not open $source for input. $!\n";
    	my @ary = (<IN>);
    	close IN;
    	return wantarray() ? @ary : (join '', @ary);
    }
    
    sub write_file {
    	my $target = shift;
    	my $mode   = shift;
    	open(OUT, '>', $target) or die "Could not open $target for output. $!\n";
    	print OUT @_;
    	close OUT;
    	chmod $mode, $target;
    }
    
    sub get_control_file {
    	my ($wanted_package, $status_file) = @_;
    	$status_file ||= '/var/lib/dpkg/status';
    	my $control;
    	my $raw_data = read_file($status_file);
    
    	# ASSERTION: it appears theat the first attribute in the status file
    	# for any given package is the package name.
    
    	foreach my $pkg_control (split /Package:\s+/, $raw_data) {
    		my ($package) = split /\n/, $pkg_control, 2;
    		next unless ($package && $package eq $wanted_package);
    
    		$control = 'Package: ';
    		foreach (split /\n/, $pkg_control) {
    			next if (/^Status:/);
    			$control .= $_ . "\n";
    		}
    		last;
    	}
    	return $control;
    }
    
    sub get_deb_data {
    	my ($wanted_package) = @_;
    	my %deb_data;
    	my $cmd    = q(dpkg-query -W --showformat='${Version}\t${Architecture}');
    	my $result = (`$cmd ${wanted_package}`)[0];
    	unless ($result =~ /No packages found/) {
    		my ($version, $architecture) = split /\t/, $result;
    		$deb_data{version}      = $version      || '0.0.0';
    		$deb_data{architecture} = $architecture || '';
    	}
    	return %deb_data;
    }
    
    sub get_file_list {
    	my ($wanted_package, $list_file) = @_;
    	$list_file ||= "/var/lib/dpkg/info/${wanted_package}.list";
    	my @list;
    	if (-f $list_file) {
    		my @listed = read_file($list_file);
    		chomp @listed;
    		foreach (@listed) {
    			if (-d $_ || -f $_) {
    				push @list, "$_\n";
    			} else {
    				warn "File or directory is missing: $_.\n";
    			}
    		}
    	}
    	return @list;
    }
    
    sub get_md5sums {
    	my ($wanted_package, $md5_file) = @_;
    	$md5_file ||= "/var/lib/dpkg/info/${wanted_package}.md5sums";
    	my @md5sums;
    
    	if (-f $md5_file) {
    		my @md5s = read_file($md5_file);
    		chomp @md5s;
    		foreach (@md5s) {
    			my ($md5, $file) = split /\s+/, $_, 2;
    			$file = '/' . $file;
    
    			if (-f $file) {
    				my $check = (`md5sum $file`)[0];
    				my ($md5_check) = split /\s+/, $check;
    				($md5_check eq $md5) || warn "MD5 for $file does not match.\n";
    
    				push @md5sums, $check;
    
    			} else {
    				warn "File $file not found.\n";
    			}
    		}
    	} else {
    		warn "No MD5 file found for $wanted_package.\n";
    	}
    	return @md5sums;
    }
    
    __END__

  3. #3
    Junior Member
    Join Date
    Feb 2006
    Posts
    3
    Hi,

    Thanks for the tip, and the script.

    Like you, the problem I'm having is finding the debs! The Knoppix debs aren't available in the location in the default sources.list file (developer.linuxtag.net), and the replacement location (debian-knoppix.alioth.debian.org) doesn't contain any binary packages. Aargh!!!

    Your script works fine, but in my release of Knoppix (4.0) the installation of the package knoppix-autoconfig can't be found (although /etc/init.d/knoppix-autoconfig exists). A few others are the same... Without them the knoppify script fails

    So... I think I'm a bit stuck until the debs appear.

    Cheers,

    Iain

  4. #4
    Junior Member
    Join Date
    Feb 2004
    Posts
    3
    Now this is unexpected...

    Code:
    root@1[knoppix]# cat /etc/knoppix-version
    4.0.2 2005-09-12
    
    root@1[knoppix]# grep knoppix-autoconfig /var/lib/dpkg/info/*list
    /var/lib/dpkg/info/sysvinit.list:/etcinit.d/knoppix-autoconfig
    I would have thought that it [knoppix-autoconfig] would have been found in a *knoppix* package.

    Hmm...

    Code:
    root@1[knoppix]# grep -c knoppix /var/lib/dpkg/info/*list | grep -v ':0' | cut -d ':' -f 1 | cut -d '/' -f 6 | sed 's/\.list//'
    shows a couple of packages that have something knoppix inside but without "knoppix" in the package name. Perhaps the knoppify script should be used as more of a guide than run as a script.

    --greg

  5. #5
    Junior Member
    Join Date
    Feb 2006
    Posts
    3
    Hmmm. I had a go at picking through the script. In the end I attacked it from a different angle - start with DSL and add the few components that I need! I've got it 95% working already!

    Thanks again,

    Iain

Similar Threads

  1. Streaming Server on a SMALL distro on ancient laptop
    By rec9140 in forum Other Live CDs
    Replies: 0
    Last Post: 09-21-2006, 03:04 AM
  2. Create Distro Online?!
    By counsel in forum Customising & Remastering
    Replies: 1
    Last Post: 08-17-2005, 07:58 PM
  3. Tiny Tiny Fonts???
    By ackelley in forum MS Windows & New to Linux
    Replies: 1
    Last Post: 04-03-2005, 01:07 AM
  4. Replies: 0
    Last Post: 06-11-2004, 06:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Netac DDR4 32GB 16GB DDR4 3200MHz UDIMM C16 Desktop Internal Memory RAM Kit picture

Netac DDR4 32GB 16GB DDR4 3200MHz UDIMM C16 Desktop Internal Memory RAM Kit

$99.99



A-Tech 8GB DDR3 1600 PC3-12800 Laptop SODIMM 204-Pin Memory RAM PC3L DDR3L 1x 8G picture

A-Tech 8GB DDR3 1600 PC3-12800 Laptop SODIMM 204-Pin Memory RAM PC3L DDR3L 1x 8G

$21.68



Major Brand 16GB (2x8GB) PC3-12800U DDR3-1600MHz DDR3-12800 DESKTOP RAM NON-ECC picture

Major Brand 16GB (2x8GB) PC3-12800U DDR3-1600MHz DDR3-12800 DESKTOP RAM NON-ECC

$29.99



NEW IN BOX - Corsair Vengeance RGB 32gb (2x16gb) DDR6200 CL36 CMH32GX5M2B6200C3 picture

NEW IN BOX - Corsair Vengeance RGB 32gb (2x16gb) DDR6200 CL36 CMH32GX5M2B6200C3

$550.00



DDR4 Laptop RAM 4GB 8GB 16GB 32GB 2400 2666 3200 Samsung Hynix picture

DDR4 Laptop RAM 4GB 8GB 16GB 32GB 2400 2666 3200 Samsung Hynix

$66.00



ADATA XPG Lancer Blade RGB 32GB (2x16GB) DDR5-6000 CL30 Desktop RAM Black picture

ADATA XPG Lancer Blade RGB 32GB (2x16GB) DDR5-6000 CL30 Desktop RAM Black

$429.94



Samsung 16GB LPCAMM2 PC5 7500 DDR5 LPDDR5X CAMM2 M561K1LC4DM0-CCTGM RAM Memory picture

Samsung 16GB LPCAMM2 PC5 7500 DDR5 LPDDR5X CAMM2 M561K1LC4DM0-CCTGM RAM Memory

$189.00



RAMAXEL Lenovo 32GB LPDDR5X CAMM2 7500MHz Laptop RAM | UNTESTED picture

RAMAXEL Lenovo 32GB LPDDR5X CAMM2 7500MHz Laptop RAM | UNTESTED

$445.00



LOT OF 4  Samsung 16GB DDR4-2666 ECC UDIMM 2Rx8 PC4-21300 M391A2K43BB1-CTDQ picture

LOT OF 4 Samsung 16GB DDR4-2666 ECC UDIMM 2Rx8 PC4-21300 M391A2K43BB1-CTDQ

$469.95



Micron 32GB 1x32GB DDR5 5600 CL46 ECC Unbuffered SO-DIMM MTC20C2085S1TC56BD1 picture

Micron 32GB 1x32GB DDR5 5600 CL46 ECC Unbuffered SO-DIMM MTC20C2085S1TC56BD1

$399.00