[Peeweelinux] CF Read Write Partition

Joe A Cairns [email protected]
Mon, 4 Aug 2003 12:36:02 -0500


Adilson,

First thing thanks for you help.

I am using a 128 mb CF card.

What I did was modify the pwl_target_load scripts. Here is what mine
looks like:

func_rd_build_comp_rd_ext2 () {

    # sanity check
    func_rd_sanity || return 1

    # determine filesystem size (w/o kernel)
    rd_size_fs=`du -s -k --exclude=$rd_kernel $rd_projectroot | cut -f
1`
    # add free space
    rd_size_fs=$((rd_size_fs + rd_ramdisk_free))

    # create loopback and format
    func_rd_make_loopback $rd_size_fs || return 1

    # mount loopback
    func_rd_action m "Mounting loopback device..."
    mount -t ext2 $rd_loop_dev $rd_mount
    func_rd_action test || return 1

    # remove the lost+found directory
    rm -rf $rd_mount/lost+found

    # copy files using tar since tar makes it easy to exclude things
    func_rd_action m "Copying files to loopback device..."
    tar cp \
        --exclude=$rd_kernel \
        --directory=$rd_projectroot ./ | tar xp --directory=$rd_mount
    if [ "$?" = "0" ]; then
        func_rd_action s
    else
        func_rd_action w
    fi

    # add fstab and rc.init

    # make some noise
    func_rd_action m "Creating fstab and rc.init..."

    # see if we're allowed to
    if [ "$rd_initscripts" = "y" ]; then

        # lets do it!
        func_rd_fstab_comp_rd_ext2 > $rd_mount/etc/fstab
        func_rd_init_rd > $rd_mount/rc.init

        # make sure rc.init is executable
        chmod 755 $rd_mount/rc.init

        # send the ok
        func_rd_action s
    else

        # duh we're not configured print a warning
        func_rd_action w
    fi

    # fix inittab
    func_rd_fix_inittab etc

    # run library loader and include XFree86 lib directory
    func_rd_action m "Building ld.so.cache..."
    ldconfig -v -r $rd_mount /usr/X11R6/lib >>$rd_log 2>&1
    func_rd_action test

    # unmount loopback
    func_rd_action m "Unmounting loopback device..."
    umount $rd_loop_dev
    func_rd_action test

    # compress the ramdisk
    func_rd_action m "Compressing $rd_loop_dev into $rd_ramdisk..."
    { dd if=$rd_loop_dev bs=1k count=$rd_size_fs | gzip -v9 >
$rd_tmp/$rd_ramdisk; } >>$rd_log 2>&1
    func_rd_action test

    # free the loopback device
    func_rd_break_loopback

    # calculate size
    func_rd_action m "Determining space on target device..."
    # get flash size
    rd_size_avail=`sfdisk -s $rd_target`
    # get ramdisk size
    rd_size_ramdisk=`du -s -k $rd_tmp/$rd_ramdisk | cut -f 1`
    # get kernel size
    rd_size_kernel=`du -s -k $rd_projectroot/boot/$rd_kernel | cut -f 1`

    # Do we have enough room?
    if [ $((rd_size_kernel + rd_size_ramdisk + rd_size_margin)) -ge
$rd_size_avail ]; then
        func_rd_action f
        echo "  +Available Space: $rd_size_avail"
        echo "  +Required Space:  $((rd_size_kernel + rd_size_ramdisk +
rd_size_margin))"
        echo "  +Available Space: $rd_size_avail" >>$rd_log
        echo "  +Required Space:  $((rd_size_kernel + rd_size_ramdisk +
rd_size_margin))" >>$rd_log
        return 1
    else
        func_rd_action s
    fi

    # fdisk target device
    func_rd_action m "Partition traget device $rd_target..."
#    sfdisk $rd_target >>$rd_log 2>&1 <<-EOF
#,,83,*
    sfdisk -uM $rd_target >>$rd_log 2>&1 <<-EOF
,100,83,*
,,83
;
EOF
    func_rd_action test

    # create the ext2 filesystem
    func_rd_action m "Creating ext2 filesystem on ${rd_target}1..."
    mke2fs -b 4096 -m0 ${rd_target}1 >>$rd_log 2>&1
    func_rd_action test
    func_rd_action m "Creating ext2 filesystem on ${rd_target}2..."
    mke2fs -b 1024 -m0 ${rd_target}2 >>$rd_log 2>&1
    func_rd_action test
#    func_rd_action m "Creating ext2 filesystem..."
#    mke2fs -i 8192 -b 4096 -m0 ${rd_target}1 >>$rd_log 2>&1
#    func_rd_action test
    sleep 1

    # mount target
    func_rd_action m "Mount the target device ${rd_target}1..."
    mount -t ext2 ${rd_target}1 $rd_mount
    func_rd_action test

    # remove the lost+found directory
    rm -rf $rd_mount/lost+found

    # copy files
    func_rd_action m "Copying ramdisk, kernel and boot.b..."
    cp -f $rd_tmp/$rd_ramdisk $rd_mount/$rd_ramdisk
    cp -f $rd_projectroot/boot/$rd_kernel $rd_mount/$rd_kernel
    cp -f $rd_bootb $rd_mount/boot.b
    func_rd_action test

    # create lilo.conf
    func_rd_action m "Creating lilo.conf in a temporary location..."
    # lets amend the ramdisk size and make sure the kernel
    # will boot the ramdisk without complaining
    rd_bp_initrd=$rd_mount/$rd_ramdisk
    rd_bp_root=/dev/ram0
    rd_bp_rd=$((rd_size_fs + rd_bp_rd_margin))
    func_rd_boot_lilo > $rd_tmp/lilo.conf
    func_rd_action test

    # run lilo
    func_rd_action m "Installing lilo bootloader..."
    lilo -v -C $rd_tmp/lilo.conf >>$rd_log 2>&1
    func_rd_action test

    # optionally we create the config.tgz file from config.lst

    # unmount target
    func_rd_action m "Unmounting target device ${rd_target}1..."
    umount ${rd_target}1
    func_rd_action test

    # mount target
    func_rd_action m "Mount the target device ${rd_target}2..."
    mount -t ext2 ${rd_target}2 $rd_mount
    func_rd_action test

    # remove the lost+found directory
    rm -rf $rd_mount/lost+found

    # copy files
    func_rd_action m "Copying Application $rd_projectroot/MTAtm to
$rd_mount..."
    cp -r $rd_projectroot/../MTAtm  $rd_mount
#    tar cp \
#        --directory=$rd_projectroot/MTAtm ./ | tar xp
--directory=$rd_mount
    func_rd_action test

    # unmount target
    func_rd_action m "Unmounting target device ${rd_target}2..."
    umount ${rd_target}2
    func_rd_action test

    # clean up
}


Thanks,

Joe

> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of Adilson Oliveira
> Sent: Monday, August 04, 2003 12:16 PM
> To: [email protected]
> Subject: Re: [Peeweelinux] CF Read Write Partition
> 
> 
> Joe A Cairns wrote:
> > Adilson,
> > 
> > When I try to mount it states that /dev/hda2 is not a valid block 
> > device.
> > 
> 
> Did you create the partition manualy with fdisk or cfdisk I believe. 
> After that, did you formated it using mke2fs?
> 
> 
> 
> _______________________________________________
> Peeweelinux mailing list
> [email protected] 
> http://mail.adis.on.ca/lists/listinfo/peeweeli> nux
> 
> 
>