08-24-2017, 05:38 PM
(This post was last modified: 08-28-2017, 07:44 AM by aussiemate.)
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:
2. Increase the root partition size:
3. Tell the kernel the partition table has changed:
4. Resize the root filesystem to fill the partition:
Reboot and you're done!
...but don't forget to change the default password from rock64
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