Tuesday, January 20, 2015

Replace Buffalo linkstation ( LS VL ) HDD with a SSD

Replacing a 1 TB HDD with a low capacity SSD in a NAS may not makes sense. Because almost all the time NAS is used as a storage device.  I mainly use the device as a torrent downloader so I think I can still live with a NAS which has a low capacity SSD for a while.

Anyway I always wanted to try replacing the original HDD with a new one and experiment. So I decided to replace the original HDD with a SSD as an experiment.

There are pros and cons using a SSD in a NAS. It is obvious that the disk capacity is the major disadvantage. Anyway so far the best things I noticed are the low heat dissemination and low noise.

Here is my experience on replacing the disk in my linkstation.

I did some Google search on how to replace the original HDD and found out that it can be done in several ways.

One method is clone the first partition of the original HDD to the new HDD and then rebuild the partition structure using the LSUpdater.exe. You need a PC to run the LSUpdater.exe.

Another method is create all the partitions manually and clone only the first partition. You don't need LSUpdater.exe for this method.

I tried both the methods and only the latter worked for me.

There are a couple of ways to create partitions and prepare the first partition of the SSD.
One is plug both drives in to a PC or a Linux host and do the partitioning. Another method is use a USB HDD enclosure to connect the SSD to the linkstation via the USB port and do the partitioning and cloning using the linkstation itself. I have a USB HDD enclosure, so I used the latter.

This wiki entry has clear instructions on creating custom partitions. However it does not show you how to create the first partition.
http://buffalo.nas-central.org/wiki/Custom_Partitions_on_the_LS_Pro#HowTo_setup_the_internal_HDD

Let's start. Connect the SSD which is now in the USB HDD enclosure to the USB port of the linkstation. Log in to the linkstation.

The new disk will be appeared as /dev/sdb

root@LS-VL406:~# cat /proc/partitions 
major minor  #blocks  name

  31        0        512 mtdblock0
   8        0  976762584 sda
   8        1    1000448 sda1
   8        2    5000192 sda2
   8        3       1024 sda3
   8        4       1024 sda4
   8        5    1000448 sda5
   8        6  961750000 sda6
   8       16  117220823 sdb

Let's start partitioning from the scratch. Detailed information of usage of these partitions are described in the wiki page mentioned above.

Be careful when you create the partitions. Specially if you use a Linux host, check the terminal which you use to enter fdisk commands. Sometimes the linkstation disconnects SSH connections so that you will be automatically put in to the host's terminal. If you didn't notice that you may end up with partitioning HDD of your host.

root@LS-VL406:~# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that the previous content
won't be recoverable.


The number of cylinders for this disk is set to 14593.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x00,0x00 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-14593, default 1): <Press Enter> 
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-14593, default 14593): +1024M 

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (126-14593, default 126): <Press Enter>
Using default value 126
Last cylinder or +size or +sizeM or +sizeK (126-14593, default 14593): +3000M

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e
Partition number (1-4): 4
First cylinder (492-14593, default 492): <Press Enter>
Using default value 492
Last cylinder or +size or +sizeM or +sizeK (492-14593, default 14593): <Press Enter>
Using default value 14593

Command (m for help): p

Disk /dev/sdb: 120.0 GB, 120034123264 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sdb1               1         125     1004031  83 Linux
/dev/sdb2             126         491     2939895  83 Linux
/dev/sdb4             492       14593   113274315   5 Extended

Command (m for help): t
Partition number (1-5): 4
Hex code (type L to list codes): L

 0 Empty                  1b Hidden Win95 FAT32     9f BSD/OS                
 1 FAT12                  1c Hidden W95 FAT32 (LBA) a0 Thinkpad hibernation  
 4 FAT16 <32M             1e Hidden W95 FAT16 (LBA) a5 FreeBSD               
 5 Extended               3c Part.Magic recovery    a6 OpenBSD               
 6 FAT16                  41 PPC PReP Boot          a8 Darwin UFS            
 7 HPFS/NTFS              42 SFS                    a9 NetBSD                
 a OS/2 Boot Manager      63 GNU HURD or SysV       ab Darwin boot           
 b Win95 FAT32            80 Old Minix              b7 BSDI fs               
 c Win95 FAT32 (LBA)      81 Minix / old Linux      b8 BSDI swap             
 e Win95 FAT16 (LBA)      82 Linux swap             be Solaris boot          
 f Win95 Ext'd (LBA)      83 Linux                  eb BeOS fs               
