Eu preciso criar um initramfs para carregar um driver para acessar a EMMC que contém o sistema de arquivos raiz.
switch_root
. Até aqui tudo funciona bem. Eu posso criar o initramfs, obter o kernel para carregá-lo e também fazer com que ele mude para /dev/mmcblk0p2
, que é a partição do EMMC que contém os rootfs reais.
Minha consulta:
Após a conclusão da inicialização, o comando mount mostra o seguinte:
rootfs on / type rootfs (rw) /dev/mmcblk0p2 on / type ext4 (rw,sync,noatime,data=ordered) proc on /proc type proc (rw,relatime) … /dev/mmcblk0p1 on /var/volatile/run/media/mmcblk0p1 type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,sh) /dev/mmcblk0p3 on /var/volatile/run/media/mmcblk0p3 type ext4 (rw,relatime,data=ordered) /dev/mmcblk0p4 on /var/volatile/run/media/mmcblk0p4 type ext4 (rw,relatime,data=ordered)
Se eu criar o driver da EMMC como parte do kernel (e me livrar do initramfs), a saída será muito diferente:
rootfs on / type rootfs (rw) /dev/root on / type ext4 (rw,relatime,discard,journal_checksum,commit=1,data=ordered) devtmpfs on /dev type devtmpfs (rw,relatime,size=112272k,nr_inodes=28068,mode=755) … /dev/mmcblk0p1 on /var/volatile/run/media/mmcblk0p1 type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,sh) /dev/mmcblk0p3 on /var/volatile/run/media/mmcblk0p3 type ext4 (rw,relatime,data=ordered) /dev/mmcblk0p4 on /var/volatile/run/media/mmcblk0p4 type ext4 (rw,relatime,data=ordered)
/dev/root
corresponde a /dev/mmcblk0p2
apenas. Depois de ter gasto tanto esforço para fazer o initramfs funcionar, não quero perder nada trivial. Qualquer ajuda, muito apreciada.
Os scripts que fazem isso são fornecidos abaixo:
#!/bin/sh
#Make busybox links
#/bin/busybox mkdir -p /usr/bin /sbin /bin
#BBINSTALL="/bin/busybox --install -s"
SWITCH="/bin/busybox switch_root"
INSERT="/sbin/insmod"
MOUNT="/bin/busybox mount"
UMOUNT="/bin/busybox umount"
DISKF="/bin/busybox df"
LSMOD="/bin/busybox lsmod"
LS="/bin/busybox ls"
CAT="/bin/busybox cat"
LS="/bin/busybox ls"
PRINTENV="/usr/bin/printenv"
SLEEP="/bin/busybox sleep"
PS="/bin/busybox ps"
MKDIR="/bin/busybox mkdir"
CAT="/bin/busybox cat"
GREP="/bin/busybox grep"
WC="/bin/busybox wc"
#mount proc and sysfs
$MOUNT -t proc none /proc
$MOUNT -t sysfs none /sys
#Mount NFS/EMMC - check
$CAT /proc/cmdline | $GREP -inr "/dev/nfs" | $WC -l > /var/NFSFOUND
ISNFSFOUND=$($CAT /var/NFSFOUND)
#Check if NFS was found in Kernel command line
if [ $ISNFSFOUND -ne 0 ]
then
echo "Mounting NFS:"
$MOUNT -a -t nfs -o rw,relatime,vers=2,rsize=8192,wsize=8192,namlen=255,hard,nolock,proto=udp,timeo=1,retrans=1,mountvers=1,addr=172.31.219.19 172.31.219.19:/home/user/Perforce/Mfg_Repo/ng5_mfg/b5/main/nfsroot /mnt/root/
else
#If NFS was not found, mount EMMC
if [ ! -d /mnt/root ]; then
$MKDIR /mnt/root
fi
echo "Mounting EMMC:"
$MOUNT -t devtmpfs -o rw,relatime,mode=755 none /dev
$SLEEP 1
#Load EMMC driver
echo "Inserting EMMC driver"
$INSERT /lib/mmc_block.ko
$INSERT /lib/omap.ko
$INSERT /lib/omap_hsmmc.ko
$SLEEP 1
#Mount the mount point
$MOUNT -a -t ext4 -o rw,relatime,discard,journal_checksum,commit=1,data=ordered /dev/mmcblk0p2 /mnt/root/
fi
#Unmount the current mounts
echo "Unmounting initramfs:"
if [ $ISNFSFOUND -eq 0 ]
then
echo "Unmounting devtmpfs(EMMC):"
$UMOUNT /dev
fi
#Switch to actual rootfs - This will be done by init program