Meego Wiki
Views

ARM/N900/Tips and Tricks/Extending the root btrfs filesystem

From MeeGo wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "By default, microSD MeeGo images for the N900 contain a root filesystem that is only 1.5GB in size. As btrfs [https://btrfs.wiki.kernel.org/index.php/FAQ#Why_is_there_so_many_way…")
(Preparing the microSD card)
Line 39: Line 39:
-
Note in the next step, by default <tt>fdisk wants to start the new partition in between partitions 1 and 2 (at block 24415) as there is a small gap. This is not desired and the end of the second partition should be used instead:
+
Note in the next step, by default <tt>fdisk</tt> wants to start the new partition in between partitions 1 and 2 (at block 24415) as there is a small gap. This is not desired and the end of the second partition should be used instead:
<pre>
<pre>
Line 98: Line 98:
[root@localhost ~]#  
[root@localhost ~]#  
</pre>
</pre>
-
 
===Fetching the btrfs software===
===Fetching the btrfs software===

Revision as of 20:00, 23 October 2010

By default, microSD MeeGo images for the N900 contain a root filesystem that is only 1.5GB in size. As btrfs space monitoring is complicated, and the large size of the default package list, such a small root filesystem can cause problems for N900 users. Fortunately btrfs is capable, allowing online resizing and multi-device support: if the user has an SD card larger than 2GB, the root filesystem can be extended and this page documents that process.

Contents

Prerequisites

The only prerequisite is an internet connection as the btrfs-progs package is not installed by default. Any network connection will do, be it Wifi or USB networking.

Procedure

Preparing the microSD card

1. Start a root shell, either by logging in to the N900 via SSH or by starting xterm and su -'ing to root.

2. Using a disk partition tool, examine the microSD card partition table and create a new partition. This example uses a 4GB card and fdisk, but sfdisk or other tools can be used instead:

[root@localhost ~]# fdisk /dev/mmcblk0

The number of cylinders for this disk is set to 60416.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p


Disk /dev/mmcblk0: 3959 MB, 3959422976 bytes
4 heads, 32 sectors/track, 60416 cylinders
Units = cylinders of 128 * 512 = 65536 bytes
Disk identifier: 0x000b985b

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1               1       24415     1562500   83  Linux
/dev/mmcblk0p2           24417       28320      249856   83  Linux



Note in the next step, by default fdisk wants to start the new partition in between partitions 1 and 2 (at block 24415) as there is a small gap. This is not desired and the end of the second partition should be used instead:


Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (24415-60416, default 24415): 28321
Last cylinder, +cylinders or +size{K,M,G} (28321-60416, default 60416): 
Using default value 60416

Command (m for help): p

Disk /dev/mmcblk0: 3959 MB, 3959422976 bytes
4 heads, 32 sectors/track, 60416 cylinders
Units = cylinders of 128 * 512 = 65536 bytes
Disk identifier: 0x000b985b

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1               1       24415     1562500   83  Linux
/dev/mmcblk0p2           24417       28320      249856   83  Linux
/dev/mmcblk0p3           28321       60416     2054144   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: 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)
Syncing disks.

3. Once the partition has been created the kernel must be made aware of it. This can be done by rebooting the N900 or by running partx:

[root@localhost ~]# partx /dev/mmcblk0
# 1:         1-  3125000 (  3125000 sectors,   1600 MB)
# 2:   3125248-  3624959 (   499712 sectors,    255 MB)
# 3:   3624960-  7733247 (  4108288 sectors,   2103 MB)
# 4:         0-       -1 (        0 sectors,      0 MB)
[root@localhost ~]# partx -a /dev/mmcblk0  
BLKPG: Device or resource busy
error adding partition 1
BLKPG: Device or resource busy
error adding partition 2
BLKPG: Device or resource busy
error adding partition 3
BLKPG: Device or resource busy
error adding partition 4

[root@localhost ~]# ls /dev/mmcblk0p*
mmcblk0p1  mmcblk0p2  mmcblk0p3  mmcblk0p4  
[root@localhost ~]# 

Fetching the btrfs software

1. Install the btrfs-progs package using zypper:

[root@localhost ~]# zypper install btrfs-progs
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following NEW package is going to be installed:
  btrfs-progs 

1 new package to install.
Overall download size: 551.0 KiB. After the operation, additional 1003.0 KiB will be used.
Continue? [y/n/?] (y): y
Retrieving package btrfs-progs-0.19-11.4.armv7l (1/1), 551.0 KiB (1003.0 KiB unpacked)
Installing: btrfs-progs-0.19-11.4 [done]


Extending the filesystem using the deprecated btrfs-* commands

The btrfs-progs will undergo a change in the near future and the following method will be deprecated as the commands are replaced with btrfs, it is however still valid as of version btrfs-progs-0.19-11.4.

1. Examine the existing btrfs layout:

[root@localhost ~]# btrfs-show /dev/mmcblk0p1
failed to read /dev/mmcblk0p4
Label: none  uuid: 075a887c-4986-4c68-a7f4-2fc013f76db7
	Total devices 1 FS bytes used 605.30MB
	devid    1 size 1.49GB used 1.27GB path /dev/mmcblk0p1

2. Extend onto the third partition:

[root@localhost ~]# btrfs-vol -a /dev/mmcblk0p3 /
ioctl returns 0

3. Re-examine the layout:

[root@localhost ~]# btrfs-show /dev/mmcblk0p1
failed to read /dev/mmcblk0p4
Label: none  uuid: 075a887c-4986-4c68-a7f4-2fc013f76db7
	Total devices 2 FS bytes used 605.30MB
	devid    1 size 1.49GB used 1.27GB path /dev/mmcblk0p1
	devid    2 size 1.96GB used 1.27GB path /dev/mmcblk0p3

Btrfs Btrfs v0.19


4. Finally, rebalance the filesystem. This causes btrfs to reallocate some metadata and data blocks from one device to the other and can reclaim wasted metadata space. It takes several minutes:

[root@localhost ~]# btrfs-vol -b /
ioctl returns 0

Extending the filesystem using the new btrfs command

Needs writing but the commands will be:

btrfs filesystem add /dev/mmcblk0p3

btrfs filesystem balance /

Personal tools