This siteAll blogsLe 17ClémentCCBCuisineLe 3ContactSe connecterS'inscrire
  • All blogs
  • Le 17
  • Clément
  • CCB
  • Cuisine
  • Le 3
  • Contact

  • S'inscrire

Recettes informatiques

  • Page de garde
  • Contact
  • Se connecter
  • « APT configuration files
  • Installation des vmware-tools sous Debian Lenny/Testing »

Linux and 4096-Byte Sector Hard Drives

Posted by mazet on Feb 14 2010 in Systeme

New hard drives uses 4k-byte sector but devices cheat on linux and say that they're using 512-byte sector as usual. If partitions are not aligned to 8 blocks, there's a huge throughput degradation. Use the 'expert' menu [x] on fdisk to move beginning of data in a partition [b] and align it to 8 blocks.

Test program:

Code

#define _LARGEFILE64_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
 
#define N 4096
char buffer[N];
 
int main(int argc, char *argv[])
{
  int fd, i, j;
 
  char *file = "test.dat";
  int size = 2048;
 
  printf ("usage: %s <file> <#blocs>\n", argv[0]);
  if (argc > 1) file = argv[1];
  if (argc > 2) size = atoi (argv[2]);
 
  fd = open(file, O_WRONLY | O_CREAT | O_TRUNC | O_SYNC);
  printf ("open %s (fd=%d)\n", file, fd);
  if (fd <= 0) return 1;
 
  printf ("write %dx%d=%d data\n", size, N, size * N);
  for (i = 0; i < size; i++) {
    int rand = random ();
    for (j = 0; j < N; j++, rand = (rand << 1) ^ (rand >> sizeof (int)))
      buffer[j] ^= rand;
    write(fd, buffer, N);
  }
  
  close(fd);
 
  return 0;        
}
This entry was posted by mazet and filed under Systeme.

No feedback yet

Catégories

  • Toutes
  • Non catégorisé
  • Programmation
    • Awk
    • Bash
    • C
    • C++
    • Javascript
    • LaTeX
    • Perl
    • Tcl/Tk
  • Systeme
    • Android
    • Debian
    • Ubuntu

Contenu

  • Creating a network between 2 virtual machines on Windows with Qemu
  • Build a Debian package for pdmenu
  • Extract informations from epub file
  • Connexion PostgreSql / Java par Socket Unix
  • Example of fork and respawn
  • Start SSH daemon on Git portable distribution
  • Create a git mirror
  • Color diff
  • Create on Debian a Minecraft server
  • GIT/HG/SVN on multiple repos simultaneously
  • Convert Comics into CBZ format
  • Random password generator function
  • Convert to camelCase
  • DKIM and SPF
  • Migration from BackupPC 3 (Debian package) to BackupPC 4 (Standalone Installation)
  • Minimal BC for Mingw
  • Diskless Debian cluster
  • Colorize log file
  • Generate certificates with (or without) a certificate authority
  • Install Mercurial (hg) on Android
Juin 2025
Lun Mar Mer Jeu Ven Sam Dim
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30            
 << <   > >>
  • Accueil
  • Récemment
  • Archives
  • Catégories
  • Derniers commentaires

Rechercher

Flux XML

  • RSS 2.0: Posts
  • Atom: Posts
What is RSS?

©2025 by Laurent Mazet • Contact • Aide • Photo albums software

Blog software

Cookies are required to enable core site functionality.