Need to corrupt an ext4 filesystem to performance test ext4
-
- Posts: 66
- Joined: 2015/02/15 18:35:55
Need to corrupt an ext4 filesystem to performance test ext4
Team,
I need to corrupt an ext4 filesystem in order to test the performance of fsck.
Googling led me to sg3_utils which I installed, it is however not working out for me. Please suggest how to use the sg3_utils or any new approach to corrupt an ext4 filesystem.
The attempts at using sg3_utils are documented below. As always all patronage is appreciated.
[root@system tmp]# sg_write_long -v -w -l 16384 /dev/sdf1
sg_write_long: issue write long to device /dev/sdf1
xfer_len= 0 (0x0), lba=16384 (0x4000)
cor_dis=0, wr_uncor=1, pblock=0
Write Long (10) cmd: 3f 40 00 00 40 00 00 00 00 00
write long(10): pass through os error: Inappropriate ioctl for device
SCSI WRITE LONG (10): Sense category: -1
[root@system tmp]# sg_write_long -v -w -l 16384 /dev/sdf
sg_write_long: issue write long to device /dev/sdf
xfer_len= 0 (0x0), lba=16384 (0x4000)
cor_dis=0, wr_uncor=1, pblock=0
Write Long (10) cmd: 3f 40 00 00 40 00 00 00 00 00
write long(10): Fixed format, current; Sense key: Illegal Request
Additional sense: Invalid command operation code
Sense Key Specific: Error in Command: byte 0
SCSI WRITE LONG (10): Illegal request, invalid opcode sense key
[root@system tmp]#
[root@system tmp]# lsscsi -g
[1:0:0:0] cd/dvd NECVMWar VMware IDE CDR10 1.00 /dev/sr0 /dev/sg0
[2:0:0:0] disk VMware Virtual disk 1.0 /dev/sda /dev/sg1
[2:0:1:0] disk VMware Virtual disk 1.0 /dev/sdb /dev/sg2
[2:0:2:0] disk VMware Virtual disk 1.0 /dev/sdc /dev/sg3
[2:0:3:0] disk VMware Virtual disk 1.0 /dev/sdd /dev/sg4
[2:0:4:0] disk VMware Virtual disk 1.0 /dev/sde /dev/sg5
[2:0:5:0] disk VMware Virtual disk 1.0 /dev/sdf /dev/sg6
[root@system tmp]#
[root@system tmp]# sg_write_long -v -w /dev/sg6
sg_write_long: issue write long to device /dev/sg6
xfer_len= 0 (0x0), lba=0 (0x0)
cor_dis=0, wr_uncor=1, pblock=0
Write Long (10) cmd: 3f 40 00 00 00 00 00 00 00 00
write long(10): Fixed format, current; Sense key: Illegal Request
Additional sense: Invalid command operation code
Sense Key Specific: Error in Command: byte 0
SCSI WRITE LONG (10): Illegal request, invalid opcode sense key
[root@system tmp]#
Regards,
Kartik Vashishta
I need to corrupt an ext4 filesystem in order to test the performance of fsck.
Googling led me to sg3_utils which I installed, it is however not working out for me. Please suggest how to use the sg3_utils or any new approach to corrupt an ext4 filesystem.
The attempts at using sg3_utils are documented below. As always all patronage is appreciated.
[root@system tmp]# sg_write_long -v -w -l 16384 /dev/sdf1
sg_write_long: issue write long to device /dev/sdf1
xfer_len= 0 (0x0), lba=16384 (0x4000)
cor_dis=0, wr_uncor=1, pblock=0
Write Long (10) cmd: 3f 40 00 00 40 00 00 00 00 00
write long(10): pass through os error: Inappropriate ioctl for device
SCSI WRITE LONG (10): Sense category: -1
[root@system tmp]# sg_write_long -v -w -l 16384 /dev/sdf
sg_write_long: issue write long to device /dev/sdf
xfer_len= 0 (0x0), lba=16384 (0x4000)
cor_dis=0, wr_uncor=1, pblock=0
Write Long (10) cmd: 3f 40 00 00 40 00 00 00 00 00
write long(10): Fixed format, current; Sense key: Illegal Request
Additional sense: Invalid command operation code
Sense Key Specific: Error in Command: byte 0
SCSI WRITE LONG (10): Illegal request, invalid opcode sense key
[root@system tmp]#
[root@system tmp]# lsscsi -g
[1:0:0:0] cd/dvd NECVMWar VMware IDE CDR10 1.00 /dev/sr0 /dev/sg0
[2:0:0:0] disk VMware Virtual disk 1.0 /dev/sda /dev/sg1
[2:0:1:0] disk VMware Virtual disk 1.0 /dev/sdb /dev/sg2
[2:0:2:0] disk VMware Virtual disk 1.0 /dev/sdc /dev/sg3
[2:0:3:0] disk VMware Virtual disk 1.0 /dev/sdd /dev/sg4
[2:0:4:0] disk VMware Virtual disk 1.0 /dev/sde /dev/sg5
[2:0:5:0] disk VMware Virtual disk 1.0 /dev/sdf /dev/sg6
[root@system tmp]#
[root@system tmp]# sg_write_long -v -w /dev/sg6
sg_write_long: issue write long to device /dev/sg6
xfer_len= 0 (0x0), lba=0 (0x0)
cor_dis=0, wr_uncor=1, pblock=0
Write Long (10) cmd: 3f 40 00 00 00 00 00 00 00 00
write long(10): Fixed format, current; Sense key: Illegal Request
Additional sense: Invalid command operation code
Sense Key Specific: Error in Command: byte 0
SCSI WRITE LONG (10): Illegal request, invalid opcode sense key
[root@system tmp]#
Regards,
Kartik Vashishta
Re: Need to corrupt an ext4 filesystem to performance test e
You can use dd if=/dev/urandom of=/dev/sdf1 bs=4096 seek=somerandomnumber to write random data to the specified location on the hard disk. You can also use /dev/zero if you're so inclined. However, chances are that doing this will not corrupt any critical ext4 directory data, but will "only" silently corrupt your files, which fsck won't notice. If you end up writing that random block of data to an unallocated part of the hard disk, nothing bad will happen.
-
- Posts: 66
- Joined: 2015/02/15 18:35:55
Re: Need to corrupt an ext4 filesystem to performance test e
Thanks for the response, it is much appreciated. I have filled up the file system, df -kh shows it at 100% (is this accurate enough), so, having filled up the filesystem will dd still not corrupt the filesystem or will it?
Regards,
Kartik Vashishta
Regards,
Kartik Vashishta
Re: Need to corrupt an ext4 filesystem to performance test e
In your case dd is likely to corrupt your data, but as ext4 does not calculate any sort of checksums of the data, running fsck on the modified filesystem will not notice any errors.
You would need to be either a) really lucky to hit a block that contains ext4 internal data (superblock, inode information, block bitmap, extent trees, directory blocks, journal etc), or b) somehow determine where those ext4 internal data blocks are. For the latter, the ext4 filesystem tools may be useful. It has been a while since I've last done anything at this level, but perhaps some of the utils listed in man -k ext4 help.
You would need to be either a) really lucky to hit a block that contains ext4 internal data (superblock, inode information, block bitmap, extent trees, directory blocks, journal etc), or b) somehow determine where those ext4 internal data blocks are. For the latter, the ext4 filesystem tools may be useful. It has been a while since I've last done anything at this level, but perhaps some of the utils listed in man -k ext4 help.
-
- Posts: 66
- Joined: 2015/02/15 18:35:55
Re: Need to corrupt an ext4 filesystem to performance test e
Thanks again. Here we go:
[root@system tmp]# mke2fs -n /dev/mapper/500gtestvg-500gbvol
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
32768000 inodes, 131069952 blocks
6553497 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
4000 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000
Could you please give me the exact command to type in? I need to corrupt this good. Regards,
Kartik Vashishta
[root@system tmp]# mke2fs -n /dev/mapper/500gtestvg-500gbvol
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
32768000 inodes, 131069952 blocks
6553497 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
4000 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000
Could you please give me the exact command to type in? I need to corrupt this good. Regards,
Kartik Vashishta
Re: Need to corrupt an ext4 filesystem to performance test e
Oh, I forgot that you'd probably need to add count=1 to the dd command line as well. Otherwise dd would write random data to the hard disk from the specified point onwards until the end of the disk.
I would expect that if you run dd if=/dev/urandom of=/dev/mapper/500gtestvg-500gbvol bs=4096 seek=32768 count=1 you would corrupt the first superblock backup block. Repeat as needed.
I would expect that if you run dd if=/dev/urandom of=/dev/mapper/500gtestvg-500gbvol bs=4096 seek=32768 count=1 you would corrupt the first superblock backup block. Repeat as needed.
-
- Posts: 66
- Joined: 2015/02/15 18:35:55
Re: Need to corrupt an ext4 filesystem to performance test e
Thank you very much. I am somewhat surprised at the lack of tools to simulate file system corruption. I appreciate your help. Regards,
Kartik Vashishta
Kartik Vashishta
-
- Posts: 10642
- Joined: 2005/08/05 15:19:54
- Location: Northern Illinois, USA
Re: Need to corrupt an ext4 filesystem to performance test e
Journaled filesystems got to great lengths to avoid filesystem corruption and the necessity to run fsck.
Depending on your filesystem size and available RAM it may not be possible to fsck the filesystem.
Depending on your filesystem size and available RAM it may not be possible to fsck the filesystem.
-
- Posts: 66
- Joined: 2015/02/15 18:35:55
Re: Need to corrupt an ext4 filesystem to performance test e
I tried dd but could not corrupt the filesystem.
my fstab looks like this:
/dev/500gtestvg/500gbvol /500GBFS ext4 defaults 0 2
I rebooted and the filesystem mounted without issues, I did not notice anything unusual on the console either.
Please advise.
my fstab looks like this:
/dev/500gtestvg/500gbvol /500GBFS ext4 defaults 0 2
I rebooted and the filesystem mounted without issues, I did not notice anything unusual on the console either.
Please advise.