# Never the same /dev for new SSD after switching to AHCI mode

## philip

I recently installed a new 120G SSD (Corsair series 3). To maximize I/O performance I chose AHCI mode of the SATA controller, in the motherboard BIOS.  Since then the kernel never designate the drive with the same /dev at boot. It used to be /dev/sdb1 before. Now I get /dev/sdg1 sometimes. Other times I get /dev/sdh1 and occassionally /dev/sdb1.  

I am well aware that I can use /etc/udev/rules.d to set the device designation for good (e.g. by using the serial number of the disk). 

But I would like to understand why the kernel gives my disk different /dev designation at every boot, eventhough there is no other HW device removed or added to the system in between shutdown and boot. 

I use the disk solely for storing my virtual disk image for VirtualBox (the foo.vdi file)

Can anyone shed some light over this?

Some system parameters:

My mother board is a ASUS M3N-HT Delux (www.asus.com/Motherboards/AMD_AM2Plus/M3NHT_DeluxeMempipe/)

```
uname -a

Linux phils_pc 2.6.39-gentoo-r2 #1 SMP PREEMPT Fri Jul 15 11:47:12 CEST 2011 i686 AMD Phenom(tm) 9550 Quad-Core Processor AuthenticAMD GNU/Linux
```

Kernel settings for AHCI:

```
# cat /usr/src/linux/.config | grep AHCI 

CONFIG_SATA_AHCI=y

# CONFIG_SATA_AHCI_PLATFORM is not set

# CONFIG_SATA_ACARD_AHCI is not set
```

dmesg:

```
EXT3-fs (hda4): using internal journal

EXT3-fs: barriers not enabled

kjournald starting.  Commit interval 5 seconds

EXT3-fs (hdb1): using internal journal

EXT3-fs (hdb1): mounted filesystem with ordered data mode

EXT3-fs (sdg1): error: can't find ext3 filesystem on dev sdg1.

EXT3-fs: barriers not enabled

kjournald starting.  Commit interval 5 seconds

EXT3-fs (sda1): using internal journal

EXT3-fs (sda1): mounted filesystem with ordered data mode

Adding 2939888k swap on /dev/hda3.  Priority:-1 extents:1 across:2939888k 

hda: task_no_data_intr: status=0x51 { DriveReady SeekComplete Error }

hda: task_no_data_intr: error=0x04 { DriveStatusError }

hda: possibly failed opcode: 0xef

hda: cache flushes not supported

hdb: cache flushes supported

ata3.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6 frozen

ata3.00: failed command: SET FEATURES

ata3.00: cmd ef/c2:00:00:00:00/00:00:00:00:00/40 tag 0

         res 40/00:fe:00:00:00/00:00:00:00:00/40 Emask 0x4 (timeout)

ata3.00: status: { DRDY }

ata3: hard resetting link

ata3: SATA link up 1.5 Gbps (SStatus 113 SControl 300)

ata3.00: configured for UDMA/133

ata3: EH complete

ata3.00: configured for UDMA/133

ata3: EH complete

ata6: exception Emask 0x10 SAct 0x0 SErr 0x5800000 action 0xe frozen

ata6: SError: { LinkSeq TrStaTrns DevExch }

ata6: hard resetting link

ata6: SATA link up 1.5 Gbps (SStatus 113 SControl 300)

ata6.00: ATA-8: Corsair Force 3 SSD, 1.3.3, max UDMA/133

ata6.00: 234441648 sectors, multi 16: LBA48 NCQ (depth 31/32)

ata6.00: configured for UDMA/133

ata6: EH complete

scsi 5:0:0:0: Direct-Access     ATA      Corsair Force 3  1.3. PQ: 0 ANSI: 5

sd 5:0:0:0: [sdh] 234441648 512-byte logical blocks: (120 GB/111 GiB)

sd 5:0:0:0: [sdh] Write Protect is off

sd 5:0:0:0: [sdh] Mode Sense: 00 3a 00 00

sd 5:0:0:0: [sdh] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA

sd 5:0:0:0: Attached scsi generic sg9 type 0

 sdh: sdh1

sd 5:0:0:0: [sdh] Attached SCSI disk

virtuoso-t[3397]: segfault at fffffffe ip 0844e8ba sp b3a4b760 error 4 in virtuoso-t[8048000+8e0000]

```

