Expanding Root Partition - Bad magic number in super-block while trying to open /dev/mmcblk0p2

3,676 views
Skip to first unread message

Xsentius

unread,
May 17, 2016, 6:52:51 PM5/17/16
to BeagleBoard
Hello all,

I have a 16GB SD card, but currently I can only make use of its 4GB:

root@beaglebone:/home/debian# df -h
Filesystem                                              Size  Used Avail Use% Mounted on
udev                                                    
10M     0   10M   0% /dev
tmpfs                                                   100M  392K   99M   1% /
run
/dev/disk/by-uuid/b7ff9570-02a9-4982-b353-1131012481cb  3.5G  3.5G     0 100% /
tmpfs                                                   248M     0  248M   0% /
dev/shm
tmpfs                                                  
248M     0  248M   0% /sys/fs/cgroup
tmpfs                                                  
100M     0  100M   0% /run/user
tmpfs                                                  
5.0M     0  5.0M   0% /run/lock


I would like to expand the root partition since I am getting no space left on device error. I tried grow_partition.sh but it did not work. So I tried to do it by fdisk many times, but it does not work as well, what could be the problem?


root@beaglebone:/home/debian# fdisk /dev/mmcblk0


Command (m for help): p


Disk /dev/mmcblk0: 15.6 GB, 15648948224 bytes
4 heads, 16 sectors/track, 477568 cylinders, total 30564352 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: 0xdcc515d1


       
Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1   *        2048     3481599     1739776    6  FAT16
/dev/mmcblk0p2         3481600    30564351    13541376   83  Linux


Command (m for help): d
Partition number (1-4): 2


Command (m for help): p


Disk /dev/mmcblk0: 15.6 GB, 15648948224 bytes
4 heads, 16 sectors/track, 477568 cylinders, total 30564352 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: 0xdcc515d1


       
Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1   *        2048     3481599     1739776    6  FAT16


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


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


Calling ioctl() to re-read partition table.
Syncing disks.


root@beaglebone
:/home/debian# reboot




After reboot:




root@beaglebone
:/home/debian# resize2fs /dev/mmcblk0p2
resize2fs
1.42.5 (29-Jul-2012)
resize2fs
: Bad magic number in super-block while trying to open /dev/mmcblk0p2
Couldn't find valid filesystem superblock.

mailbot...@gmail.com

unread,
Jul 4, 2016, 4:54:05 PM7/4/16
to BeagleBoard
I had the same issue as you. So, what I did is to remove all partitions (/dev/mmcblk0p*) and create a new partition that uses all the available space. Write the changes and reboot BBB. Run resize2fs on the only partition. Do a "df -h" to confirm.

gfa...@gmail.com

unread,
Aug 10, 2016, 5:09:29 PM8/10/16
to BeagleBoard, mailbot...@gmail.com
Yeh, It works pretty well on a Beaglebone Black running Jessie. It seems like all Documentation about expand storage on Beaglebone are a little bit out of date.

在 2016年7月4日星期一 UTC+2下午10:54:05,mailbot...@gmail.com写道:

i.la...@gmail.com

unread,
Sep 8, 2016, 2:36:56 PM9/8/16
to BeagleBoard
This worked for me as well on BBB Jessie. The thought of deleting the one and only partition freaked me out at first but apparently fdisk works like that. 

James Hice

unread,
Feb 19, 2017, 10:46:24 PM2/19/17
to BeagleBoard, i.la...@gmail.com
I first found the instructions at http://elinux.org/Beagleboard:Expanding_File_System_Partition_On_A_microSD which are a bit outdated. there was only 1 partition on the Debian Jesse image 
I still came across this issue though as my partition started on a different sector so I thought it would be a good to add to this thread when I came across it while searching for instructions.

in cases where the only partition has a different start sector, the new partition should also start on the same sector

for my case the partition started on 8192 
as found from fdisk /dev/mmcblk0
Device         Boot Start       End   Sectors  Size Id Type
/dev/mmcblk0p1       8192 124735487 124727296 59.5G 83 Linux

when creating the new partition, the number under start should be used. (8192 in my case) instead of using the default of 2048 
after I did this I was able to resize the file system without issue

Robert Nelson

