Author Topic: Changing file system blocksize on 4G USB drive  (Read 2331 times)

Offline wedgetail

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 2469
  • Any Bugs in site?
Changing file system blocksize on 4G USB drive
« on: March 10, 2012, 07:56:01 PM »
I am making an attempt to change the blocksize from the almost universal 512 bytes to 4096 bytes.

The stick held a liveUSB KDE-mini, and I have only make a dd copy of it for safe keeping, then immediately used mkfs as follows:

Quote
[root@KDE-mini gert]# mkfs -t ext3 -b 4096 /dev/sdc1
mke2fs 1.42 (29-Nov-2011)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks
244320 inodes, 975940 blocks
48797 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1002438656
30 block groups
32768 blocks per group, 32768 fragments per group
8144 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done

[root@KDE-mini gert]#


Just thought I would check

Quote
[root@KDE-mini gert]# fdisk -l /dev/sdc

Disk /dev/sdc: 4005 MB, 4005560320 bytes
255 heads, 63 sectors/track, 486 cylinders, total 7823360 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: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *          63     7807589     3903763+  83  Linux
[root@KDE-mini gert]#

Shortlived happiness  

Any suggestions, I am bracing myself to be embarrased  :)
« Last Edit: March 13, 2012, 01:00:50 AM by wedgetail »
32 bit: KDE (older) & various KDE-mini, ASUSTek P5P41D Rev X.0x, BIOS AMI0207 07/21/2009, "Pentium(R) Dual-Core CPU E5300 @ 2.60GHz", nVidia GeForce 9600 GT, 2x1GB Seagate Technology 1000528AS HDD
TV CompuPro VideoMate Vista E700 (not working in Linux), Acer X243HD LCD Screen

Offline AS

  • Hero Member
  • *****
  • Posts: 4098
  • Have a nice ... night!
Re: Changing file system blocksize on 4G USB drive
« Reply #1 on: March 10, 2012, 08:13:15 PM »
I am making an attempt to change the blocksize from the almost universal 512 bytes to 4096 bytes.

You are attempting to become an incumbent of Seagate and Western Digital  ::)

Quote
The stick held a liveUSB KDE-mini, and I have only make a dd copy of it for safe keeping, then immediately used mkfs as follows:

Quote
[root@KDE-mini gert]# mkfs -t ext3 -b 4096 /dev/sdc1
mke2fs 1.42 (29-Nov-2011)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks
244320 inodes, 975940 blocks
48797 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1002438656
30 block groups
32768 blocks per group, 32768 fragments per group
8144 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done

[root@KDE-mini gert]#


Just thought I would check

Quote
[root@KDE-mini gert]# fdisk -l /dev/sdc

Disk /dev/sdc: 4005 MB, 4005560320 bytes
255 heads, 63 sectors/track, 486 cylinders, total 7823360 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: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *          63     7807589     3903763+  83  Linux
[root@KDE-mini gert]#

Shortlived happiness 

Any suggestions, I am bracing myself to be embarrased  :)

You are confusing the disk sector with the filesystem block   :D
the block size of a device (stick, disk, card, ...) is a physical size decided at time of device design.
the block size of a filesystem is decided automatically from mkfs, or manually like you have done.

Have a nice day!  ;)
AS

Offline wedgetail

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 2469
  • Any Bugs in site?
Re: Changing file system blocksize on 4G USB drive
« Reply #2 on: March 10, 2012, 08:42:33 PM »
AS
A little bit of knowledge, as the saying goes is dangerous, I am constantly being reminded.

I was just reading this
http://linux-howto-guide.blogspot.com.au/2009/10/increase-usb-flash-drive-write-speed.html

The penny came slowly running towards me, no dropping speed here  ;D

Now I understand, so I need to find a stick that was 'made' with 4k block size.

Note to myself
I have restored the partition file image:

Quote

root@KDE-mini gert]# dd if=/dev/sdc  of=backup.img bs=1M
3820+0 records in
3820+0 records out
4005560320 bytes (4.0 GB) copied, 241.785 s, 16.6 MB/s
[root@KDE-mini gert]#