Note the error in dmesg output:

```
EXT3-fs (sdg1): error: can't find ext3 filesystem on dev sdg1
```

This is strange because the disk is formatted with ext3 and once the disk is mounted, the file system works OK

blkid:

```
# blkid

/dev/hda2: UUID="c8666160-7009-4686-9718-57a698267319" TYPE="ext2" LABEL="Int_80GB_root+w7" 

/dev/hda1: UUID="bd39473e-35f0-48d5-be64-fdcbec706af5" SEC_TYPE="ext2" TYPE="ext3" 

/dev/sr0: LABEL="Philip NystrM-CM-6mer" TYPE="iso9660" 

/dev/hda3: TYPE="swap" 

/dev/hda4: UUID="2a78f289-c6a4-4ec2-a223-efe0f828dc00" TYPE="ext3" 

/dev/hdb1: LABEL="Int_160GB_BUP_HD" UUID="9b013a6b-ced6-4c8c-97c7-a0dc81f07b75" TYPE="ext3" 

/dev/sda1: UUID="253e82f4-eef8-4123-8517-4cb5e140aa32" TYPE="ext3" LABEL="Int_500GB_Pic_HD" 

/dev/sdg1: UUID="D00B-0094" TYPE="vfat" 

/dev/sdf1: LABEL="Ext_500GB_HD_1" UUID="19a818cf-976f-4295-bc68-1ee7ec048779" SEC_TYPE="ext2" TYPE="ext3" 

/dev/sdh1: UUID="0de155d0-06d3-4e77-aed6-53517cf053cc" SEC_TYPE="ext2" TYPE="ext3"

fstab:
```

My /etc/fstab:

```
# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.

/dev/hda2               /boot                   ext2            noauto,noatime          1 2

/dev/hda4               /                       ext3            noatime                 0 1

/dev/hda3               none                    swap            sw                      0 0

/dev/hdb1               /mnt/hdb1               ext3            defaults                1 1

/dev/sr0                /mnt/cdrom              iso9660         noauto,user             0 0

/dev/fd0                /mnt/floppy             auto            noauto,user             0 0

/dev/sdg1               /mnt/vb_w7              ext3            defaults                1 1

/dev/sda1               /home/philip/Pictures   ext3            noatime                 0 1

# NOTE: The next line is critical for boot!

none                    /proc           proc            defaults                0 0

# glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for

# POSIX shared memory (shm_open, shm_unlink). 

# (tmpfs is a dynamically expandable/shrinkable ramdisk, and will

#  use almost no memory if not populated with files)

# Adding the following line to /etc/fstab should take care of this:

none                    /dev/shm        tmpfs           defaults                0 0

/dev/hdc                /media/cdrecorder       auto    user,exec,noauto,managed 0 0
```

The PCI i/f for IDe and SATA:

