- Preparation 1: Bootable SD card.
- Preparation 2: Make a reference Edison
- Enable resize-rootfs.service.
- Boot from SD card.
- Mount rootfs and check how much used.
- Create a disk image and mount it.
- Copy files from rootfs@emmc to the mounted disk image.
- Unmount the disk image and copy it to a PC.
- Rename the disk image file to edison-image-edison.ext4 and replace the same name file in unzipped firmware directory.
- Run flashall against a target Edison board.
Preparation 1
Preparation 2
Install required software, enable/disable services, add user account, etc.
Enable resize-rootfs.service
When create a disk image file, it need not copy empty blocks. So a disk image file is smaller than rootfs partition's size. After a target's rootfs partition is overwritten with a disk image, it needs to extend to an actual size. It happens when flashing by flashall/ota method too, so that there is already a service that runs only once at the first boot. Enable this service before boot from SD card. But even if you forget this, you can just run resize2fs command to extend rootfs partition. It can be done on live file system.
# systemctl enable resize-rootfs
Then reboot from SD card.
# reboot from_sdcard
Then reboot from SD card.
# reboot from_sdcard
Mount rootfs partition in eMMC and check size
After boot from SD card, mount rootfs partition in emmc and check its size.
# mkdir /mnt/emmc
# mount /dev/mmcblk0p8 /mnt/emmc
Run df and see how much used. In my case, 500MB is enough.
# df -h | grep /mnt/emmc
Filesystm Size Used Available Use% Mounted on
/dev/mmcblk0p8 1.4G 471.0M 889.0M 35% /mnt/emmc
Run df and see how much used. In my case, 500MB is enough.
# df -h | grep /mnt/emmc
Filesystm Size Used Available Use% Mounted on
/dev/mmcblk0p8 1.4G 471.0M 889.0M 35% /mnt/emmc
Create a disk image and mount
The following command creates 512MB (512KB * 1024) disk image file (edison-rootfs.ext4). If you need bigger space, modify count=1024.
# dd if=/dev/zero of=edison-rootfs.ext4 bs=512K count=1024
# mkfs.ext4 -F -L rootfs edison-rootfs.ext4
# mkdir /mnt/image
# mount -o loop edison-rootfs.ext4 /mnt/image
Copy from eMMC to disk image
It is optional, but you can delete journal files before coping.
# cd /mnt/emmc/var/log/journal
# rm -rf *
It is also optional. But if a copied Edison is used somewhere else, it would be better to delete your Wifi information.
# cd /mnt/emmc/etc/wpa_supplicant
# cp wpa_supplicant.conf.original wpa_supplicant.conf
# cp wpa_supplicant.conf.original wpa_supplicant.conf
Now, copy all files.
It seems to be better to use rsync because cp copies hard linked files as individual file. But then it needs to install rsync from opkg.
# opkg install rsync
# rsync -rlH /mnt/emmc/ /mnt/image/
Unmount and copy
# umount /mnt/image
# umount /mnt/emmc
Copy edison-rootfs.ext4 to a PC.
Clone
To make a clone, rename edison-rootfs.ext4 to edison-image-edison.ext4 and replace the same name file in a unzipped firmware directory. Then run flashall script and connect a target Edison.
(Strictly speaking, it is not a complete clone. It only copies rootfs. You might want to copy home and u-boot-env0 partitions too. To make more perfect clone, it needs to copy factory partition too. (That partition contains serial number and Bluetooth MAC address.))
(Strictly speaking, it is not a complete clone. It only copies rootfs. You might want to copy home and u-boot-env0 partitions too. To make more perfect clone, it needs to copy factory partition too. (That partition contains serial number and Bluetooth MAC address.))
0 件のコメント:
コメントを投稿