For my application, the space on the eMMC is beginning to get a little
tight. I decided to write a new "flash" script that would flash the eMMC,
but set it up using btrfs with compression for the root. It's a bit
tricky since the uboot stuff doesn't support it so the /boot needs to be
ext2/4 and all the device tree files it needs also needs to be on that
partition. Anyway, I did get it all working. I've attached my script.
Basically, it creates a 128MB /boot (/dev/mmcblk1p1) to hold the kernel
and initial filesystem and a /lib/firmware that just houses the various
Beaglebone devicetree files. It then uses the rest of the eMMC
(/dev/mmcblk1p2) as a btrfs filesystem with zlib compression for the
flash. It then rsyncs everything over and creates a new /etc/fstab file,
updates the boot/uEnv.txt to mark the root as btrfs, and builds and copies
all the bb overlay dts things over. For the fstab, I have it mounting
with compression=lzo as the data for my app works very well for that (I
need the extra CPU when loading/saving my files), but you could keep that
as zlib as well.
For my app, this leaves well over 2GB of free space on the eMMC as compared
to about 500MB before. Performance is about the same. Anyway, I
thought I'd share it with others in case they want to try it out, play with
it, suggest enhancements, etc....
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/beagleboard/d0a0a946-a5d9-4eb1-ac01-dc50c83039bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
#!/bin/sh
DEVICE="/dev/mmcblk1"
echo "---------------------------------------"
echo "Creating partitions"
echo ""
# create partitions
sfdisk --force ${DEVICE} <<-__EOF__
4M,124M,,*
128M,,,-
__EOF__
blockdev --rereadpt ${DEVICE}
fdisk -l ${DEVICE}
echo "---------------------------------------"
echo "Formating partitions"
echo ""
#format partitions
mkfs.ext4 -F -O ^metadata_csum,^64bit ${DEVICE}p1 -L bootfs
mkfs.btrfs -f ${DEVICE}p2 -L rootfs
echo "---------------------------------------"
echo "Installing bootloader "
echo ""
#install bootloader
dd if=/opt/backup/uboot/MLO of=/dev/mmcblk1 count=1 seek=1 conv=notrunc bs=128k
dd if=/opt/backup/uboot/u-boot.img of=/dev/mmcblk1 count=2 seek=1 conv=notrunc bs=384k
echo "---------------------------------------"
echo "Creating mount points and mounting rootfs"
echo ""
#mount
mkdir /tmp/rootfs
mount -t btrfs -o noatime,nodiratime,compress-force=zlib ${DEVICE}p2 /tmp/rootfs
mkdir /tmp/rootfs/boot
mount -t ext4 -o noatime ${DEVICE}p1 /tmp/rootfs/boot
echo "---------------------------------------"
echo "Copy files rootfs"
echo ""
#copy files
rsync -aAx --human-readable --info=name0,progress2 /ID.txt /bin /boot /dev /etc /home /lib /lost+found /media /mnt /opt /proc /root /run /sbin /srv /sys /tmp /usr /var /tmp/rootfs --exclude=/dev/* --exclude=/proc/* --exclude=/sys/* --exclude=/tmp/* --exclude=/run/* --exclude=/mnt/* --exclude=/media/* --exclude=/lost+found --exclude=/uEnv.txt
echo "---------------------------------------"
echo "Configure /boot"
echo ""
#configure /boot
cd /tmp/rootfs/boot
ln -s . boot
cd /
cd /opt/source/bb.org-overlays
make clean
make
mkdir /tmp/rootfs/boot/lib
mkdir /tmp/rootfs/boot/lib/firmware
cp /opt/source/bb.org-overlays/src/arm/* /tmp/rootfs/boot/lib/firmware
echo "" >> /tmp/rootfs/boot/uEnv.txt
echo "mmcrootfstype=btrfs" >> /tmp/rootfs/boot/uEnv.txt
echo "rootfstype=btrfs" >> /tmp/rootfs/boot/uEnv.txt
echo "mmcpart=2" >> /tmp/rootfs/boot/uEnv.txt
echo "" >> /tmp/rootfs/boot/uEnv.txt
echo "---------------------------------------"
echo "Configure /etc/fstab"
echo ""
#configure fstab
echo "/dev/mmcblk1p2 / btrfs noatime,nodiratime,compress-force=lzo 0 1" > /tmp/rootfs/etc/fstab
echo "/dev/mmcblk1p1 /boot ext4 defaults,noatime,nodiratime 0 2" >> /tmp/rootfs/etc/fstab
echo "debugfs /sys/kernel/debug debugfs defaults 0 0" >> /tmp/rootfs/etc/fstab
echo "---------------------------------------"
echo "Cleaning up"
echo ""
rm -rf /tmp/rootfs/etc/ssh/*key*
rm -rf /tmp/rootfs/var/lib/connman/eth*
rm /tmp/rootfs/var/log/*
rm /tmp/rootfs/var/log/samba/*
echo "---------------------------------------"
echo "Unmounting filesystems"
echo ""
umount /tmp/rootfs/boot
umount /tmp/rootfs
echo "---------------------------------------"
echo "Done flashing eMMC, powering down"
echo ""
systemctl poweroff || halt