Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Samsung 840 250G alignment
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
atzorvas
n00b
n00b


Joined: 28 Jun 2013
Posts: 1
Location: Greece

PostPosted: Fri Jun 28, 2013 7:23 pm    Post subject: Samsung 840 250G alignment Reply with quote

So, i have bought a new Samsung 840 non-pro 250G, as reported here:

Quote:

Series 840 250 GB (non-pro):
NAND erase block size: 1536kb
NAND page size: 8kb
So 1536/8 = 192 pages per block.


so the following command as proposed to http://wiki.gentoo.org/wiki/SSD
Code:
fdisk -S 32 -H 32 /dev/sda
will mis-align the disk

could someone help me with the right values?
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2448
Location: Germany

PostPosted: Sat Jun 29, 2013 12:25 pm    Post subject: Reply with quote

Don't use `fdisk` unless you absolutely have to.

`parted` is a much better choice, if you tell it to `unit mib` you can't go wrong - it will give you MiB-aligned partitions which is fine for any HDD/SSD.
Back to top
View user's profile Send private message
eccerr0r
Advocate
Advocate


Joined: 01 Jul 2004
Posts: 3964
Location: USA

PostPosted: Tue Jul 30, 2013 2:35 pm    Post subject: Reply with quote

Ok, this is actually kind of weird.

I've never seen NAND erase blocks of fractional MB, 1536 is 1.5MiB. This means that you have to go 3MiB to keep erase blocks aligned, but really, if you get page size alignment right, this isn't that great a deal. This isn't as bad as getting page alignment wrong, this will cause a lot of extra writes.

Getting erase blocks misaligned will also cause premature writes but it won't happen as often and on good disks, garbage collection will happen in the background anyway.

So if you want, make sure your MB boundaries are on 3MiB boundaries, but it's not that big a deal. Just don't align by sector (512B) - that will kill performance if you're off by 1. Off by 0.5 MiB or 1MiB, you won't notice.
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed to be advocating?
Back to top
View user's profile Send private message
schentuu
n00b
n00b


Joined: 18 Sep 2004
Posts: 19
Location: paderborn, germany

PostPosted: Mon Jul 14, 2014 3:10 pm    Post subject: Reply with quote

Sorry for digging out an old thread, but since i think i came a little step further, this might help. But i still have a question....


Same problem here.

I also bought an EVO 840 with 250 GB.

Until now i found out, that you could allign the SSD correctly with gdisk.

Code:

# gdisk /dev/sda
GPT fdisk (gdisk) version 0.8.8

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): p
Disk /dev/sda: 488397168 sectors, 232.9 GiB
Logical sector size: 512 bytes
...

Thats the first information you'll need: the logical sector size is 512 bytes.
When deviding the erase block size (1536 * 1024 bytes) by the logical sector size (512 bytes) you'll get 3072 sectors.
Lets go back to gdisk. In the expert options (x) You can edit the sector alignment value (l).
Set this to 3072, like calculated above. After this return to the gdisk main menu (m).
Code:

Command (? for help): ?
b   back up GPT data to a file
c   change a partition's name
d   delete a partition
i   show detailed information on a partition
l   list known partition types
n   add a new partition
o   create a new empty GUID partition table (GPT)
p   print the partition table
q   quit without saving changes
r   recovery and transformation options (experts only)
s   sort partitions
t   change a partition's type code
v   verify disk
w   write table to disk and exit
x   extra functionality (experts only)
?   print this menu

Command (? for help): x

Expert command (? for help): ?
a   set attributes
c   change partition GUID
d   display the sector alignment value
e   relocate backup data structures to the end of the disk
g   change disk GUID
h   recompute CHS values in protective/hybrid MBR
i   show detailed information on a partition
l   set the sector alignment value
m   return to main menu
n   create a new protective MBR
o   print protective MBR data
p   print the partition table
q   quit without saving changes
r   recovery and transformation options (experts only)
s   resize partition table
t   transpose two partition table entries
u   Replicate partition table on new device
v   verify disk
w   write table to disk and exit
z   zap (destroy) GPT data structures and exit
?   print this menu

Expert command (? for help): l
Enter the sector alignment value (1-65536, default = 2048): 3072

Expert command (? for help): m

Now the allignment is set correctly and you can partition your ssd simmilar to fdisk.


So far, so good.
I posted this in hope to help other to get that far.

Now to my problem:

gdisk will create a GPT partition table.
Thats absolutely okay for newer systems using (u-)EFI.
But i try to speed up an older system which still uses BIOS with that SSD.

Do you know how i can make my BIOS boot from a drive using a GPT partition table?
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 32027
Location: 56N 3W

