Hello,
I've hacked a little script together for integrating ntfs-3g into the initrd. I'm using this to set up a system where I need to put the tce directory inside an ntfs-partition. It is intended to be used together with the grub4dos.tcz package, which includes everything needed to start Tiny Core Linux using the Windows Bootloader.
#!/bin/sh
if [ -f /opt/.tce_dir ]; then
TCEDIR=$(cat /opt/.tce_dir)
else
TCEDIR=/tmp/tce
fi
TMPDIR=/tmp/initrd.d
TCLOOP=/tmp/tcloop
TCENAMES="ntfs-3g"
installtcz()
{
for tce in $@;do
if [ ! -d ${TCLOOP}/${tce} ]; then
if [ ! -f ${TCEDIR}/optional/${tce}.tcz ]; then
echo "downloading ${tce}"
tce-load -w ${tce}
fi
echo "installing ${tce}"
tce-load -i ${TCEDIR}/optional/${tce}.tcz
if [ ! -d ${TCLOOP}/${tce} ]; then
echo "${tce} seems to be installed, but not via loopback, forcing it."
sudo mkdir -p ${TCLOOP}/${tce}
sudo mount -o loop ${TCEDIR}/optional/${tce}.tcz ${TCLOOP}/${tce}
fi
fi
echo "copying ${tce} to new initrd"
(cd ${TCLOOP}/${tce} ; find * ! -type d | xargs tar cf -) |
(cd ${TMPDIR};sudo tar xf -)
touch ${TMPDIR}/usr/local/tce.installed/${tce}
done
}
if [ "$(id -u)" -eq 0 ]; then
echo do not run as root, sudo will called when necessary
exit 0
fi
if [ ! -f "${1}" ]; then
echo "usage: ${0} initrd.gz [initrd_ntfs.gz]"
exit 0
fi
sudo rm -rf ${TMPDIR}
sudo mkdir -p ${TMPDIR}
echo "unpacking initrd"
gzip -dc ${1} | (cd ${TMPDIR};sudo cpio -i)
echo "creating /usr/local/tce.installed"
sudo mkdir -p ${TMPDIR}/usr/local/tce.installed
sudo chown ${USER}:staff ${TMPDIR}/usr/local/tce.installed
installtcz ${TCENAMES}
sudo chroot ${TMPDIR} ldconfig
sudo sed -i 's/\$(blkid \$1)/$(blkid $1|sed s@TYPE=\\"ntfs\\"@TYPE=\\"ntfs-3g\\"@g)/' ${TMPDIR}/usr/sbin/fstype
ntfscpio="${2}"
[ -z "${ntfscpio}" ] && ntfscpio="tinycore+ntfs.gz"
echo "creating new initrd"
(cd ${TMPDIR};find .|sudo cpio -H newc -o) | gzip -9 > "${ntfscpio}"
[ -x /usr/local/bin/advdef ] && /usr/local/bin/advdef -z4 "${ntfscpio}"
(edit 1: bugfix in sed-script for patching fstype)