unread,
Feb 19, 2017, 10:52:04 PM2/19/17
to Beagle Board, jame...@gmail.com
On Sun, Feb 19, 2017 at 9:46 PM, James Hice <jame...@gmail.com> wrote:
> I first found the instructions at
> http://elinux.org/Beagleboard:Expanding_File_System_Partition_On_A_microSD
> which are a bit outdated. there was only 1 partition on the Debian Jesse
> image
> I still came across this issue though as my partition started on a different
> sector so I thought it would be a good to add to this thread when I came
> across it while searching for instructions.
>
> in cases where the only partition has a different start sector, the new
> partition should also start on the same sector
>
> for my case the partition started on 8192
> as found from fdisk /dev/mmcblk0
> Device Boot Start End Sectors Size Id Type
> /dev/mmcblk0p1 8192 124735487 124727296 59.5G 83 Linux
>
> when creating the new partition, the number under start should be used.
> (8192 in my case) instead of using the default of 2048
> after I did this I was able to resize the file system without issue

There's a built-in script:

http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#Expanding_File_System_Partition_On_A_microSD

We moved the start of the partition from 1MB -> 4MB as the default
u-boot has gotten big enough to break thru the 1MB hole boundary..

Regards,

--
Robert Nelson
https://rcn-ee.com/

James Hice

unread,
Feb 20, 2017, 2:16:55 AM2/20/17
to Robert Nelson, Beagle Board
Ah thank you I'll use that next time :)

dariush...@gmail.com

unread,
Nov 21, 2017, 5:38:55 PM11/21/17
to BeagleBoard
Hello all,

I have 64GB SD card but it is not shown under filesystems (df -h):

Filesystem      Size  Used Avail Use% Mounted on
udev             10M     0   10M   0% /dev
tmpfs            98M  6.5M   92M   7% /run
/dev/mmcblk1p1  3.6G  3.5G     0 100% /
tmpfs           244M     0  244M   0% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           244M     0  244M   0% /sys/fs/cgroup

I created one partition that uses all the available space.

root@beaglebone:~# fdisk -l

Disk /dev/mmcblk0: 59.5 GiB, 63864569856 bytes, 124735488 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: dos
Disk identifier: 0x6a65dc0d

Device         Boot Start       End   Sectors  Size Id Type
/dev/mmcblk0p1 *     8192 124735487 124727296 59.5G 83 Linux

Disk /dev/mmcblk1: 3.7 GiB, 3925868544 bytes, 7667712 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: dos
Disk identifier: 0x00000000

Device         Boot Start     End Sectors  Size Id Type
/dev/mmcblk1p1 *     8192 7667711 7659520  3.7G 83 Linux

Disk /dev/mmcblk1boot1: 1 MiB, 1048576 bytes, 2048 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 /dev/mmcblk1boot0: 1 MiB, 1048576 bytes, 2048 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

But when I run resize2fs /dev/mmcblk0p1, I got the following error:

root@beaglebone:/# resize2fs /dev/mmcblk0p1 
resize2fs 1.43 (17-May-2016)
resize2fs: Bad magic number in super-block while trying to open /dev/mmcblk0p1
Couldn't find valid filesystem superblock.

I also used Robert new method but I got following error:

root@beaglebone:/# cd /opt/scripts/tools/
root@beaglebone:/opt/scripts/tools# git pull || true 
Already up-to-date.
root@beaglebone:/opt/scripts/tools# sudo ./grow_partition.sh 
Media: [/dev/mmcblk1]

Disk /dev/mmcblk1: 119808 cylinders, 4 heads, 16 sectors/track
Old situation:
Units: 1MiB = 1024*1024 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start   End    MiB    #blocks   Id  System
/dev/mmcblk1p1   *     4   3743   3740    3829760   83  Linux
/dev/mmcblk1p2         0      -      0          0    0  Empty
/dev/mmcblk1p3         0      -      0          0    0  Empty
/dev/mmcblk1p4         0      -      0          0    0  Empty
New situation:
Units: 1MiB = 1024*1024 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start   End    MiB    #blocks   Id  System
/dev/mmcblk1p1   *     4   3743   3740    3829760   83  Linux
/dev/mmcblk1p2         0      -      0          0    0  Empty
/dev/mmcblk1p3         0      -      0          0    0  Empty
/dev/mmcblk1p4         0      -      0          0    0  Empty
Successfully wrote the new partition table

Re-reading the partition table ...
sfdisk: BLKRRPART: Device or resource busy
sfdisk: The command to re-read the partition table failed.
Run partprobe(8), kpartx(8) or reboot your system now,
before using mkfs
sfdisk: If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes:  dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)