```
00:09.0 SATA controller: nVidia Corporation MCP78S [GeForce 8200] AHCI Controller (rev a2) (prog-if 01 [AHCI 1.0])

        Subsystem: ASUSTeK Computer Inc. Device 82e7

        Flags: bus master, 66MHz, fast devsel, latency 0, IRQ 23

        I/O ports at 09f0 [size=8]

        I/O ports at 0bf0 [size=4]

        I/O ports at 0970 [size=8]

        I/O ports at 0b70 [size=4]

        I/O ports at dc00 [size=16]

        Memory at fe026000 (32-bit, non-prefetchable) [size=8K]

        Capabilities: [44] Power Management version 2

        Capabilities: [8c] SATA HBA v1.0

        Capabilities: [b0] MSI: Enable- Count=1/8 Maskable- 64bit+

        Capabilities: [ec] HyperTransport: MSI Mapping Enable- Fixed+

        Kernel driver in use: ahci

00:06.0 IDE interface: nVidia Corporation MCP78S [GeForce 8200] IDE (rev a1) (prog-if 8a [Master SecP PriP])

        Subsystem: ASUSTeK Computer Inc. Device 82e7

        Flags: bus master, 66MHz, fast devsel, latency 0

        [virtual] Memory at 000001f0 (32-bit, non-prefetchable) [size=8]

        [virtual] Memory at 000003f0 (type 3, non-prefetchable) [size=1]

        [virtual] Memory at 00000170 (32-bit, non-prefetchable) [size=8]

        [virtual] Memory at 00000370 (type 3, non-prefetchable) [size=1]

        I/O ports at f000 [size=16]

        Capabilities: [44] Power Management version 2

        Kernel driver in use: AMD_IDE

07:00.0 IDE interface: Marvell Technology Group Ltd. 88SE6121 SATA II Controller (rev b2) (prog-if 8f [Master SecP SecO PriP PriO])

        Subsystem: Marvell Technology Group Ltd. 88SE6121 SATA II Controller

        Flags: bus master, fast devsel, latency 0, IRQ 16

        I/O ports at 8c00 [size=8]

        I/O ports at 8800 [size=4]

        I/O ports at 8400 [size=8]

        I/O ports at 8000 [size=4]

        I/O ports at 7c00 [size=16]

        Memory at fdaff000 (32-bit, non-prefetchable) [size=1K]

        Capabilities: [48] Power Management version 2

        Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit-

        Capabilities: [e0] Express Legacy Endpoint, MSI 00

        Capabilities: [100] Advanced Error Reporting

        Kernel driver in use: ahci
```

# emerge --info

Portage 2.1.9.42 (default/linux/x86/10.0/desktop, gcc-4.4.5, libc-0-r0, 2.6.39-gentoo-r2 i686)

```
=================================================================

System uname: Linux-2.6.39-gentoo-r2-i686-AMD_Phenom-tm-_9550_Quad-Core_Processor-with-gentoo-2.0.2

Timestamp of tree: Sat, 26 Nov 2011 13:15:01 +0000

app-shells/bash:     4.1_p9

dev-java/java-config: 2.1.11-r3

dev-lang/python:     2.7.1-r1, 3.1.3-r1

dev-util/cmake:      2.8.4-r1

dev-util/pkgconfig:  0.25-r2

sys-apps/baselayout: 2.0.2

sys-apps/openrc:     0.8.2-r1

sys-apps/sandbox:    2.4

sys-devel/autoconf:  2.13, 2.68

sys-devel/automake:  1.6.3-r1, 1.9.6-r3, 1.10.3, 1.11.1

sys-devel/binutils:  2.20.1-r1

sys-devel/gcc:       4.3.4, 4.4.5

sys-devel/gcc-config: 1.4.1-r1

sys-devel/libtool:   2.2.10

sys-devel/make:      3.82

sys-kernel/linux-headers: 2.6.36.1

sys-libs/glibc:      2.12.2

virtual/os-headers:  0

ACCEPT_KEYWORDS="x86"

ACCEPT_LICENSE="*"

CBUILD="i686-pc-linux-gnu"

CFLAGS="-O2 -march=k8 -pipe -fomit-frame-pointer"

CHOST="i686-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /usr/share/openvpn/easy-rsa"

CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.3/ext-active/ /etc/php/cgi-php5.3/ext-active/ /etc/php/cli-php5.3/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"

CXXFLAGS="-O2 -march=k8 -pipe -fomit-frame-pointer"

DISTDIR="/usr/portage/distfiles"

FEATURES="assume-digests binpkg-logs distlocks fixlafiles fixpackages news parallel-fetch protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"

FFLAGS=""

GENTOO_MIRRORS="http://distfiles.gentoo.org http://distro.ibiblio.org/pub/linux/distributions/gentoo"

LANG="en_US.UTF-8"

LDFLAGS="-Wl,-O1 -Wl,--as-needed"

LINGUAS="sv en_US"

MAKEOPTS="-j5"

PKGDIR="/usr/portage/packages"

PORTAGE_CONFIGROOT="/"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"

USE="3dnow X a52 aac aalib acl acpi alsa apache2 audiofile bash-completion berkdb bidi bluetooth branding bzip2 bzlib cairo cdda cdparanoia cdr cjk cleartype cli consolekit corefonts cpdflib cracklib crypt cups cxx dbus dga dio divx4linux dlloader doc dri dts dv dvb dvd dvdr dvdread emacs emboss encode ethereal evo examples exif fam fbcon ffmpeg firefox flac flash font-server fontconfig foomaticdb fortran freetds ftp gd gdbm gdu ggi gif gimp gphoto2 gpm gps gstreamer gtk handbook iconv icq imagemagick imap imlib innodb ipv6 jack java javascript jikes joystick jpeg jpeg2k kde kerberos ladcca lcms ldap libg++ libnotify live lm_sensors loop-aes mad milter mms mmx mng modules mozilla mp3 mp4 mpeg mplayer msn mudflap mysql mysqli nas ncurses network nls npp nptl nptlonly nsplugin nvidia ogg openal opengl openmp oscar pam pango pcre pda pdf pdflib perl php plotutils png policykit portaudio posix ppds pppd python qt3support qt4 quicktime readline rtc samba scanner sdl semantic-desktop session slp soap sockets sox speex spell spl sql sse ssl startup-notification svg sysfs tcpd theora tidy tiff truetype type1 udev unicode usb v4l vcd videos vorbis webkit win32codecs wmf x264 x86 xcb xface xine xml xorg xpm xprint xulrunner xv xvid xvmc yahoo zlib" ALSA_CARDS="cmipci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic auth_digest authn_anon authn_dbd authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock dbd deflate dir disk_cache env expires ext_filter file_cache filter headers ident imagemap include info log_config logio mem_cache mime mime_magic negotiation proxy proxy_ajp proxy_balancer proxy_connect proxy_http rewrite setenvif so speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan stage tables krita karbon braindump" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="sv en_US" PHP_TARGETS="php5-3" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="nvidia vga vesa fbdev" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account" 

Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PORTDIR_OVERLAY
```