PostPosted: Mon Jul 14, 2014 3:43 pm    Post subject: Reply with quote

schentuu,

BIOS booting from a GPT works here. There is a trap or two for the unwary.

First, your GPT disc must have a valid protective MSDOS partition table.
It needs the signature word at the end correct and at least one partition defined.
The boot loader needs to be in LBA 0, grub-legacy works for me.

Lastly, some brain dead BIOSes will check the bootable flag. To keep these BIOSes happy, this needs to be set on the one partition in the protective MSDOS partition table, not on the real GPT boot partition.

The last trap for the unwary is that on a GPT drive, grub cannot install its stage1.5 file, as there is no space. As a result, stage1 blindly loads stage2 using a block list.
This means that if grub-legacy is ever updated, it must be reinstalled to the MBR to update the block list.

Be aware that many SSDs lie about the sector size. They are never really 512B but the drive will do read/modify/writes to fake this for the operating system.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
schentuu
n00b
n00b


Joined: 18 Sep 2004
Posts: 19
Location: paderborn, germany

PostPosted: Mon Jul 14, 2014 4:21 pm    Post subject: Reply with quote

Thanks for your reply!
NeddySeagoon wrote:
Be aware that many SSDs lie about the sector size. They are never really 512B but the drive will do read/modify/writes to fake this for the operating system.

Now i'm confused. If i cant rely on the sector size, how can i then do the alignment right?

All other tools i know (like gparted for example) allow alignung on MiB's, but my SSD's erase block size is 1.5 MiB.
So i would need to align to that and not to 1.0 MiB.

How can i do this, when my method (calculating the number of sectors) won't work ???
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 32027
Location: 56N 3W

PostPosted: Mon Jul 14, 2014 4:40 pm    Post subject: Reply with quote

schentuu,

Its safe to assume that the erase block size is exactly divisible by the physical write bloc size, whatever that may be so if you want erase block alignment, use a tool that understands partition sizes in Mb.

The hard bit is moving the start of the first partition around.
However, an others have said, write block alignment is much more important than erase block alignment.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
vasettoo
n00b
n00b


Joined: 11 Nov 2012
Posts: 32

PostPosted: Mon Jul 14, 2014 5:23 pm    Post subject: Reply with quote

From an Arch linux forum guy who suggests for SSD Samsung 840 EVO 250 GB partitioning be done in this way:
Code:
How to correctly partition and create ext4 fs on this SSD, taking care of the alignment based on Erase Block Size and Page Size.

This is intended for a Linux install only on a BIOS system.

----------------------
Partitioning
----------------------

# gdisk /dev/sda

---
GPT fdisk (gdisk) version 0.8.8

Partition table scan:
  MBR: not present
  BSD: not present
  APM: not present
  GPT: not present

Creating new GPT entries.

Command (? for help): p
Disk /dev/sda: 488397167 sectors, 232.9 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 9396D5CC-DBA4-4D65-986F-FF4AA6A7ADA4
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 488397133
Partitions will be aligned on 2048-sector boundaries
Total free space is 488397100 sectors (232.9 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
---

Command (? for help): x

Expert command (? for help): L
Enter the sector alignment value (1-65536, default = 2048): 3072

Expert command (? for help): m

-----

Command (? for help): n
Partition number (1-128, default 1):
First sector (34-488397133, default = 3072) or {+-}size{KMGTP}:
Last sector (3072-488397133, default = 488397133) or {+-}size{KMGTP}: +3M
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): ef02
Changed type of partition to 'BIOS boot partition'

----------------

Command (? for help): n
Partition number (2-128, default 2):
First sector (34-488397133, default = 9216) or {+-}size{KMGTP}:
Last sector (9216-488397133, default = 488397133) or {+-}size{KMGTP}: +45G
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 8300
Changed type of partition to 'Linux filesystem'

------------------

Command (? for help): n
Partition number (3-128, default 3): 
First sector (34-488397133, default = 94381056) or {+-}size{KMGTP}:
Last sector (94381056-488397133, default = 488397133) or {+-}size{KMGTP}:
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 8300
Changed type of partition to 'Linux filesystem'

---------------------

