LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 03-17-2023, 09:18 AM   #1
dr_berta
Member
 
Registered: Sep 2005
Location: Carpi (Modena) - Italy
Distribution: Ubuntu 20.04_x86_64 LTS; Slackware 13 64bit; Gentoo, Fedora, Yocto
Posts: 77

Rep: Reputation: 1
mke2fs: Bad magic number in super-block


Hello,
I have created a script to automatically create two partitions on a disk and to create an ext4 filesystem on the disk sda1 and the swap disk on sda2.

The proble I have is that the tool mke2fs, used to create the filesystem on sda1, gives me a "Bad magic number in super-block error" if executed immediately after the disk partitioning.

If I put in the script a read command (see the blue commands below), asking for a enter key pressed, everything goes well and the error is not present.

This is the code showing the issue:
Code:
echo -e "Making new partitions..."
# make partitions
DEVICE="/dev/sda"

sfdisk $DEVICE < /mnt/cdrom/tbs/.sda.sfdisk
sfdisk -qV $DEVICE
RESULT=$?
if [ $RESULT -ne 0 ] ; then
	echo "Error creating partitions!"
	exit
fi

echo "enter return to continue"
read ANS

echo -e "Reloading partition table..."
partprobe $DEVICE
sleep 1

# create filesystems
BIG="16000"
VERYBIG="2000000000"
if [ $PLATFORM = "64bit" ]; then
	mke2fs -t ext4 -L "slash" "${DEVICE}1"
	tune2fs -c $BIG -i $VERYBIG "${DEVICE}1"
	mkswap -L "swap" "${DEVICE}2"
else
	echo "Error!!!"
	exit
fi
Is there anyone that knows the reason of this strange behavior? I would like to remove the "enter key press" request

Thanks
Claudio
 
Old 03-18-2023, 02:18 AM   #2
xode
Member
 
Registered: Aug 2003
Distribution: Mandrake 9.0; FC4; FC8; SUSE 10.3; SUSE 12.1; SUSE 13.2
Posts: 638
Blog Entries: 1

Rep: Reputation: 52
This is a wild guess: without the read command between sfdisk and partprobe, the changes you made with sfdisk haven't yet been written to disk before partprobe again reads the partition, and therefore partprobe would be reading the old partition data. What happens if you put
Code:
sleep 5
between sfdisk and partprobe instead of the read command?
 
Old 03-18-2023, 06:42 AM   #3
dr_berta
Member
 
Registered: Sep 2005
Location: Carpi (Modena) - Italy
Distribution: Ubuntu 20.04_x86_64 LTS; Slackware 13 64bit; Gentoo, Fedora, Yocto
Posts: 77

Original Poster
Rep: Reputation: 1
I tried two different solutions to skip the need of a human interaction:

1)
Code:
sleep 3
2)
Code:
echo "Yes" | read ANS
Both of them have been useless.

To tell the truth, sfdisk, at the and of the disk partitioning, sends a message saying:
Code:
reloading partition table. 
syncing disks.
After this command, I do the check of the new partition checking the result.

Thus I was thinking that after the control the writing of the new disk partition was finished succesfully.

Claudio
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bad magic number to open super block Ritho Linux - Newbie 1 03-06-2008 08:02 AM
Bad magic number in super-block Cadmium Linux - Newbie 2 10-03-2007 01:50 AM
Bad magic number in super-block while trying to open /dev/hda6 Daddyfix Linux - Hardware 1 11-20-2006 10:05 PM
e2fsck: Bad magic number in super-block jamesdin Debian 3 04-25-2005 05:14 PM
Bad magic number in super-block kubokubik Linux - Newbie 4 01-26-2005 10:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 01:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration