Resizing file system with Arch on Raspberry Pi 2 [SOLVED]

Raspberry Pi 2

Resizing file system with Arch on Raspberry Pi 2 [SOLVED]

Postby RobMeades » Sat Feb 14, 2015 12:25 am

Hi there. I've used Raspberry Pi 1's with Arch Linux for a little while and have just bought a Pi 2. I decided to start afresh with Arch Linux latest for Pi 2 from here:

http://archlinuxarm.org/platforms/armv7/broadcom/raspberry-pi-2

...on a nice new SD card but I'm having some trouble. The initial Arch Linux installation on the SD card boots fine in the Pi 2 but then I want to resize the file system so that it will fit on all my SD cards rather than only fitting on those that happen to exactly match in size (given that all SD cards are slightly different in size). On previous Arch Linux/Pi combinations I would start with something like this:

Code: Select all
/dev/mmcblk0p1           2048    186367   92160   c W95 FAT32 (LBA)
/dev/mmcblk0p2         186368   3667967 1740800   5 Extended
/dev/mmcblk0p5         188416   3667967 1739776  83 Linux

...fdisk my way to something like this:

Code: Select all
/dev/mmcblk0p1           2048    186367   92160   c W95 FAT32 (LBA)
/dev/mmcblk0p2         186368  15499999 7656816   5 Extended
/dev/mmcblk0p5         188416  15499999 7655792  83 Linux

...reboot the Pi, login once more and do:

Code: Select all
resize2fs /dev/mmcblk0p5

...to line things up, which worked fine. With the latest Arch Linux what I have is this:

Code: Select all
Device         Boot  Start      End  Sectors  Size Id Type
/dev/mmcblk0p1        2048   206847   204800  100M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      206848 15564799 15357952  7.3G 83 Linux

...so I decided to fdisk it to this:

Code: Select all
Device         Boot  Start      End  Sectors  Size Id Type
/dev/mmcblk0p1        2048   206847   204800  100M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      206848 15499999 15293152  7.3G 83 Linux

However then when I reboot the Pi doesn't come up. I'm no expert in disk partitioning and I must be doing something wrong. Can anyone put me right please?

Rob
Last edited by RobMeades on Sun Feb 15, 2015 11:57 am, edited 2 times in total.
RobMeades
 
Posts: 18
Joined: Sat May 17, 2014 3:35 pm

Re: Resizing file system with Arch latest on Raspberry Pi 2

Postby pepedog » Sat Feb 14, 2015 12:51 am

Only this method is supported
http://archlinuxarm.org/platforms/armv7/broadcom/raspberry-pi-2#qt-platform_tabs-ui-tabs2
And with that resize is not needed.