This is a LiveUSB raw imagage copy
file:///media/USB465-1B/Data-Recovered-100711/Data/x8-ISO_Files/MyLiveCDs/120311-backup_KDE-mini_livUSB_4GB.img


Restoring the file I used the cli memory and just changed file names as

Quote

[root@KDE-mini gert]# dd of=/dev/sdc  if=backup.img bs=1M



Unfortunately, I closed the konsole window before copying result.  Restore speed, ie write speed was 7.9 MB/s
This is about expectations of half read speed.


  
« Last Edit: March 10, 2012, 09:32:34 PM by wedgetail »
32 bit: KDE (older) & various KDE-mini, ASUSTek P5P41D Rev X.0x, BIOS AMI0207 07/21/2009, "Pentium(R) Dual-Core CPU E5300 @ 2.60GHz", nVidia GeForce 9600 GT, 2x1GB Seagate Technology 1000528AS HDD
TV CompuPro VideoMate Vista E700 (not working in Linux), Acer X243HD LCD Screen

Offline menotu

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 15506
  • ┌∩┐(◕_◕)┌∩┐
Re: Changing file system blocksize on 4G USB drive
« Reply #3 on: March 11, 2012, 03:56:15 AM »
The penny came slowly running towards me, no dropping speed here  ;D  

 ;D ;D
PCLinuxOS 32bit KDE 4.10.4; kernel-3.4.11-pclos1.bfs & 64bit 3.4.38bfs; NVidia GeForce 8400GS 1GB 310.19 driver

Sony Vaio SVE1513A4ESI Laptop, Intel Core i5, 2.6GHz, 6GB RAM, 750GB, 15.6" Intel HD Graphics 4000

Offline AS

  • Hero Member
  • *****
  • Posts: 4098
  • Have a nice ... night!
Re: [ solved ] Changing file system blocksize on 4G USB drive
« Reply #4 on: March 11, 2012, 06:37:57 AM »
About USB device speed, you may be interested about some results:
http://www.pclinuxos.com/forum/index.php/topic,96370.msg815513.html#msg815513

 ;)

Offline wedgetail

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 2469
  • Any Bugs in site?
Re: [ solved ] Changing file system blocksize on 4G USB drive
« Reply #5 on: March 11, 2012, 08:35:52 AM »
AS
I had totally forgotten your thread, I saw it a few weeks ago but at the time it was just a quick read.  Now my understanding of the "block" has increase a little bit I have read it much closer.

Quote
That's because most of NAND flash drives (the most commonly used flash sticks) have 128k erase block size .....


Above is quoted from
http://linux-howto-guide.blogspot.com.au/2009/10/increase-usb-flash-drive-write-speed.html

I tried to use fdisk to line up cyl,sect,heads on my 4GB drive but failed and got myself into a muddle. Still am.

What I have done, calculated what I believe should be the 128K boundaries on your test series.

AS   AS   AS   AS   Blog   
64   63   124   247   224   Heads
62   62   62   62   56   Sectors/track
3968   3906   7688   15314   12544   Sectors/cylinder
2031616   1999872   3936256   7840768   6422528   Bytes
15.5   15.25   30.03   59.82   49   128K (131072B ) boundary

With the reported CHS values I have made a quick calculation of the total bytes per cylinder and divided with the 12k bytes value 13107 Bytes, only the Blog column has an integer.

From my understanding the non integer  value indicates that more write time needed as a 128K boundary may be crossed.

My attempt at reorganising the CHS failed the values changed but I still ended up with real value factor for the cylinder multiples of 128K instead of the integer I was hoping for.

I have given up for the time being.   ;D





« Last Edit: March 11, 2012, 08:38:10 AM by wedgetail »
32 bit: KDE (older) & various KDE-mini, ASUSTek P5P41D Rev X.0x, BIOS AMI0207 07/21/2009, "Pentium(R) Dual-Core CPU E5300 @ 2.60GHz", nVidia GeForce 9600 GT, 2x1GB Seagate Technology 1000528AS HDD
TV CompuPro VideoMate Vista E700 (not working in Linux), Acer X243HD LCD Screen