Command (? for help): p
Disk /dev/sda: 488397167 sectors, 232.9 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): D0CED8E4-2665-481E-8568-B2C7456A878A
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 488397133
Partitions will be aligned on 3072-sector boundaries
Total free space is 3038 sectors (1.5 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            3072            9215   3.0 MiB     EF02  BIOS boot partition
   2            9216        94381055   45.0 GiB    8300  Linux filesystem
   3        94381056       488397133   187.9 GiB   8300  Linux filesystem


--------------

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/sda.
The operation has completed successfully.


------------------------------------------------------------------
FS creation
------------------------------------------------------------------
to format /dev/sda2 and /dev/sda3, will hold / and /home respectively.

# mkfs.ext4 -b 4096 -E stride=2,stripe-width=384 /dev/sdXX

/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
Details about the previous steps
//////////////

---------------------------------------------------
Information about the Page and Erase Block Size
----------------

according to these posts, the EVO should share the same specs as the 840 non-pro, it's also a TLC.

http://askubuntu.com/questions/314262/partition-alignment-confusion
http://www.thessdreview.com/Forums/ssd-beginners-guide-discussion/3630.htm

Series 840 250 GB (non-pro):
NAND erase block size: 1536kb
NAND page size: 8kb
So 1536/8 = 192 pages per block.

to get the correct alignment, the initial sector of each partition must be a multiple of 1536kb, according to this table

Size          Sectors
512 bytes   1
1 kb           2
512 kb           1024
1 MB           2048
1 GB           2097152

the minimum would be 3072 sectors.

link for the table and further explanation.
http://siduction.org/index.php?module=news&func=display&sid=78

Edit 21/05/14
New source confirming 1536 kiB EBS and 8 kiB page size.

https://bbs.archlinux.org/viewtopic.php?pid=1385980#p1385980

---------------------------------------------------
Information about optimizing ext4 filesytem
----------------
to create the FS, ext4, we will take into account once again the Erase block size,

According to the recommendations here
http://thelastmaimou.wordpress.com/2013/05/04/magic-soup-ext4-with-ssd-stripes-and-strides/
https://raid.wiki.kernel.org/index.php/RAID_setup#ext2.2C_ext3.2C_and_ext4


chunk size = 128kB (set by mdadm cmd, see chunk size advise above)
block size = 4kB (recommended for large files, and most of time)
stride = chunk / block = 128kB / 4k = 32
stripe-width = stride * ( (n disks in raid5) - 1 ) = 32 * ( (3) - 1 ) = 32 * 2 = 64

If the chunk-size is 128 kB, it means, that 128 kB of consecutive data will reside on one disk. If we want to build an ext2 filesystem with 4 kB block-size, we realize that there will be 32 filesystem blocks in one array chunk.
stripe-width=64 is calculated by multiplying the stride=32 value with the number of data disks in the array.
A raid5 with n disks has n-1 data disks, one being reserved for parity. (Note: the mke2fs man page incorrectly states n+1; this is a known bug in the man-page docs that is now fixed.) A raid10 (1+0) with n disks is actually a raid 0 of n/2 raid1 subarrays with 2 disks each.


We'll use the setup of a "raid" with a single drive, making the chunk size equal to the EBS, and using the usual 4KB block size.

NAND EBS: 1536 KB
NAND Page size: 8KB

chunk size = Page size = 8 KB
block size = 4 KB
stride = Page Size / block size = 2
srtipe-width = EBS / block size = 384

all this ends up in

mkfs.ext4 -b 4096 -E stride=2,stripe-width=384 /dev/sdXX


Taken from original source http://pastebin.com/0Jvn3PyQ

I have the same SSD and following these steps aligning has been OK for me.
Code:
 # blockdev --getalignoff /dev/sda6
0


My partitions and disks:
Code:
# lsblk -f
NAME   FSTYPE  LABEL          UUID                                 MOUNTPOINT
sda                                                               
├─sda1 ntfs-3g Възстановяване 924A383B4A381F03                     
├─sda2 vfat                   4A4B-2C86                           
├─sda3                                                             
├─sda4 ntfs-3g                FC9AE53A9AE4F256                     
├─sda5 ext2                   0e3e89f7-7129-4597-84ad-b711e995c1a2
└─sda6 ext4                   3225cd86-9cd3-4d8c-b0e3-cbc5ebcaa7e2 /
sdb                                                               
├─sdb1 swap    SWAP           96d826cc-a3ba-417b-8b9f-ad3c10aa5020 [SWAP]
├─sdb2 ext4    VAR            21d1e109-fb7b-4af3-bd55-dc3c5fc933c8 /var
├─sdb3 ext4    PORTAGE        37fde6a6-e0b2-48b6-b1b6-b98ace57c338 /usr/portage
├─sdb4 ext4    HOME           c097704e-1768-463c-a9fd-7e828f410575 /home
└─sdb5 ntfs-3g STORAGE        C41CF85E1CF84CC4                     /media/MEDIA
sdc                                                               
└─sdc1 ntfs-3g My Book        5488E13B88E11C6C                     /run/media/vasettoo/My Book


Hope this helps you.
Best regards!
Back to top
View user's profile Send private message
schentuu
n00b
n00b


Joined: 18 Sep 2004
Posts: 19
Location: paderborn, germany

PostPosted: Tue Jul 15, 2014 4:53 am    Post subject: Reply with quote

Thank you for your reply!

That information helped me a lot.
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2448
Location: Germany

PostPosted: Tue Jul 15, 2014 10:59 am    Post subject: Reply with quote

vasettoo wrote:
I have the same SSD and following these steps aligning has been OK for me.
Code:
 # blockdev --getalignoff /dev/sda6
0


I'm not sure where this blockdev --getalignoff advice is coming from. For most disks it will return 0 for almost anything. There is no magic, the system does not know the SSD page size, so it can't tell you anything about alignment.

Erase block alignment does not matter much at all, reads and writes are aligned to page size, not erase block size. The addressing is remapped inside the SSD anyway.

Quote:

http://codecapsule.com/2014/02/12/coding-for-ssds-part-1-introduction-and-table-of-contents/

Reads are aligned on page size
Writes are aligned on page size
To ensure that logical writes are truly aligned to the physical memory, you must align the partition to the NAND-flash page size of the drive.


An 1.5MiB alignment (on the filesystem level) is impossible anyway. Especially in Gentoo. Too many small files (>50k for a single /usr/src/linux Kernel). If you line these files up with 1.5MiB alignment for each individual file, it would waste 50k erase blocks and consume 75GiB. I sincerely hope that the SSD will do better than that.

In general my experience with SSD so far is that they "just work", and work well, without any special considerations. Don't worry so much about alignment and write cycles. MiB alignment you get pretty much automatically (any tool does that nowadays, mdadm / cryptsetup / lvm etc. all changed their defaults in that regard if it wasn't already MiB aligned before). Add a weekly or monthly fstrim to that and you're good.
_________________
Linux-User @ VServer (Debian), Desktop (Gentoo), Netbook (Ubuntu), Router (OpenWRT), PDA (Cacko), Smartphone (Android)
Back to top
View user's profile Send private message
Polyatomic
n00b
n00b