----------

## roarinelk

There's a config option called "Asynchronous SCSI scanning" (CONFIG_SCSI_SCAN_ASYNC).  Disable it and the /dev nodes

should stabilize.

----------

## philip

Unfortunately it is already disabled

```
# cat /usr/src/linux/.config | grep CONFIG_SCSI_SCAN_ASYNC

# CONFIG_SCSI_SCAN_ASYNC is not set
```

----------

## roarinelk

I find your mixture of hda and sda nodes quite interesting. Do you need the old ide drivers for some

exotic piece of hardware?  there are libata drivers for almost all drivers which are in the old

ide subsys.  I suggest you try them.

One thing you could do is use the /dev/disk/by-id/  nodes. Of course this doesn't help with

the root disk, but those names remain constant.

----------

## Hu

 *philip wrote:*   

> 
> 
> ```
> # cat /usr/src/linux/.config | grep CONFIG_SCSI_SCAN_ASYNC
> 
> ...

 This is a UUOC.  Grep can read files on its own.

May I ask why you put ext3 on an SSD instead of ext4?  The improvements in ext4 are likely to give you better performance and possibly lifetime for an SSD.

I have seen a system that has unstable node names even without asynchronous scanning, though it was stable enough that I mostly ignored it.  It seemed to be related to discovering a flash card reader in an unpredictable way.

----------

## philip

I used ext3 just out of old habit

----------

## philip

I reverted to non AHCI mode. The erratic designation of bloc devices continued without any solution. Now the designation of block devices are the same every time again at boot.

----------

## Ant P.

As already mentioned, you are having these problems because you're using obsolete IDE drivers. udev itself hasn't officially supported /dev/hda-style devices for months now, and all you're accomplishing by running your SATA devices in legacy mode is hiding the problem until it surfaces again, possibly worse next time.

----------

## philip

Thanks for the tip.  I guess I just dd my old bootable IDE (with boot , swap and root on it) to a fresh SSD and change the BIOS to boot from the new SSD under the SATA driver.

----------

## Hu

That is wrong in several ways.  First, we never told you to cease using the IDE hardware.  We want you to cease using the old IDE kernel drivers, because the PATA drivers are better maintained and should interact better with the rest of your system.  Second, using dd to transfer any filesystem is inefficient and should be done only when you know you need a perfect copy of the source drive.  Third, using dd to write large amounts of free space to an SSD is inappropriate because that marks those regions as busy in the SSD, when they are not filled with useful data.

----------

## philip

Hmmmm,

If I would like to get rid of my old IDE anyway (e.g. for better speed and larger volume). Which way would you recommend to clone the old IDE partition to a new one?

+ upgrade of kernel as per tip above........

----------

## Hu

Make a new filesystem on the new drive.  Use cp -ar or rsync --archive to copy the data.  The advantage of cp is that it will start quickly, whereas rsync needs to inventory the full hierarchy.  The advantage of rsync is that it can be restarted without redoing old work.

----------

## pigeon768

 *philip wrote:*   

> 
> 
> ```
> EXT3-fs (hda4): using internal journal
> 
> ...

  You're using the ancient, ancient ATA/ATAPI interface. Don't. It's slow and buggy and unmaintained and inefficient and slow. It's also slow. Disable 'Device Drivers' -> 'ATA/ATAPI/MFM/RLL support (DEPRECATED)'. (emphasis on DEPRECATED. Also emphasis on SLOW) Instead, enable 'Device Drivers' -> 'Serial ATA and Parallel ATA drivers' -> 'ATA SFF Support' -> 'ATA BDMA support' -> 'AMD/NVidia PATA support'.

