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

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.
`

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.

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写道:

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.

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,

Ah thank you I’ll use that next time :slight_smile:

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

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!

Regards,

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?

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?

Regards,

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

Regards,

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

Regards,

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?

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,

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..

Regards,

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?