Joined: 18 May 2014
Posts: 12
Location: Adelaide , South Australia

PostPosted: Tue Aug 19, 2014 8:45 am    Post subject: Reply with quote

vasettoo wrote:
From an Arch linux forum guy who suggests for SSD Samsung 840 EVO 250 GB partitioning be done in this way:
How to correctly partition and create ext4 fs on this SSD, taking care of the alignment based on Erase Block Size and Page Size.


Wicked man I've been searching for this all afternoon, so I could partion another ssd. Is the sector alignment value the same on the 128 gig Samsung 840.

frostschutz wrote:
vasettoo wrote:
I have the same SSD and following these steps aligning has been OK for me.
Code:
 # blockdev --getalignoff /dev/sda6
0


Don't worry so much about alignment and write cycles. MiB alignment you get pretty much automatically (any tool does that nowadays, mdadm / cryptsetup / lvm etc. all changed their defaults in that regard if it wasn't already MiB aligned before). Add a weekly or monthly fstrim to that and you're good.


frostschutz does GNU parted do the alignment automatically? Do I have to at least start at a boundary of a block? what ever that value is?. vasettoo's paste uses a sector alignment value of 3072 and I'm wondering why. I am asking because I used parted here is the output of
gdisk /dev/sda

Code:
Disk /dev/sdb: 250069680 sectors, 119.2 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 431D2355-B16D-4DBA-8A03-D8A0AEC9352B
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 250069646
Partitions will be aligned on 2048-sector boundaries
Total free space is 2669 sectors (1.3 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          976895   476.0 MiB   EF00  ESI
   2          976896       250068991   118.8 GiB   0700  primary


and parted /dev/sdb
Code:
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                           
Model: ATA Samsung SSD 840 (scsi)
Disk /dev/sdb: 128GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End    Size   File system  Name     Flags
 1      1049kB  500MB  499MB  fat32        ESI      boot
 2      500MB   128GB  128GB  ext4         primary

I've been trying to find out where the boudaries are ( or the size of the blocks) as I have been reading its one important issue. I was going to repartiton my other drive but now I've seen your post I think I'll wait. Hope to hear from you man. I hang around in #gentoo, I use the same nick there too.
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2448
Location: Germany

PostPosted: Tue Aug 19, 2014 9:57 pm    Post subject: Reply with quote

Just use start = multiple of 1 MiB (or 2048 512byte-sectors) and you're good.

If you use 'unit mib' in parted, all partitions you create should end up being MiB aligned.
_________________
Linux-User @ VServer (Debian), Desktop (Gentoo), Netbook (Ubuntu), Router (OpenWRT), PDA (Cacko), Smartphone (Android)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum