Moving Fedora ARM from SSD/MMC card to USB harddrive
WARNING!!! All examples are valid for PandaBoard A3 and Fedora 21 beta4 images. Note, that device names might differ on other boards and there's a risk of destroying your data if you select a wrong device name!
1.) Install Fedora ARM on SSD/MMC (can be skipped if you've done this already)
2.) Boot the installed system from SSD/MMC and login as root or use 'su' (as majority of the steps require root permissions)
3.) Connect the USB harddrive and obtain its device name from the 'fdisk -l' or 'dmesg' output. Look for the SSD/MMC card device name as well
SSD/MMC card ... /dev/mmcblk0
USB harddrive ... /dev/sda
4.) List the LABELs and UUIDs with 'blkid' and search for the SSD/MMC card entries (you'll need the LABELs and UUIDs later in step 6 and 7)
/dev/mmcblk0p1: LABEL="_/boot" UUID="e56831cc-9e1d-469a-b346-f8629ffddd18" TYPE="ext3" PARTUUID="e8b07d0b-01"
/dev/mmcblk0p2: LABEL="_swap" UUID="f4868832-9d74-489f-a183-51c8a4213ddc" TYPE="swap" PARTUUID="e8b07d0b-02"
/dev/mmcblk0p3: LABEL="_/" UUID="63864bcd-f2f2-4c4c-9cf8-dfc0d77d4bd7" TYPE="ext4" PARTUUID="e8b07d0b-03"
Note, that the /dev/mmcblk0p2 partition has a wrong partition type in case of Fedora 21 beta4 images. The type is 83 (Linux) and should be 82 (Linux swap), but fortunately the kernel doesn't care. The partition marked with "_/" label is the partition containing the ROOT filesystem we want to move to the USB harddrive.
5.) Use 'fdisk' for creating SWAP and ROOT partitions on the USB harddrive. The new ROOT partition needs to be big enough to hold the data from the source ROOT partition located on the SSD/MMC card.
- fdisk /dev/sda
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 4196351 4194304 2G 82 Linux swap / Solaris
/dev/sda2 4196352 71305215 67108864 32G 83 Linux
6.) The new SWAP partition needs to be initialized with 'mkswap' and the LABEL & UUID needs to match the LABEL & UUID of the current swap partition (take both from the list generated in step 4)
- mkswap -L _swap -U f4868832-9d74-489f-a183-51c8a4213ddc /dev/sda1
7.) The new ROOT partition needs to be initialized with 'mkfs.ext4' and the filesystem needs to have the same LABEL & UUID like the current/source ROOT filesystem (take both from the list generated in step 4)
- mkfs.ext4 -L _/ -U 63864bcd-f2f2-4c4c-9cf8-dfc0d77d4bd7 /dev/sda2
8.) Mount the new ROOT filesystem under /mnt
- mount /dev/sda2 /mnt
9.) Install the 'pax' package
- yum install pax
10.) Move the data from the source ROOT filesystem (SSD/MMC card) to the new ROOT filesystem (USB harddrive) with the 'pax' tool
- cd /; pax -v -X -rw -pe . /mnt
11.) Force SELinux to relabel the new ROOT after the reboot
- touch /mnt/.autorelabel
... or disable SELinux if you don't want to wait for relabelling after the reboot (takes ~15 minutes with clean F21 beta4 XFCE on PandaBoard)
- sed -i 's|SELINUX=enforcing|SELINUX=disabled|' /mnt/etc/selinux/config
12.) Remove the old SWAP and ROOT partition from SSD/MMC with 'fdisk' so that only the BOOT partition remains there. You'll get a warning that kernel is still using the old table, but ignore it.
- fdisk /dev/mmcblk0
The system should boot from the USB harddrive now, but you need to give SELinux some time to relabel the ROOT filesystem. That takes approximately 15 minutes with a clean F21 beta4 XFCE on PandaBoard and you'll see nothing but a black screen during that phase.