LeMaker Guitar:How to resize system partition
Description
The Linux OS image file(an .img or .fw file) provided by LeMaker has a size about 3.0GB, after you use the image burning tool to write it to a SD card or eMMC on board, you'll find that the partition which contains the root directory "/" has a space of about 3.0GB, and this is a trouble because the partition space will be used up soon, e.g. Installing emacs related packages will use more than 200 MB space.
So, we need to let the root directory partition use almost the whole SD card or eMMC space. For example, I have a 8GB SD card or a 8G eMMC, then I want the left space to be the root directory partition.
parted:parted is a disk partitioning and partition resizing program. It allows you to create, destroy, resize, move and copy ext2, linux-swap, FAT, FAT32, and reiserfs partitions. It can create, resize, and move Macintosh HFS partitions, as well as detect jfs, ntfs, ufs, and xfs partitions. It is useful for creating space for new operating systems, reorganising disk usage, and copying data to new hard disks.
resize2fs:The resize2fs program will resize ext2, ext3, or ext4 file systems. It can be used to enlarge or shrink an unmounted file system located on device. If the filesystem is mounted, it can be used to expand the size of the mounted filesystem, assuming the kernel supports on-line resizing. (As of this writing, the Linux 2.6 kernel supports on-line resize for filesystems mounted using ext3 and ext4.).
Implementation
sudo parted /dev/mmcblk0 #mmcblk0 represent SD card or eMMC GNU Parted 3.2 Using /dev/mmcblk0 Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) print #List partitions Model: SD SL08G (sd/mmc) Disk /dev/mmcblk0: 7948MB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 8389kB 58.7MB 50.3MB fat16 primary msftdata 2 58.7MB 3670MB 3611MB ext4 primary msftdata (parted) resizepart #Resize partition Partition number? 2 #Select partition 2 End? [3670MB]? -1 #Resize to the end (parted) print #List partitons Model: SD SL08G (sd/mmc) Disk /dev/mmcblk0: 7948MB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 8389kB 58.7MB 50.3MB fat16 primary msftdata 2 58.7MB 7947MB 7888MB ext4 primary msftdata (parted) q Information: You may need to update /etc/fstab. sudo reboot sudo resize2fs /dev/mmcblk0p2
(Notice:/dev/mmcblk0 represents the MicroSD card, /dev/mmcblk1 represents the eMMC on board. parted 2.3 is not support dynamic partitioning.)
Reference
1、http://www.thegeekstuff.com/2011/09/parted-command-examples/
2、http://www.gnu.org/software/parted/manual/parted.html
3、http://man.he.net/man8/resize2fs
4、http://man.he.net/?topic=parted§ion=all