美文网首页EmuELEC
生成较小的Emuelec镜像

生成较小的Emuelec镜像

作者: Armlinux | 来源:发表于2020-12-25 10:41 被阅读0次

以下为脚本内容,实现的功能是:

从较大的EmuELEC镜像中读取部分内容,创建较小(3.5GB)的EmuELEC镜像(Backup_system.img)
#!/bin/sh
#backup for Emuelec 3.3.1
echo "creating img 3.5GB image file..."
#fallocate -l $(( 3584 * 1024 *1024 )) Backup_system.img 
#dd if=/dev/zero of=Backup_system.img  bs=1M count=0 seek=3584
truncate -s 3584M Backup_system.img 
echo "create fdisk.cmd"
cat > fdisk.cmd <<-EOF
o
n
p
1

+544MB
t
c
n
p
2


a
1
w
EOF
# 以上内容空行表示是采用默认参数 都不能随意改动
echo "fdisk.cmd done!"
echo "disk partition..."
fdisk Backup_system.img < fdisk.cmd
echo "Done!"
echo "losetup loop0..."
#losetup -f -P --show Backup_system.img
losetup -d /dev/loop0
losetup -d /dev/loop1
losetup -P loop0 Backup_system.img
losetup -P loop1 EmuELEC.img
echo "mount and format..."
mkfs.vfat -n "EMUELEC" /dev/loop0p1
mke2fs -F -q -t ext4 -L STORAGE -m 0 /dev/loop0p2
mkdir /mnt/emu_img -p
mount /dev/loop0p2 /mnt/emu_img
mkdir /mnt/emu_img/EmuELEC
mount /dev/loop0p1 /mnt/emu_img/EmuELEC
mkdir /mnt/EmuELEC -p
mkdir /mnt/sys -p
mount /dev/loop1p1 /mnt/EmuELEC
mount /dev/loop1p2 /mnt/sys

echo "Begin backup system..."

cd /mnt/sys
DIR_INSTALL=/mnt/emu_img
cp -r /mnt/EmuELEC/* /mnt/emu_img/EmuELEC/
# for file in `ls |grep -v roms|xargs` 
#  for file in 后面是所需要读取复制的内容  未包含roms 后期自己添加
for file in backup   .config   .emulationstation  joypads     overlays           remappings  savestates   .ssh  .tmp   .bash_history  cores     .fbtermrc          .local      playlists    screenshots  system      .update assets  .cache         database  ip.txt   lost+found  .please_resize_me  savefiles   shaders      thumbnails
do
echo "tar -cf - $file | (cd $DIR_INSTALL; tar -xpf -)"
tar -cf - $file | (cd $DIR_INSTALL; tar -xpf -)
done
sync
echo "umount..."
cd /
umount /mnt/emu_img/EmuELEC
umount /mnt/emu_img
losetup -d /dev/loop0

umount /mnt/EmuELEC
umount /mnt/sys
losetup -d /dev/loop1
echo "All done! Please check back_system_du.txt and  system_du.txt in /ddbr."

相关文章

网友评论

    本文标题:生成较小的Emuelec镜像

    本文链接:https://www.haomeiwen.com/subject/nfgjwktx.html