I figured out that my beaglebone black is booted from EMMC but not the SD card. I don't know how to boot from the SD card but what I need now is more space so I can Install other things on my beaglebone black.
Sorry for the long message, I'm kinda new to LInux and beaglebone black. I'll appreciate if anybody can help me.

Best,
Darioush

Robert Nelson

unread,
Nov 21, 2017, 5:45:14 PM11/21/17
to Beagle Board, dariush...@gmail.com
On Tue, Nov 21, 2017 at 4:29 PM, <dariush...@gmail.com> wrote:
> Hello all,
>
> I have 64GB SD card but it is not shown under filesystems (df -h):
>
> Filesystem Size Used Avail Use% Mounted on
> udev 10M 0 10M 0% /dev
> tmpfs 98M 6.5M 92M 7% /run
> /dev/mmcblk1p1 3.6G 3.5G 0 100% /
> tmpfs 244M 0 244M 0% /dev/shm
> tmpfs 5.0M 4.0K 5.0M 1% /run/lock
> tmpfs 244M 0 244M 0% /sys/fs/cgroup
>
> I created one partition that uses all the available space.

what does "lsblk" show?

What "brand" 64GB SD? (64GB are SDXC cards)

The am335x ip only "supports" SDHC cards.. (which is spec'd up to 32GB)

While some "SDXC" cards do work, there is no guarantee!

Dariush Keivan

unread,
Nov 21, 2017, 5:56:55 PM11/21/17
to BeagleBoard
Hi Robert,

Thanks for the prompt response.
"lsblk" shows:

root@beaglebone:~# lsblk
NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
mmcblk1boot0 179:16   0    1M  1 disk 
mmcblk1boot1 179:24   0    1M  1 disk 
mmcblk0      179:0    0 59.5G  0 disk 
└─mmcblk0p1  179:1    0 59.5G  0 part 
mmcblk1      179:8    0  3.7G  0 disk 
└─mmcblk1p1  179:9    0  3.7G  0 part /

The brand of "64GB SD card" is SDXC. You think the problem comes from the "SDXC" ?
What should I do now?

Robert Nelson

unread,
Nov 21, 2017, 6:00:15 PM11/21/17
to Beagle Board, dariush...@gmail.com
On Tue, Nov 21, 2017 at 4:56 PM, Dariush Keivan
<dariush...@gmail.com> wrote:
> Hi Robert,
>
> Thanks for the prompt response.
> "lsblk" shows:
>
> root@beaglebone:~# lsblk
> NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
> mmcblk1boot0 179:16 0 1M 1 disk
> mmcblk1boot1 179:24 0 1M 1 disk
> mmcblk0 179:0 0 59.5G 0 disk
> └─mmcblk0p1 179:1 0 59.5G 0 part
> mmcblk1 179:8 0 3.7G 0 disk
> └─mmcblk1p1 179:9 0 3.7G 0 part /
>
> The brand of "64GB SD card" is SDXC. You think the problem comes from the
> "SDXC" ?
> What should I do now?

Not sure, what you "should" do, as it's right there..

> mmcblk0 179:0 0 59.5G 0 disk
> └─mmcblk0p1 179:1 0 59.5G 0 part

aka the 64GB card..

So what do you want to do with the 64GB card again?

Dariush Keivan

unread,
Nov 21, 2017, 6:06:21 PM11/21/17
to BeagleBoard
I wanted to install Ros from source (since Ros Kinetic is not working on debian Jessie on beaglebone black), However, in the middle of the installation, it said that there is not enough space. 
Should I get another SD card (Like 32 GB)?

Robert Nelson

unread,
Nov 21, 2017, 6:10:40 PM11/21/17
to Beagle Board, Dariush Keivan
On Tue, Nov 21, 2017 at 5:06 PM, Dariush Keivan
<dariush...@gmail.com> wrote:
> I wanted to install Ros from source (since Ros Kinetic is not working on
> debian Jessie on beaglebone black), However, in the middle of the
> installation, it said that there is not enough space.
> Should I get another SD card (Like 32 GB)?

ROS:

Using your 64GB microSD, just follow:

https://dscl.lcsr.jhu.edu/home/courses/EduMIP_ROS

Dariush Keivan

unread,
Nov 21, 2017, 6:46:53 PM11/21/17
to BeagleBoard
The problem is that the beaglebone does not recognize my SD card and it says that there is not enough space.
I used the same link for installation of ROS. I think the problem is that my SD card is not shown under "df -h".
Do you have any suggestion?

Robert Nelson

unread,
Nov 21, 2017, 8:39:47 PM11/21/17
to Beagle Board, Dariush Keivan
On Tue, Nov 21, 2017 at 5:46 PM, Dariush Keivan
<dariush...@gmail.com> wrote:
> The problem is that the beaglebone does not recognize my SD card and it says
> that there is not enough space.
> I used the same link for installation of ROS. I think the problem is that my
> SD card is not shown under "df -h".
> Do you have any suggestion?

No that doesn't make any sense..

run:

sudo /opt/scripts/tools/version.sh

Dariush Keivan

unread,
Nov 21, 2017, 9:20:31 PM11/21/17
to BeagleBoard
It shows :

root@beaglebone:~# sudo /opt/scripts/tools/version.sh 
git:/opt/scripts/:[23650994e41b16bcf78253cde7d35a93664beeef]
eeprom:[A335BNLT00C03615BBBK1DA3]
model:[TI_AM335x_BeagleBone_Black]
dogtag:[BeagleBoard.org Debian Image 2017-03-19]
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2017.03-dirty]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2017.03-00002-gd12b1519b4]
kernel:[4.4.68-ti-r111]
nodejs:[v4.8.3]
pkg:[bb-cape-overlays]:[4.4.20170614.0-0rcnee0~jessie+20170614]
pkg:[bb-wl18xx-firmware]:[1.20170612-0rcnee0~jessie+20170612]
WARNING:pkg:[firmware-ti-connectivity]:[NOT_INSTALLED]