If you used NOOBS or an image, delete 2 and 5, create logical (2), then create partition within it (5), then resize 5 (using all default values
pepedog
Developer
 
Posts: 2431
Joined: Mon Jun 07, 2010 3:30 pm
Location: London UK

Re: Resizing file system with Arch latest on Raspberry Pi 2

Postby RobMeades » Sat Feb 14, 2015 10:44 am

That's the method I used but the scenario I'm afraid of is when I make a backup copy of this image (SD card size 15564799) using dd and want to put it on an SD card which happens to have, say, only 15564700 sectors available then if any files used sectors in the 15564700 to 15564799 region they would be corrupted. Given that every SD card is a different size it would be a nightmare to make a backup that could ever be used reliably on any other SD card and impossible to keep two or more SD cards aligned unless they happened to be exactly the same size. Hence I want to be in control of the maximum file system size.

I tried the procedure you point to but entering 15499999 as the last sector however that SD card did not boot in the Pi either.

What am I missing?

Rob
P.S. to prove it, here's a log of my terminal activities when running the defined procedure but with a max size of 15499999 sectors:

Code: Select all
ubuntu@ubuntu:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/cow            7.8G   59M  7.7G   1% /
udev            7.7G  4.0K  7.7G   1% /dev
tmpfs           1.6G  1.5M  1.6G   1% /run
/dev/sdc1        15G  985M   14G   7% /cdrom
/dev/loop0      939M  939M     0 100% /rofs
none            4.0K     0  4.0K   0% /sys/fs/cgroup
tmpfs           7.8G  4.0K  7.8G   1% /tmp
none            5.0M     0  5.0M   0% /run/lock
none            7.8G   76K  7.8G   1% /run/shm
none            100M   56K  100M   1% /run/user
/dev/sdb1       932G  812G  121G  88% /media/ubuntu/Elements
/dev/sde2       7.1G  550M  6.2G   9% /media/ubuntu/f00ea051-3e0a-4fed-b809-85df653493e1
/dev/sde1       100M   12M   88M  12% /media/ubuntu/8B01-7D22
ubuntu@ubuntu:~$ sudo su
root@ubuntu:/home/ubuntu# fdisk /dev/sde

Command (m for help): p

Disk /dev/sde: 7969 MB, 7969177600 bytes
246 heads, 62 sectors/track, 1020 cylinders, total 15564800 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: 0xe353cd08

   Device Boot      Start         End      Blocks   Id  System
/dev/sde1            2048      206847      102400    c  W95 FAT32 (LBA)
/dev/sde2          206848    15564799     7678976   83  Linux

Command (m for help): o
Building a new DOS disklabel with disk identifier 0xe687e25e.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): p

Disk /dev/sde: 7969 MB, 7969177600 bytes
246 heads, 62 sectors/track, 1020 cylinders, total 15564800 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: 0xe687e25e

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-15564799, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-15564799, default 15564799): +100M

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): c
Changed system type of partition 1 to c (W95 FAT32 (LBA))

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (1-4, default 2): 2
First sector (206848-15564799, default 206848):
Using default value 206848
Last sector, +sectors or +size{K,M,G} (206848-15564799, default 15564799): 15499999

Command (m for help): p

Disk /dev/sde: 7969 MB, 7969177600 bytes
246 heads, 62 sectors/track, 1020 cylinders, total 15564800 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: 0xe687e25e

   Device Boot      Start         End      Blocks   Id  System
/dev/sde1            2048      206847      102400    c  W95 FAT32 (LBA)
/dev/sde2          206848    15499999     7646576   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)

WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.
root@ubuntu:/home/ubuntu# mkfs.vfat /dev/sde1
mkfs.fat 3.0.26 (2014-03-07)
mkfs.vfat: /dev/sde1 contains a mounted filesystem.
root@ubuntu:/home/ubuntu# umount /dev/sde1
root@ubuntu:/home/ubuntu# umount /dev/sde2
root@ubuntu:/home/ubuntu# mkfs.vfat /dev/sde1
mkfs.fat 3.0.26 (2014-03-07)
root@ubuntu:/home/ubuntu# mkdir boot
root@ubuntu:/home/ubuntu# mount /dev/sde1 boot
root@ubuntu:/home/ubuntu# mkfs.ext4 /dev/sde2
mke2fs 1.42.9 (4-Feb-2014)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
480496 inodes, 1919744 blocks
95987 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1967128576
59 block groups
32768 blocks per group, 32768 fragments per group
8144 inodes per group
Superblock backups stored on blocks:
   32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Allocating group tables: done                           
Writing inode tables: done                           
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

root@ubuntu:/home/ubuntu# mkdir root
root@ubuntu:/home/ubuntu# mount /dev/sde2 root
root@ubuntu:/home/ubuntu# wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
--2015-02-14 11:09:24--  http://archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
Resolving archlinuxarm.org (archlinuxarm.org)... 50.116.36.110
Connecting to archlinuxarm.org (archlinuxarm.org)|50.116.36.110|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz [following]
--2015-02-14 11:09:24--  http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
Resolving os.archlinuxarm.org (os.archlinuxarm.org)... 129.241.205.167, 213.202.193.253, 144.76.72.180, ...
Connecting to os.archlinuxarm.org (os.archlinuxarm.org)|129.241.205.167|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 234858784 (224M) [application/octet-stream]
Saving to: ‘ArchLinuxARM-rpi-2-latest.tar.gz’