11 Hidden FAT12           84 OS/2 hidden C: drive   ee EFI GPT               
12 Compaq diagnostics     85 Linux extended         ef EFI (FAT-12/16/32)    
14 Hidden FAT16 <32M      86 NTFS volume set        f0 Linux/PA-RISC boot    
16 Hidden FAT16           87 NTFS volume set        f2 DOS secondary         
17 Hidden HPFS/NTFS       8e Linux LVM              fd Linux raid autodetect 
Hex code (type L to list codes): f
Changed system type of partition 4 to f (Win95 Ext'd (LBA))

Command (m for help): p

Disk /dev/sdb: 120.0 GB, 120034123264 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sdb1               1         125     1004031  83 Linux
/dev/sdb2             126         491     2939895  83 Linux
/dev/sdb4             492       14593   113274315   f Win95 Ext'd (LBA)

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (492-14593, default 492): <Press Enter>
Using default value 492
Last cylinder or +size or +sizeM or +sizeK (492-14593, default 14593): +300M

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (529-14593, default 529): <Press Enter> 
Using default value 529
Last cylinder or +size or +sizeM or +sizeK (529-14593, default 14593): <Press Enter> 
Using default value 14593

Command (m for help): p

Disk /dev/sdb: 120.0 GB, 120034123264 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sdb1               1         125     1004031  83 Linux
/dev/sdb2             126         491     2939895  83 Linux
/dev/sdb4             492       14593   113274315   f Win95 Ext'd (LBA)
/dev/sdb5             492         528      297171  83 Linux
/dev/sdb6             529       14593   112977081  83 Linux

Command (m for help): t
Partition number (1-6): 5
Hex code (type L to list codes): L

 0 Empty                  1b Hidden Win95 FAT32     9f BSD/OS                
 1 FAT12                  1c Hidden W95 FAT32 (LBA) a0 Thinkpad hibernation  
 4 FAT16 <32M             1e Hidden W95 FAT16 (LBA) a5 FreeBSD               
 5 Extended               3c Part.Magic recovery    a6 OpenBSD               
 6 FAT16                  41 PPC PReP Boot          a8 Darwin UFS            
 7 HPFS/NTFS              42 SFS                    a9 NetBSD                
 a OS/2 Boot Manager      63 GNU HURD or SysV       ab Darwin boot           
 b Win95 FAT32            80 Old Minix              b7 BSDI fs               
 c Win95 FAT32 (LBA)      81 Minix / old Linux      b8 BSDI swap             
 e Win95 FAT16 (LBA)      82 Linux swap             be Solaris boot          
 f Win95 Ext'd (LBA)      83 Linux                  eb BeOS fs               
11 Hidden FAT12           84 OS/2 hidden C: drive   ee EFI GPT               
12 Compaq diagnostics     85 Linux extended         ef EFI (FAT-12/16/32)    
14 Hidden FAT16 <32M      86 NTFS volume set        f0 Linux/PA-RISC boot    
16 Hidden FAT16           87 NTFS volume set        f2 DOS secondary         
17 Hidden HPFS/NTFS       8e Linux LVM              fd Linux raid autodetect 
Hex code (type L to list codes): 82
Changed system type of partition 5 to 82 (Linux swap)

Command (m for help): p

Disk /dev/sdb: 120.0 GB, 120034123264 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sdb1               1         125     1004031  83 Linux
/dev/sdb2             126         491     2939895  83 Linux
/dev/sdb4             492       14593   113274315   f Win95 Ext'd (LBA)
/dev/sdb5             492         528      297171  82 Linux swap
/dev/sdb6             529       14593   112977081  83 Linux

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

Calling ioctl() to re-read partition table
root@LS-VL406:~# 

After few seconds, the linkstation disconnect SSH sessions. Log in to the linkstation again and check the partition structure.

root@LS-VL406:~# partprobe /dev/sdb
root@LS-VL406:~# cat /proc/partitions 
major minor  #blocks  name

  31        0        512 mtdblock0
   8        0  976762584 sda
   8        1    1000448 sda1
   8        2    5000192 sda2
   8        3       1024 sda3
   8        4       1024 sda4
   8        5    1000448 sda5
   8        6  961750000 sda6
   8       16  117220823 sdb
   8       17    1004031 sdb1
   8       18    2939895 sdb2
   8       20          1 sdb4
   8       21     297171 sdb5
   8       22  112977081 sdb6

Now create xfs file system on the data partition. (i.e. /dev/sdb6)

root@LS-VL406:~# mkfs.xfs /dev/sdb6
meta-data=/dev/sdb6              isize=256    agcount=4, agsize=7061068 blks
         =                       sectsz=512   attr=2, projid32bit=0
data     =                       bsize=4096   blocks=28244270, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0
log      =internal log           bsize=4096   blocks=13791, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0


Then clone the /dev/sda1 to /dev/sdb1

root@LS-VL406:~# dd if=/dev/sda1 of=/dev/sdb1
2000896+0 records in
2000896+0 records out
root@LS-VL406:~# sync
root@LS-VL406:~# 

Now switch off the linkstation and unplug the USB device. Remove the original HDD and plug the SSD to the linkstation directly. Then start your linkstation. Now it should be up and running with the SSD without any issue.

We are almost done. There is one thing we need to address. The linkstation needs it's "share" directory in the data partition and we haven't created it yet. We could have created it when we made the xfs file system. However the best way to create it is using the web interface so that it will be created with proper permissions.

So log into the linkstation using the web interface and remove the share directory shown in there and create it again with same permissions. That's it. You have the linkstation up and running with the SSD.