= split the Centos code over 2 different physical media. == introduction The original documentation will guide you to use dd for putting the OS on a microSD card. The result is a microSD card with 3 partions: ---- Device Boot Start End Blocks Id System /dev/mmcblk0p1 2048 1026047 512000 c W95 FAT32 (LBA) /dev/mmcblk0p2 1026048 2074623 524288 82 Linux swap / Solaris /dev/mmcblk0p3 2074624 30253055 14089216 83 Linux ---- However, in this tutorial, we are going to put only the boot and swap partition on a very small microSD card, in our case 2GB. The root partition will be put on an external (more reliable) media such as an USB key or a SSD disk via the USB bus. In our scenario, both devices, a microSD and an USB key will be mounted as /dev/sdb. WARNING: this procedure will unconditionally re-partition and format your disk(s). == prepare wget http://mirror.centos.org/altarch/7/isos/armhfp/CentOS-Userland-7-armv7hl-Minimal-1708-RaspberryPi3.img.xz xz -dv CentOS-Userland-7-armv7hl-Minimal-1708-RaspberryPi3.img.xz kpartx -av CentOS-Userland-7-armv7hl-Minimal-1708-RaspberryPi3.img ---- add map loop0p1 (253:4): 0 1024000 linear /dev/loop0 2048 add map loop0p2 (253:5): 0 1048576 linear /dev/loop0 1026048 add map loop0p3 (253:6): 0 4194304 linear /dev/loop0 2074624 ---- == micro SD card TIP: umount the (auto)mounted disk: umount /dev/sdb1 parted -s /dev/sdb mklabel "msdos" partprobe /dev/sdb parted --align optimal -s /dev/sdb mkpart primary 0% "512M" parted --align optimal -s /dev/sdb mkpart primary "512M 100%" sfdisk --part-type /dev/sdb "1" "0C" sfdisk --part-type /dev/sdb "2" "82" mkfs.vfat -n "BOOT" /dev/sdb1 mkswap -L "swap" /dev/sdb2 mkdir -p /mnt/source /mnt/target mount /dev/mapper/loop0p1 /mnt/source mount /dev/sdb1 /mnt/target rsync -aiP /mnt/source/* /mnt/target/ sed -i 's~root=/dev/mmcblk0p3~root=/dev/sda1~' /mnt/target/cmdline.txt sync; umount /mnt/source/ /mnt/target/ eject == external USB key TIP: umount the (auto)mounted disk: umount /dev/sdb1 parted -s /dev/sdb mklabel "msdos" partprobe /dev/sdb parted --align optimal -s /dev/sdb mkpart primary "0% 100%" sfdisk --part-type /dev/sdb "1" "83" mkfs.ext4 -L "root" -m 1 /dev/sdb1 mkdir -p /mnt/source /mnt/target mount /dev/mapper/loop0p3 /mnt/source mount /dev/sdb1 /mnt/target rsync -aiP /mnt/source/* /mnt/target/ echo "#" > /mnt/target/etc/fstab echo "LABEL=BOOT /boot vfat noatime 0 0" >> /mnt/target/etc/fstab echo "LABEL=swap swap swap noatime 0 0" >> /mnt/target/etc/fstab echo "LABEL=root / ext4 noatime 0 0" >> /mnt/target/etc/fstab sync; umount /mnt/source/ /mnt/target/ eject == cleanup rm -fr /mnt/source/ /mnt/target/ kpartx -dv CentOS-Userland-7-armv7hl-Minimal-1708-RaspberryPi3.img ---- del devmap : loop0p3 del devmap : loop0p2 del devmap : loop0p1 loop deleted : /dev/loop0 ----