Offline wedgetail

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 2469
  • Any Bugs in site?
Re: Changing file system blocksize on 4G USB drive
« Reply #6 on: March 13, 2012, 03:54:12 AM »
I am opening this topic again as some more experimenting taking place, and I am struggling with fdisk.

I am experimenting with changing the geometry of the USB stick, to do with setting up 128KB cylinder boundaries.

The aim to set out H and S values and let C take up proper value.

I start with this, the final result I am aiming for.

Quote
[root@KDE-mini-Cprog gert]# fdisk -l /dev/sdc

Disk /dev/sdc: 4005 MB, 4005560320 bytes
151 heads, 48 sectors/track, 1079 cylinders, total 7823360 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: 0x000af4cd

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1     7820591     3910295+  83  Linux
[root@KDE-mini-Cprog gert]#

Then I load the original USB stick Image via dd

Code: [Select]
[root@KDE-mini-Cprog gert]# dd if=/media/USB465-1B/Data-Recovered-100711/Data/x8-ISO_Files/MyLiveCDs/  bs=1M of=/dev/sdc
3820+0 records in
3820+0 records out
4005560320 bytes (4.0 GB) copied, 502.664 s, 8.0 MB/s
[root@KDE-mini-Cprog gert]#

Quote
[root@KDE-mini-Cprog gert]# fdisk -l /dev/sdc

Disk /dev/sdc: 4005 MB, 4005560320 bytes
255 heads, 63 sectors/track, 486 cylinders, total 7823360 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: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *          63     7807589     3903763+  83  Linux
[root@KDE-mini-Cprog gert]#

Now change geometry with fdisk, by the way here I have to umount the device to get success

Code: [Select]
[root@KDE-mini-Cprog gert]# fdisk -H 151 -S 48 /dev/sdc

Command (m for help): p

Disk /dev/sdc: 4005 MB, 4005560320 bytes
151 heads, 48 sectors/track, 1079 cylinders, total 7823360 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: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *          63     7807589     3903763+  83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@KDE-mini-Cprog gert]#

So the partition table has been altered, I pulled out the stick and inserted it again.

Quote
[root@KDE-mini-Cprog gert]# fdisk /dev/sdc

Command (m for help): p

Disk /dev/sdc: 4005 MB, 4005560320 bytes
255 heads, 63 sectors/track, 486 cylinders, total 7823360 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: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *          63     7807589     3903763+  83  Linux

Command (m for help): q

I quit here a bit worried as there is no sign of partition table having changed.

Proceed to re-establish a file system as changing CHS value seem to upset the existing partition.  Reformatting as follows.

Code: [Select]
[root@KDE-mini-Cprog gert]# mke2fs -t ext3 -L problem /dev/sdc1
mke2fs 1.42 (29-Nov-2011)
Filesystem label=problem
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
244320 inodes, 975940 blocks
48797 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1002438656
30 block groups
32768 blocks per group, 32768 fragments per group
8144 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done

[root@KDE-mini-Cprog gert]#


Looking again at geometry with fdisk

Quote
[root@KDE-mini-Cprog gert]# fdisk -l /dev/sdc

Disk /dev/sdc: 4005 MB, 4005560320 bytes
255 heads, 63 sectors/track, 486 cylinders, total 7823360 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: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *          63     7807589     3903763+  83  Linux
[root@KDE-mini-Cprog gert]#

And also with sfdisk

Code: [Select]
[root@KDE-mini-Cprog gert]# sfdisk -g /dev/sdc
/dev/sdc: 486 cylinders, 255 heads, 63 sectors/track
[root@KDE-mini-Cprog gert]#

So far is there anything wrong in my method?
32 bit: KDE (older) & various KDE-mini, ASUSTek P5P41D Rev X.0x, BIOS AMI0207 07/21/2009, "Pentium(R) Dual-Core CPU E5300 @ 2.60GHz", nVidia GeForce 9600 GT, 2x1GB Seagate Technology 1000528AS HDD
TV CompuPro VideoMate Vista E700 (not working in Linux), Acer X243HD LCD Screen