You could login using headless mode (headless mode means that you don't have a display connect and you login with ssh from any other system) and use these steps to expand your root partition and file system on a Raspberry Pi running Pedora (fedora remix):cclauss wrote:In Pidora, is there a headless mode way to expand the rootfs to take up the entire SD card without doing remote Xwindows into the Pi?
'Parted' runs on the command line but I don't know how to expand the rootfs with it.
- backup your system in case of a misstake!
- use "fdisk /dev/mmcblk0" to view your partitions.
- use "parted" to delete the partition and then recreate it but with a larger size. (don't worry, the data will remain)
- reboot to activate the partition changes.
- use "resize2fs /dev/mmclk0p2" to enlarge the root file system.
- use e2fsck -f /dev/mmcblk0p2 to perform a file system check.
- use "df -h" to check results.
Before you extend your root partition and filesystem you should know how big your rootfs is and how much space is available:
Code: Select all
[root@raspi ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 1.6G 1.5G 53M 97% /
/dev/mmcblk0p1 50M 18M 33M 35% /boot
[root@raspi ~]#
Code: Select all
[root@raspi ~]# ll /dev/mm*
brw-rw---- 1 root disk 179, 0 Jun 3 13:22 /dev/mmcblk0
brw-rw---- 1 root disk 179, 1 Jun 3 13:21 /dev/mmcblk0p1
brw-rw---- 1 root disk 179, 2 Jun 3 13:21 /dev/mmcblk0p2
[root@raspi ~]
Code: Select all
[root@raspi ~] fdisk /dev/mmcblk0
Welcome to fdisk (util-linux 2.22.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/mmcblk0: 16.0 GB, 16012804096 bytes, 31275008 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
Disk identifier: 0x000622ba
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 * 2048 104447 51200 c W95 FAT32 (LBA)
/dev/mmcblk0p2 104448 3494304 1694928+ 83 Linux
Command (m for help): q
[root@raspi ~]#
Print the partition table with "parted":
Code: Select all
[root@raspi ~]# parted /dev/mmcblk0
GNU Parted 3.1
Using /dev/mmcblk0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit chs
(parted) print
Model: SD (sd/mmc)
Disk /dev/mmcblk0: 1946,198,43
Sector size (logical/physical): 512B/512B
BIOS cylinder,head,sector geometry: 1946,255,63. Each cylinder is 8225kB.
Partition Table: msdos
Disk Flags:
Number Start End Type File system Flags
1 0,32,32 6,127,56 primary fat16 boot, lba
2 6,127,57 217,130,9 primary ext4
(parted)
Note: "fdisk" displays the partition info in 512 bytes blocks and "parted" displays the cylinder,head,sector geometry. Each cylinder is 8225kB.
Now remove the second partition and recreate it larger.
Note: If you have a third swap or other partition that you don't need any longer, you can remove that one too and use the disk space to extend you.
Removing the partition will only change the partition table and not the data. Creating a new partition will write a new start and end point in the partition table.
Be careful: If you make a misstake, you lose you root partition data:
(Ignore the warning.)
Code: Select all
(parted) rm 2
Error: Partition(s) 2 on /dev/mmcblk0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will
remain in use. You should reboot now before making further changes.
Ignore/Cancel? i
(parted)
Code: Select all
(parted) print
Model: SD (sd/mmc)
Disk /dev/mmcblk0: 1946,198,43
Sector size (logical/physical): 512B/512B
BIOS cylinder,head,sector geometry: 1946,255,63. Each cylinder is 8225kB.
Partition Table: msdos
Disk Flags:
Number Start End Type File system Flags
1 0,32,32 6,127,56 primary fat16 boot, lba
(parted)
The new partition must start at the same position where the old root partition did start and it ends where you like. It must have at least the same size as current partition and it may not exceed the end of the disk (in my case 1946,198,43).
(Ignore the warning.)
Code: Select all
(parted) mkpart primary 6,127,57 1946,198,43
Error: Partition(s) 2 on /dev/mmcblk0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will
remain in use. You should reboot now before making further changes.
Ignore/Cancel? i
(parted)
Code: Select all
(parted) print
Model: SD (sd/mmc)
Disk /dev/mmcblk0: 1946,198,43
Sector size (logical/physical): 512B/512B
BIOS cylinder,head,sector geometry: 1946,255,63. Each cylinder is 8225kB.
Partition Table: msdos
Disk Flags:
Number Start End Type File system Flags
1 0,32,32 6,127,56 primary fat16 boot, lba
2 6,127,57 1946,198,43 primary ext4
(parted) quit
Information: You may need to update /etc/fstab.
[root@raspi ~]#
Code: Select all
[root@raspi ~]# reboot
Code: Select all
[root@raspi ~]# fdisk /dev/mmcblk0
Welcome to fdisk (util-linux 2.22.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/mmcblk0: 16.0 GB, 16012804096 bytes, 31275008 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
Disk identifier: 0x000622ba
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 * 2048 104447 51200 c W95 FAT32 (LBA)
/dev/mmcblk0p2 104448 31275007 15585280 83 Linux
Command (m for help): quit
[root@raspi ~]#
Code: Select all
[root@raspi ~]# resize2fs /dev/mmcblk0p2
resize2fs 1.42.3 (14-May-2012)
Filesystem at /dev/mmcblk0p2 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/mmcblk0p2 is now 3896320 blocks long.
[root@raspi ~]
Then check the file system for errors:
Code: Select all
[root@raspi ~]# e2fsck -f /dev/mmcblk0p2
e2fsck 1.42.3 (14-May-2012)
/dev/mmcblk0p2 is mounted.
WARNING!!! The filesystem is mounted. If you continue you ***WILL***
cause ***SEVERE*** filesystem damage.
Do you really want to continue<n>? yes
rootfs: recovering journal
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Free blocks count wrong (3453563, counted=3453559).
Fix<y>? yes
rootfs: ***** FILE SYSTEM WAS MODIFIED *****
rootfs: ***** REBOOT LINUX *****
rootfs: 63775/952000 files (0.1% non-contiguous), 442761/3896320 blocks
[root@raspi ~]#
Finaly check the file systems size and the available space:
Code: Select all
[root@raspi ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 15G 1.5G 13G 11% /
/dev/mmcblk0p1 50M 18M 33M 35% /boot
[root@raspi ~]#
I hope this helps you.
Ted Sluis