Hello, 
fsck and its variations can be used on a partition, not on an entire image 
file/disk. 
Since you are using an image file, you need to create a loop device to run 
e2fsck.

After increasing the disk size with: 
$ dd if=/dev/zero bs=1M count=400 >>  linux-x86.img

Expand the first partition:
$ parted linux-x86.img resizepart 1 100%  

The sector size and the boot start should be checked and noted down using:
$ fdisk -l linux-x86.img

sector size * boot start will give you the offset.

Using this offset and an available loop device number create a loop device:
$ losetup --offset  <sector size * boot start> /dev/loop<X> linux-x86.img

Resize the file system size:
$ resize2fs /dev/loop<X>

At this stage e2fsck can be used:  
$ e2fsck -f /dev/loop<X>

You can also mount the device and copy your files. 
$ mount -oloop /dev/loop<X> <mount_point>

Serhat

________________________________________
From: gem5-users [gem5-users-boun...@gem5.org] on behalf of Seeley, Justin P 
[jpsee...@wpi.edu]
Sent: 16 April 2019 19:31
To: gem5-users@gem5.org
Subject: [gem5-users] Expanding Disk Image for FS Mode

Hello,

I am using the X86 disk image from:
http://gem5.org/Download

I am trying to get full system mode working, so I use an R script as a 
benchmark.

This requires me to edit the disk image by:
1. Copying over my R scripts
2. Installing R
3. Installing Rscript

I can easily copy over my R scripts by just copying them over to the mounted 
disk image.

However, installing R and Rscript is not so easy. The disk image does not have 
enough room to install them, so I have been trying to expand the disk image to 
no success. I get the following for this disk image.

> e2fsck -f linux-x86.img
e2fsck 1.44.1 (24-Mar-2018)
ext2fs_open2: Bad magic number in super-block
e2fsck: Superblock invalid, trying backup blocks...
e2fsck: Bad magic number in super-block while trying to open linux-x86.img

The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem.  If the device is valid and it really contains an ext2/ext3/ext4
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>
 or
    e2fsck -b 32768 <device>

Found a dos partition table in linux-x86.img
________

I am able to increase the disk size with:
> sudo dd if=/dev/zero bs=1M count=400 >>  linux-x86.img

But because of this superblock issue resize2fs does not work.

Has anyone had any luck expanding the X86 disk image for gem5? It seems strange 
the disk image from the gem5 source has this superblock issue.

Thank you,
Justin

_______________________________________________
gem5-users mailing list
gem5-users@gem5.org
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users

Reply via email to