It should fix your issue with unpredictable drive ordering.

----------

## philip

OK,

So I currently have:

```
phils_pc linux # grep -e PATA_AMD -e IDE=y -e ATA= -e ATA_SFF -e ATA_BMDMA -e PATA_AMD .config

CONFIG_HAVE_IDE=y

CONFIG_IDE=y

CONFIG_IDE_GD_ATA=y

CONFIG_ATA=y

CONFIG_ATA_SFF=y

CONFIG_ATA_BMDMA=y

# CONFIG_PATA_AMD is not set

phils_pc linux # 

```

I shall change to:

```
CONFIG_HAVE_IDE=n

CONFIG_IDE=n

CONFIG_IDE_GD_ATA=y

CONFIG_ATA=y

CONFIG_ATA_SFF=y

CONFIG_ATA_BMDMA=y

# CONFIG_PATA_AMD=y
```

Right?

Just a double check: I presume my Ultra DMA 133/100/66 connector will still work (via the AMD/Nvidia PATA support)? My IDE disk, with boot, swap and root is connected to this connector. Otherwise the machine will not boot.

----------

## VoidMage

You shouldn't change .config by hand, unless you really know what's you're doing (and it's quite obvious you don't).

Just use 'make menuconfig' - pigeon768 already wrote were the required options are.

Remember to correct your fstab and kernel command line too.

----------

## philip

Well,

I have reconfigured my kernel many times. And I usuall use make menuconfig and update grub.conf, etc. So no worries.

My last question remains unanswered though.....

----------

## Jaglover

Yes, your IDE drive will show up as sda when set as boot drive in the BIOS.

----------

## VoidMage

 *philip wrote:*   

> Well,
> 
> I have reconfigured my kernel many times. And I usuall use make menuconfig and update grub.conf, etc. So no worries.
> 
> My last question remains unaswered though.....

 

 :Rolling Eyes:  Really ?

Then you should be already aware that toggling a single option in menuconfig much of the time (barring leaves) tends to have side effects.

In this particular case, CONFIG_HAVE_IDE will most likely stay 'y', due to CONFIG_PATA_AMD being set.

----------

## pigeon768

 *philip wrote:*   

> 
> 
> ```
> CONFIG_HAVE_IDE=n
> 
> ...

  Nope - the '# CONFIG_PATA_AMD=y' is commented out, which means it is disabled. Go back into menuconfig/nconfig, enable 'AMD/NVidia PATA support'. Note the difference between that and 'NVIDIA SATA support' which you do not necessarily need to have enabled.

----------

## philip

Thanks for advice from all.   Now I am confident what to enable/disable and what to expect.

----------