100%[======================================>] 234,858,784 3.93MB/s   in 59s   

2015-02-14 11:10:24 (3.78 MB/s) - ‘ArchLinuxARM-rpi-2-latest.tar.gz’ saved [234858784/234858784]
root@ubuntu:/home/ubuntu# bsdtar -xpf ArchLinuxARM-rpi-2-latest.tar.gz -C root
root@ubuntu:/home/ubuntu# sync
root@ubuntu:/home/ubuntu# mv root/boot/* boot
root@ubuntu:/home/ubuntu# umount boot root
root@ubuntu:/home/ubuntu# df -h
Filesystem      Size  Used Avail Use% Mounted on
/cow            7.8G  413M  7.4G   6% /
udev            7.7G  4.0K  7.7G   1% /dev
tmpfs           1.6G  1.5M  1.6G   1% /run
/dev/sdc1        15G  985M   14G   7% /cdrom
/dev/loop0      939M  939M     0 100% /rofs
none            4.0K     0  4.0K   0% /sys/fs/cgroup
tmpfs           7.8G   12K  7.8G   1% /tmp
none            5.0M     0  5.0M   0% /run/lock
none            7.8G   80K  7.8G   1% /run/shm
none            100M   60K  100M   1% /run/user
/dev/sdb1       932G  812G  121G  88% /media/ubuntu/Elements
RobMeades
 
Posts: 18
Joined: Sat May 17, 2014 3:35 pm

Re: Resizing file system with Arch latest on Raspberry Pi 2

Postby RobMeades » Sat Feb 14, 2015 12:45 pm

Oooo, a clue: I've just reinserted that disk into another Linux box and it pops up:

Code: Select all
Error mounting /dev/sde2 at /media/ubuntu/d7512083-4e3c-49e5-b44c-240dcf607a49: Command-line `mount -t "ext4" -o "uhelper=udisks2,nodev,nosuid" "/dev/sde2" "/media/ubuntu/d7512083-4e3c-49e5-b44c-240dcf607a49"' exited with non-zero exit status 32: mount: wrong fs type, bad option, bad superblock on /dev/sde2,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so

...and dmesg | tail gives me:

Code: Select all
[  136.452280] sd 7:0:0:1: [sde] 15564800 512-byte logical blocks: (7.96 GB/7.42 GiB)
[  136.457886]  sde: sde1 sde2
[  136.737800] EXT4-fs (sde2): bad geometry: block count 1919744 exceeds size of device (1911644 blocks)

So something must be up with how I'm using mkfs.ext4...

Rob
RobMeades
 
Posts: 18
Joined: Sat May 17, 2014 3:35 pm

Re: Resizing file system with Arch latest on Raspberry Pi 2

Postby RobMeades » Sat Feb 14, 2015 1:09 pm

Got it. On previous occasions I was only remembering to unmount the SD card when prompted, after the fdisk write had apparently succeeded. It seems that I should have paid more attention to the line:

Code: Select all
The kernel still uses the old table

...as mkfs.ext4 was working on the basis of the previous SD card size, working out the disk size to be:

1919744 blocks

If I repeat the procedure and unmount the SD card before running fdisk then mkfs.ext4 works out the SD card size to be:

1911644 blocks

Bearing in mind that us Pi users are often only occasional Linux users I think it would be a sensible enhancement to the installation instructions to put at the top something like:

unmount any drives on sdX, e.g.:

umount /dev/sdX1


Rob
RobMeades
 
Posts: 18
Joined: Sat May 17, 2014 3:35 pm


Return to Broadcom

Who is online

Users browsing this forum: No registered users and 2 guests