Solved - Resize Root Filesystem (Xenial)
#1
Information 
This is for those less familiar with Linux, or running Linux from an SD card.
When you flash Ubuntu Xenial onto an SD card, the root filesystem size is only big enough to fit the operating system.
This is intentional; to keep the size of the image file as small as possible, making it quicker to download and flash to any size SD card (within reason).
After flashing the sd card and booting up for the first time, log in and do the following to expand the root filesystem by following these instructions.
There's a lot of code below, but the whole process took me less than 2 minutes, and you should be able to safely accept the default response to all prompts.

1. Fix the partition table to reflect the size of the SD card:
Code:
rock64@rock64:~$ sudo parted -l
Warning: Not all of the space available to /dev/mmcblk1 appears to be used, you
can fix the GPT to use all of the space (an extra 60332032 blocks) or continue
with the current setting?
Fix/Ignore? F                                                            
Model: SD 5&DRP (sd/mmc)
Disk /dev/mmcblk1: 32.1GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name       Flags
1      32.8kB  4129kB  4096kB               loader1
2      4129kB  4194kB  65.5kB               reserved1
3      4194kB  8389kB  4194kB               reserved2
4      8389kB  12.6MB  4194kB               loader2
5      12.6MB  16.8MB  4194kB               atf
6      16.8MB  134MB   117MB   fat16        boot       legacy_boot, msftdata
7      134MB   1208MB  1074MB  ext4         root

2. Increase the root partition size:
Code:
rock64@rock64:~$ sudo fdisk /dev/mmcblk1

Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/mmcblk1: 29.9 GiB, 32099008512 bytes, 62693376 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: 062EE0ED-2FD5-4D89-B424-771CB4465BD4

Device          Start     End Sectors  Size Type
/dev/mmcblk1p1     64    8063    8000  3.9M Linux filesystem
/dev/mmcblk1p2   8064    8191     128   64K Linux filesystem
/dev/mmcblk1p3   8192   16383    8192    4M Linux filesystem
/dev/mmcblk1p4  16384   24575    8192    4M Linux filesystem
/dev/mmcblk1p5  24576   32767    8192    4M Linux filesystem
/dev/mmcblk1p6  32768  262143  229376  112M Microsoft basic data
/dev/mmcblk1p7 262144 2359295 2097152    1G Linux filesystem

Command (m for help): d
Partition number (1-7, default 7):

Partition 7 has been deleted.

Command (m for help): n
Partition number (7-128, default 7):
First sector (262144-62693342, default 262144):
Last sector, +sectors or +size{K,M,G,T,P} (262144-62693342, default 62693342):

Created a new partition 7 of type 'Linux filesystem' and of size 29.8 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy

The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).

3. Tell the kernel the partition table has changed:
Code:
rock64@rock64:~$ sudo partprobe /dev/mmcblk1


4. Resize the root filesystem to fill the partition:
Code:
rock64@rock64:~$ sudo resize2fs /dev/mmcblk1p7
resize2fs 1.42.13 (17-May-2015)
Filesystem at /dev/mmcblk1p7 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/mmcblk1p7 is now 7803899 (4k) blocks long.

rock64@rock64:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            459M     0  459M   0% /dev
tmpfs            93M  3.9M   89M   5% /run
/dev/mmcblk1p7   30G  769M   28G   3% /
tmpfs           462M     0  462M   0% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           462M     0  462M   0% /sys/fs/cgroup
/dev/mmcblk1p6  100M   22M   79M  22% /boot/efi

Reboot and you're done!
...but don't forget to change the default password from rock64  Rolleyes
  Reply


Messages In This Thread
Solved - Resize Root Filesystem (Xenial) - by aussiemate - 08-24-2017, 05:38 PM
RE: Resize Root Filesystem (Xenial) - by Jakr - 08-25-2017, 09:23 AM
RE: Resize Root Filesystem (Xenial) - by ayufan - 08-28-2017, 07:05 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Display limited to 800x600 [SOLVED] Averell 16 18,597 06-05-2020, 11:07 PM
Last Post: ab1jx
Question [SOLVED] Alpine Linux won't boot rock7 1 5,756 10-22-2019, 04:30 PM
Last Post: rock7
Question HDD filesystem corruption at reboot / poweroff (DietPi) WrongWorld 1 2,915 02-11-2019, 04:00 PM
Last Post: WrongWorld
  Repair corrupt root filesystem on emmc David82 1 3,739 01-31-2019, 01:11 PM
Last Post: Tozzi
  [solved] Unable to start X Osiander 8 11,396 10-03-2018, 03:54 AM
Last Post: jovval
  Rock64: Debian root fs on software RAID1 of eMMC and microSD - is installing it the s jovval 2 3,739 08-03-2018, 12:33 PM
Last Post: jovval
  If you've messed up your eMMC Card - Solved gregb49 11 16,385 07-11-2018, 02:08 PM
Last Post: gregb49
  Xenial Mate + Emmc Guettt 2 3,167 05-31-2018, 02:49 AM
Last Post: pas059
  Any reason why ntp time is 6 minutes slow (Solved) Rocklobster 1 2,527 05-29-2018, 05:27 AM
Last Post: Rocklobster
  compiling meteor on xenial-minimal-rock64-0.5.15-136-armhf.img.xz maudy 0 1,889 05-02-2018, 05:35 PM
Last Post: maudy

Forum Jump:


Users browsing this thread: 1 Guest(s)