You are not logged in.

#1 2014-12-01 12:05:48

Gianlucode
Member
Registered: 2013-05-24
Posts: 25

How can i format and finaly mount??

Hi guys,
i'm trying to create an image bootable from scratch, but i fell in error right at the beginning sad.
I've created an image filled by zero with

dd if=/dev/zero of=deb.iso bs=1M count=2048

after that i've partitioning this file with

cfdisk deb.iso

and the resultant partition table is

Disk ../deb.iso: 2 GiB, 2147483648 bytes, 4194304 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: 0x114cf359

Device      Boot  Start     End Sectors  Size Id Type
../deb.iso1 *      2048  718847  716800  350M 83 Linux
../deb.iso2      718848 4194303 3475456  1,7G 83 Linux

At this point i've create a block devices for each partition, so

losetup -o $((2048*512)) /dev/loop0 ../deb.iso
losetup -o $((718848*512)) /dev/loop1 ../deb.iso

then i formatted it in ext4

mkfs.ext4 /dev/loop0
mkfs.ext4 /dev/loop1

and until here everything goes right.
Now i decided to mount my formatted loop devices, so

mkdir root
mount /dev/loop1 root
cd root
mkdir boot

but when i give the command for mount the /dev/loop0, this give me back an error

mount /dev/loop0 boot
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
       missing codepage or helper program, or other error

       In some cases useful info is found in syslog - try
       dmesg | tail or so.

The permission of directory and the privilege for mount devices it's ok.
I also tried mount the partition without use losetup, directly from

mount -o loop,offset=$((2048*512)) -t ext4 ../deb.iso boot/

or format directly the partition with

mkfs.ext4 -E offset=$((2048*512)) deb.iso

but always is the same.

My dmesg said:

[ 3123.395788] JBD2: no valid journal superblock found
[ 3123.395796] EXT4-fs (loop0): error loading journal

Can someone help me with this damn trouble?? Thanks you very much

Last edited by Gianlucode (2014-12-01 12:17:26)

Offline

#2 2014-12-01 12:58:15

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: How can i format and finaly mount??

Gianlucode wrote:

i'm trying to create an image bootable from scratch, but i fell in error right at the beginning.

Are you following instructions? Where are the instructions?

Also, what is your ultimate goal? Are you trying to make a custom bootable Debian DVD?

Offline

#3 2014-12-01 13:46:04

Gianlucode
Member
Registered: 2013-05-24
Posts: 25

Re: How can i format and finaly mount??

drcouzelis wrote:

Are you following instructions? Where are the instructions?

Nope, i don't have followed any instruction. I was thinking that that's is the right way.

drcouzelis wrote:

Also, what is your ultimate goal? Are you trying to make a custom bootable Debian DVD?

I want to realize a lightly debian image with debootstrap, that i can boot inside an old thinclient who uses CF card.
What i was trying to do in the first post was create a virtual image, partition and mount it, then copy inside the debian filesystem.

Offline

#4 2014-12-01 15:39:05

bstaletic
Member
Registered: 2014-02-02
Posts: 658

Re: How can i format and finaly mount??

The problem I saw right away is that you can not make "boot" dir the way you tried. When you mount an image it has to be mounted read only.

Fix that and retry. Other than that i can not help you.

Offline

#5 2014-12-01 17:12:48

Gianlucode
Member
Registered: 2013-05-24
Posts: 25

Re: How can i format and finaly mount??

bstaletic wrote:

When you mount an image it has to be mounted read only.

Sorry, but i don't understand. Why i have to mount the partition in read-only. If i want to copy inside the filesystem, i need to mount it read-write, as i do in the previous post.
I'm wrong?

Offline

#6 2014-12-01 18:48:39

bstaletic
Member
Registered: 2014-02-02
Posts: 658

Re: How can i format and finaly mount??

You can mount partition with "-o rw", but you can not do the same with images.Try to mount any iso file and write something to it. You will see that you can not do that. Mounted images behave the same way mounted cd roms behave, as a Read Only Memory.

Offline

#7 2014-12-02 14:39:33

Gianlucode
Member
Registered: 2013-05-24
Posts: 25

Re: How can i format and finaly mount??

How we are used to hear in computer science, Divide et impera!
I divided my deb.iso in 3 pices using dd. Remebering the partitions table

Gianlucode wrote:
Disk ../deb.iso: 2 GiB, 2147483648 bytes, 4194304 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: 0x114cf359

Device      Boot  Start     End Sectors  Size Id Type
../deb.iso1 *      2048  718847  716800  350M 83 Linux
../deb.iso2      718848 4194303 3475456  1,7G 83 Linux

I use dd in this way

dd if=deb.img of=deb.img.mbr bs=512 skip=0 count=2048
dd if=deb.img of=deb.img.0 bs=512 skip=2048 count=716800
dd if=deb.img of=deb.img.1 bs=512 skip=718848

To be sure that i haven't corrupted something i've calculeted the md5 hash of this file and the original

cat deb.img.mbr deb.img.0 deb.img.1 | md5sum
f33fed42eb63666d325e4fff796bfef9
md5sum deb.img
f33fed42eb63666d325e4fff796bfef9

So i was able to format my partitions and then mount them

mkfs.ext4 deb.iso.0
mkfs.ext4 deb.iso.1
mkdir root
mount deb.iso.1 root
cd root
mkdir boot
mount ../deb.iso.0 boot
touch boot/test
cd ..
umount root/boot
umount root

I've reassembled the image

cat deb.img.mbr deb.img.0 deb.img.1 > deb_final.img

and obviously if i recalculate the md5 is different then the initaly deb.img because i formatted and wrote some file in these partitions.

md5sum deb.img
f33fed42eb63666d325e4fff796bfef9
md5sum deb_final.img
b1b5656781b28803759d46ee67c428d5

To be sure, i've done the ultimately proof

sudo mount -o loop,offset=$((2048*512)) deb_final.img root
ls root
test  lost+found

Et voilà there is the file test as i aspected.
Now do not forget to umont the partition

sudo umount root

I hope that this post will be useful for someone in future. If you have other solution to the initial problem, write it below. big_smile

Last edited by Gianlucode (2014-12-02 14:48:39)

Offline

Board footer

Powered by FluxBB