Distribute my BLFS

Dan Nicholson dbn.lists at gmail.com
Mon Feb 19 11:08:37 PST 2007

Kevin, please don't top-post. Thanks.

On 2/19/07, Kevin Annies <anniesk at coventry.ac.uk> wrote:
> Also please tell me of anything that you don't think will work ( I have a
> bad feeling about Chrooting from a script)

I wouldn't worry about that. It's done it all the time.

I'll add a couple suggestions I could think of for find
drives/partitions. I'm sure this is not robust. One thing that would
be more powerful would be querying through HAL, but you might not have
that. I'll throw those ideas at the end.

> #!/bin/bash
> echo --The following ide drives have been found
> ls /sys/bus/ide/devices/0.0/{*hda*,*sda*}

drives=$(find /sys/block -maxdepth 1 -type d -name "[sh]d[a-z]" -printf "%P ")

> echo drives labelled hda are usually Primary/Master IDE
> echo drives labelled hdb are usually Primary/Slave IDE
> echo drives labelled hdc, usually refer to secondary IDE drives
> echo SATA & SCSI drives use the same naming convention but are instead
> labelled sda,sdb,sdc etc

I don't know if this part is really necessary or accurate all the time.

> echo pleaseselect the drive you wish to partition by typing the correct
> drive ie; hda, hdb, sda etc

echo "Enter the drive you wish to partition from the following list: $drives"
read req_drive

echo "Enter the drive you wish to partition from this list: ${drives}"
# loop until we get a valid partition
while :; do
    read req_drive
    # check if the input is in the list
    if [[ " $drives " =~ " $req_drive " ]]; then
        echo "Error: $req_drive is not a valid drive" >&2

> echo Please select your root partition

For bash:

read -p "Enter your root partition: " req_root

This would prompt and store the value in the variable req_root.

> mke2fs -jv /dev/$ROOT
> mkswap /dev/$SWAP

Probably want to check those devices exist before you start hammering them.

> cp -frv /{bin,lib,opt,usr,sbin,srv,media} $TARGET
> cp -frv /fake/needwrite/{etc,root} $TARGET

It might be better to use tar or cpio for this kind of work. Here's
and example in tar:

tar -C / -cf - . | tar -C $TARGET -xf -

Obviously, you'd need to add something to filter just the parts you
want there. The -T option could help.

If you want to get fancy and you know you have HAL where you're
building, you can be a little smarter about finding available drives
and partitions.

drive_udis=$(hal-find-by-property --key storage.drive_type --string disk)
for d in $drive_udis; do
    drive_devs+="$(hal-get-property --key block.device --udi $d) "

part_udis=$(hal-find-by-capability --capability volume)
for p in $part_udis; do
    part_devs+="$(hal-get-property --key block.device --udi $p) "

Making those variables arrays would be cleaner in bash.



More information about the blfs-support mailing list