Any idea?

Robert Nelson

unread,
Nov 21, 2017, 9:26:59 PM11/21/17
to Beagle Board, dariush...@gmail.com


On Nov 21, 2017 8:20 PM, "Dariush Keivan" <dariush...@gmail.com> wrote:
It shows :

root@beaglebone:~# sudo /opt/scripts/tools/version.sh 
git:/opt/scripts/:[23650994e41b16bcf78253cde7d35a93664beeef]
eeprom:[A335BNLT00C03615BBBK1DA3]
model:[TI_AM335x_BeagleBone_Black]
dogtag:[BeagleBoard.org Debian Image 2017-03-19]
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2017.03-dirty]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2017.03-00002-gd12b1519b4]


There's the issue...

Either hold down the boot button before you power the board, or erase the eMMC.. (bootloader is to old for what we do now by default)

Regards,

Dariush Keivan

unread,
Nov 21, 2017, 9:44:03 PM11/21/17
to BeagleBoard
How can I erase eMMC?

Robert Nelson

unread,
Nov 21, 2017, 9:48:09 PM11/21/17
to Beagle Board, Dariush Keivan
On Tue, Nov 21, 2017 at 8:44 PM, Dariush Keivan
<dariush...@gmail.com> wrote:
> How can I erase eMMC?

sudo dd if=/dev/zero of=/dev/mmcblk1

after 2-3 minutes just hit ctrl-c, the "former" data on the partition
including the boot partition will be mostly zeros..

Dariush Keivan

unread,
Nov 21, 2017, 10:02:40 PM11/21/17
to BeagleBoard
I erased it. Now just 2 LEDS light up and I can not even connect to the beaglebone through SSH.
What should I do now?

Robert Nelson

unread,
Nov 21, 2017, 10:40:30 PM11/21/17
to Beagle Board
On Tue, Nov 21, 2017 at 9:02 PM, Dariush Keivan
<dariush...@gmail.com> wrote:
> I erased it. Now just 2 LEDS light up and I can not even connect to the
> beaglebone through SSH.
> What should I do now?

Now stick your flashed microSD and it'll boot from it..

If it doesn't, let's start back with this image:

https://rcn-ee.com/rootfs/2017-10-12/microsd/bone-ubuntu-16.04.3-console-armhf-2017-10-12-2gb.img.xz

Use etcher.io to write teh *.img.xz directly to the microSD card..

Louis Whitcomb

unread,
Nov 22, 2017, 11:26:03 AM11/22/17
to BeagleBoard
To build ROS Kinetic from source on the Beaglebone, in addition booting from the SD card (for extra flash space) you need to create and enable a swap file. A 1GB swap file seems to wrok fine.  Without a swap file the build of ROS Kinetic failed due to lack memory.   Instructions here:  https://sheldondwill.wordpress.com/2013/12/14/beaglebone-black-ubuntu-adding-a-swapfile
Reply all
Reply to author
Forward
0 new messages