11-23-2019, 05:39 PM
(This post was last modified: 12-04-2019, 04:59 PM by Arwen.
Edit Reason: Corrected spelling mistake; Added must create new partition table partition table; Fixed spelling
)
Here is a guide of how I repartitioned my eMMC to allow for a physical swap partition, and used GPT partition layout, (instead of DOS).
Basically you need an 8GB or larger SD card you can over-write.
Note that both Linux experience and command line familiarity is required. Any mistake and you could accidentally overwrite your working OS. Last, backups, (preferably multiple), is recommended.
This copies the low level boot information:
This section prepares the SD card. I had a 32GB one, so that is used in the sample below.
I don't give the details of how to use "fdisk", as the program has builtin help and can be quite verbose in use. But, you need to create a new partition label, (GPT in this example), as the one copied from above would almost certainly be wrong for the size of the media. Not to mention having a duplicate UUID number.
Do not change the start of either the "/boot" or the first partition, (swap or OS). Nor the size of the "/boot" partition. There is u-Boot code in there somewhere we don't want to overwrite.
Create the file systems:
This copies the boot partition:
This copies the OS partition:
Then reboot. If you have the ability to boot SD cards, this will create a bootable SD card.
Whence booted to SD card, you can redo do the eMMC as desired. I choose to allow for additional root file systems, so I made my first OS partition only 27GBs. More than enough with the 32bit ARM default OS.
Edit: Clarified that the user must create a new partition table since the one copied from the source disk would have a duplicate UUID. And likely be wrong in size.
Basically you need an 8GB or larger SD card you can over-write.
Note that both Linux experience and command line familiarity is required. Any mistake and you could accidentally overwrite your working OS. Last, backups, (preferably multiple), is recommended.
This copies the low level boot information:
Code:
# dd if=/dev/mmcblk1 bs=512 count=262144 of=/dev/mmcblk0
This section prepares the SD card. I had a 32GB one, so that is used in the sample below.
I don't give the details of how to use "fdisk", as the program has builtin help and can be quite verbose in use. But, you need to create a new partition label, (GPT in this example), as the one copied from above would almost certainly be wrong for the size of the media. Not to mention having a duplicate UUID number.
Do not change the start of either the "/boot" or the first partition, (swap or OS). Nor the size of the "/boot" partition. There is u-Boot code in there somewhere we don't want to overwrite.
Code:
# fdisk /dev/mmcblk0
Disklabel type: gpt
Device Start End Sectors Size Type
/dev/mmcblk0p1 32768 163839 131072 64M Microsoft basic data
/dev/mmcblk0p2 262144 4456447 4194304 2G Linux swap
/dev/mmcblk0p3 4456448 61497310 57040863 27.2G Linux filesystem
Create the file systems:
Code:
# mkfs.fat -n sd_boot -v /dev/mmcblk0p1
# mkswap -L sd_swap /dev/mmcblk0p2
# mke2fs -b 4096 -j -L sd_root -m 1 -t ext4 -v /dev/mmcblk0p3
This copies the boot partition:
Code:
# mount -t vfat /dev/mmcblk0p1 /mnt
# rsync -aAHSXx --stats /boot/ /mnt/
# vi /mnt/extlinux/extlinux.conf
{change references to root FS from /dev/mmcblk1 to /dev/mmcblk0}
# umount /mnt
This copies the OS partition:
Code:
# mount -t ext4 /dev/mmcblk0p3 /mnt
# rsync -aAHSXx --stats / /mnt/
# vi /mnt/etc/fstab
Add /boot & swap lines:
/dev/mmcblk0p1 /boot vfat defaults 0 0
/dev/mmcblk0p2 swap swap pri=5 0 0
# umount /mnt
Then reboot. If you have the ability to boot SD cards, this will create a bootable SD card.
Whence booted to SD card, you can redo do the eMMC as desired. I choose to allow for additional root file systems, so I made my first OS partition only 27GBs. More than enough with the 32bit ARM default OS.
Code:
root@Debian-Desktop:~# df -h / /boot;swapon
Filesystem Size Used Avail Use% Mounted on
/dev/root 27G 4.0G 23G 16% /
/dev/mmcblk1p1 64M 50M 15M 78% /boot
NAME TYPE SIZE USED PRIO
/dev/mmcblk1p2 partition 6G 0B 5
Code:
root@Debian-Desktop:~# fdisk -l /dev/mmcblk1
Disk /dev/mmcblk1: 116.5 GiB, 125069950976 bytes, 244277248 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 3F39B914-D8D7-470B-BF6E-E7A2F2B33ABB
Device Start End Sectors Size Type
/dev/mmcblk1p1 32768 163839 131072 64M Microsoft basic data
/dev/mmcblk1p2 262144 12845055 12582912 6G Linux swap
/dev/mmcblk1p3 12845056 69885918 57040863 27.2G Linux filesystem
/dev/mmcblk1p4 69885952 126926814 57040863 27.2G Linux filesystem
--
Arwen Evenstar
Princess of Rivendale
Arwen Evenstar
Princess of Rivendale