Transfering /home and swap from SSD to Hard Drive

Hi there,
complete noob here. I’ve searched the forum, looked at the faq’s etc but can’t find my exact ‘problem’.

A while back I installed opensuse 12.1 on this pc which had only a 120gig SSD installed. Worked fine but as it wasn’t my main machine (Win7),
I didn’t have much time to ‘play’ with it.

Last week main machine went ‘ladies chest’ up :slight_smile: and took out my hard drive. To cut a long story short, decided to try and stick with
Linux rather than pay for Microsoft executives yachts all the time. So upgraded to Opensuse 12.3, installed wine and virtualbox and managed to
install a copy of Win7 (just for 1 prog) in Virtualbox (still not right but I’ll sort that later).

This morning just took delivery of and installed a 2 Terabyte hard drive (on this machine)… now what???

By reading some simmilar posts, I assume I’ll want to transfer my /home directory and swap file to the new spinny whirly thing
but how? and is there anything else I need to do??

Thanks in advance for any advice given.

Steve

So is it your intent to keep both hard drives? I can say that using a 120 GB SSD for root / and use the large hard drive for /home would be my suggestion. If you want to switch entirely to the new hard drive, but can for a short while have both, consider you could reinstall openSUSE, including root / , SWAP and /home on the new hard drive, perhaps with the SSD gone, then reattach the SSD and copy any files you want from your old /home to your new. You can use the dd command, to copy a drive, but it must remain the same size for that to work. You can use a by-file copy command, from old /home to new, but that is best done running a Live USB of DVD to fire up a copy of openSUSE so as to not have any of your old drive partitions being used during the copy. Lastly, I use a 120 GB SSD for my root /, which works like a champ and keep /home on a standard hard drive and it works very well. To make a Live USB bootable drive, take a look here:

S.C.L.U. - SuSE Create Live USB - openSUSE Forums

Thank You,

Before doing anything you might like to install the windows app with wine. It will work with many windows applications these days. Q4Wine is worth installing as well and gives more install options such as start up screen size. Once these have been installed simply click on the windows installer for the package. Associations on their data files will work directly from linux as well. I often use an optical design package that is purely windows as there aren’t any realistic alternatives.

You can change your disc usage with the YAST - system - partitioner but many people think gparted is easier to use. Both are similar in what they actually do so some pointers may help. Gparted can be installed from YAST last time I looked.

Linux splits discs in an sda, sdb etc fashion and then partitions on a disc as sda1,sda2 etc. If you fire up yast partitioner you will get the idea. Click on hard disks at the left and then each of the discs. These partitions are mapped to directories. Mine for instance shows sda1 as /boot/efi and sda2 as /. The last one is everything from the root directory unless the directory is specified elsewhere. These are called mount points

If I then click on sdb this shows sdb1 mounted as swap, sdb2 mounted as /var, sdb3 mounted as /tmp and the remaining space on the disc sdb3 mounted as /home/home2. In your case you would just want it mounted as /home. I have my /home on yet another disc so I have just put the spare space somewhere convenient.

My boot and / directories are on ssd so I have put the other partitions on a hard drive to minimise writing to ssd. /tmp for instance can be used when pdf’s etc are downloaded from the web. /var has log files in it so neither have any real effect on performance. Many writes are small so are taken up by the buffers in the disc.

One thing to realise about these utilities is that they are told everything they have to do before it’s actually done. So for instance deleting a partition doesn’t do anything until the last final button is pressed. Neither does telling it to format a partition but clearly if the data on a partition needs to be kept it mustn’t be formatted where the data is. Also before a partition can be grown another partition has to be deleted if the disc is already fully utilised. However if some one wanted to increase the storage on home for instance I believe more than one disc can be mounted too it. So to increase the storage space create the new partition and format it and set the mount point as /home. rotfl! Hope some one will clarify that this is correct… Multiple discs across one directory isn’t as fashionable as it was some years ago. In fact default installs did this at one time if the discs were there. It was seen as an advantage over windows. It is actually as the apparent size of the user space can be increased without having to worry about a new drive letter being added.

This leaves you a problem. You will already have a /tmp, /var and /home on the ssd. I’ve done most of the work explaining how partitioning works so over to some one else on this aspect.

Personally given that I had just installed and wasn’t likely to loose anything I would do a fresh install. Import existing partitions, select custom partitioning, delete the lot and then set them up from scratch as I have outlined. Or of course ask about the 2 points I have mentioned that I am not sure about. I would be interested in the answers as well.

John

Yes, that’s the idea.

You lost me a bit with the part about a bootable usb stick. Is this something that I <have> to do or just would make things easier if I did it?

Thanks,

Steve

I’m a little unclear on if you just want to copy the old drive to the new and then go from there.

If so its very easy. Boot to a live CD / USB and simply use dd or dd_rescue. Its fine if the target drive is larger, no worry - you will just have unpartioned space at the end of the drive. You can install another OS to it, or simply expand your existing partitions to use it, etc. (Expanding partitions can be done using gparted from a live CD.)

Or - you can use Clonezilla - About boot cd, which has the option to not only clone the old drive to the new, but can extend the partition table and file system for you. (Or not, your choice) Clonezilla is menu driven and pretty easy to use.

If you provide the output of fdisk -l it might also help ensure there are no issue which might arise.

Edit: Oh, I see you want to use the SSD for /root now, sorry I missed that. It that case yes, you might still use clonezille to copy /home to the new drive. Yet another option is to copy the whole drive with clonezilla and use bcache http://bcache.evilpiepirate.org/ which will use the SSD as a drive cache. This would be more advanced, as bcache is pretty new and requires manual configuration. In the end though, it might be the best route.

The windows app is Picaxe Program Editor and according to users on the Picaxe forums is a bit of a swine to get working with Wine hence the Windows in a virtual box. There is a cross platform alternative editor but no where near as feature rich (have yet to try it). That’s all for a later time though.

I did say I was a complete noob. I’ve got this hard drive phisicaly installed in my machine but still don’t know what to do with it. I don’t even know what type of file system to put on it. I read your thing about partitions and I think I got the gist of it but I’ll have to read it over a few times before it sinks in (the perils of old age).

Going by your reply, I just need /root (and it’s contents or sub folders) on the SSD and all the rest on the hard drive? correct? Will it really be so much easier to start again (I’d like to avoid that if possible, unless I have to)?

Optical design package… must be into astronomy then?

Cheers,

Steve

linux-ypc6:~ # fdisk -l


Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders, total 234441648 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: 0x00042e96


   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048     4208639     2103296   82  Linux swap / Solaris
/dev/sda2   *     4208640    46153727    20972544   83  Linux
/dev/sda3        46153728   234440703    94143488   83  Linux


Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Does that tell you anything ?

If I understand you correctly, I could use clonezilla to clone the whole SSD and then resize the partition. Could I then put /root back on the SSD or will that cause problems. Not too sure about bcache though. Perhaps if/when I get a little more experience.

Cheers

Steve

Let me say that it is much more trouble free to just reinstall openSUSE. Expanding partitions can be done, but has all sorts of possible issues. When you get down to it, a copy of your most import files to safe place and then starting over is the best bet. To use the SSD as boot, make it sda. During the install, point /home and SWAP to your larger hard drive and expand root for all of the SSD.

The Live USB blog lets you create a backup bootable openSUSE copy on a USB thumb drive. Read the article and you will see its a great way to have a backup plan during such an installation change.

Thank You,

Hi guys, rightly or wrongly I used clonezilla and have got as far as

linux-ypc6:~ # fdisk -l


Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders, total 234441648 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: 0x00042e96


   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048     4208639     2103296   82  Linux swap / Solaris
/dev/sda2   *     4208640    46153727    20972544   83  Linux
/dev/sda3        46153728   234440703    94143488   83  Linux


Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00042e96


   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     4208639     2103296   82  Linux swap / Solaris
/dev/sdb2   *     4208640    46153727    20972544   83  Linux
/dev/sdb3        46153728  3907029167  1930437720   83  Linux

My rationale being “I might as well have a go if I might have to reinstall anyway”. Even managed to resize the partition. What now though? Surely I must have to tell Suse to use the new home directory and swap file while still using the /root on the SSD ?

rotfl! Yes astronomy and paper telescopes that I may not be able to make or afford in some cases…

Yes I expected that you would have to read it a couple of times. The important part is to understand mount points. These can be the root system or any directory on the disc. It’s important to note that as far as I am aware ordinary users can’t do anything in the root directory of a disc. That’s where the term root as a user comes from.

Your best bet at the moment for more help is to go to /etc and find the file called fstab, copy it and paste it on here. This is mine


**/dev/disk/by-id/ata-PLEXTOR_PX-128M5Pro_P02306101219-part2    /    ext4    acl,user_xattr 1 1** 
**/dev/disk/by-id/ata-VB0250EAVER_Z3TCNPGW-part1    swap    swap    defaults 0 0 
/dev/disk/by-id/ata-PLEXTOR_PX-128M5Pro_P02306101219-part1    /boot/efi    vfat    umask=0002,utf8=true 0 0 
**/dev/md0    /home    ext4    acl,user_xattr 1 2 
**/dev/disk/by-id/ata-VB0250EAVER_Z3TCNPGW-part4    /home/home2    ext4    acl,user_xattr 1 2 
/dev/disk/by-id/ata-VB0250EAVER_Z3TCNPGW-part3    /tmp    ext4    acl,user_xattr 1 2 
/dev/disk/by-id/ata-VB0250EAVER_Z3TCNPGW-part2    /var    ext4    acl,user_xattr 1 2 
**proc    /proc    proc    defaults 0 0 
sysfs    /sys    sysfs    noauto 0 0 
debugfs    /sys/kernel/debug    debugfs    noauto 0 0 
usbfs    /proc/bus/usb    usbfs    noauto 0 0 
devpts    /dev/pts    devpts    mode=0620,gid=5 0 0 

From that you can see which partitions numbered 1 to 4 on the gobble de guke disk id of VB0250EAVER etc are mounted as. Starting with / then boot, both on ssd and then the others on a disc. The dev/dmo is due to me using a raid array from my home directory. Some of the rest will be down to things I have installed. I have highlighted the parts that set the mount points. When you change your partitioning the software will generate the syntax that is needed.

I have also looked at gparted. Assuming you are new to this. Click on the yast icon, green thing with an animal on it. Select software management and enter gparted in the search field. Click the check box next to it and then next, it will mention what else it will do so next again. You now have gparted installed. While in yast go to the system section and select partitioning. Say yes to the warning message and then have a click on the items in the left pane, disks being the main one. This will show you how your disc is currently set up and the mount points it shows will tie in with your fstab. Do what ever you like in this but always exit with abort. You can even see what edit offers and then simply back out of it. Keep hitting next though and at some point it will show you what changes it’s going to make and the next next will do it. You will see that at a yast level entering things which will finish up in fstab is relatively easy.

I would suggest - maybe - using gparted for making changes as it does offer move and resize and others use it but yast will do it as well. This area is where your new disc will be formatted as well. Personally I would use YAST. If it doesn’t work out then a re install will be needed.

John

jdmcdaniel3’s suggestion of simply saving your /home data and doing a reinstall is a good way to go. It should be relatively simple, and get you want you want.

You could re-partition the 2TB drive with one large partition for /home and a small swap partition and simply copy the contents from your current /home to the new larger /home partition. Of course, you have effectively done this by cloning the drive - you have a large home and swap already on the 2TB drive. You could use it the way it is now - just make sure your data was correctly copied to it.

Then, re-install Suse electing to you the SSD as your root volume, and the 2TB drive as /home and the swap partition you already have on sdb. Make certain you choose in the installer to not format the home partition! That’s really pretty much it. Your new install would boot from the SSD, using /home and swap on the 2TB drive.

I’m sorry if I distracted the issue by mentioning clonezilla. While it can do full drive, or partition only, copies and expand the file system for you like it did - in your case this is likely not going to help much given what your trying to achieve. Just reinstalling should be the easiest path.

Note: When you install and re-create the user(s), it will use the home dirs on the new 2TB /home. If for some reason you run into any permission error, or can’t log in, etc. at that point just post the details. If you only have one user created on the system it’s uid and gid will be the default, and simply recreating a user of the same name should just work.

There is also this option:
Simply change your /etc/fstab to use the /home on sdb rather than sda
Then disable swap from using sda1 and use the swap partition on sdb1

While that would work, it leaves things in a sort of messy way, and you effectively never use the space on the SSD allocated to swap or home. Thus reinstalling and making all of the sda into the root filesystem would be a better use of its capacity, and make for a cleaner environment.

(As an aside: bcache was recently introduced into the Linux kernel. It allows one to use an SSD to improve drive performance Unfortunately, setup is pretty advanced. In the near future, I expect most Linux distributions installers will be able to take advantage of this and offer the ability to use an SSD this way.)

/dev/disk/by-id/ata-Corsair_Force_3_SSD_12126503000008951623-part1 swap                 swap       defaults               0 0
/dev/disk/by-id/ata-Corsair_Force_3_SSD_12126503000008951623-part2 /                        ext4        acl,user_xattr       1 1
/dev/disk/by-id/ata-Corsair_Force_3_SSD_12126503000008951623-part3 /home                ext4        acl,user_xattr       1 2
proc                    /proc                      proc         defaults                    0 0
sysfs                  /sys                       sysfs        noauto                     0 0
debugfs              /sys/kernel/debug    debugfs    noauto                      0 0
usbfs                  /proc/bus/usb          usbfs       noauto                      0 0
devpts                /dev/pts                  devpts     mode=0620,gid=5       0 0



Tried to tidy it up a little.

I’ll install gparted as you suggest and have a look with both it and yast (tomorrow now though).

OT bit… paper telescopes… I once saw an episode of mythbusters where they made a functioning canon with nothing more than duct tape,
chambered for a 2 inch ball if I’m not mistaken, and it worked! Just thinking outside the box :slight_smile:

Thanks for the help so far,

Steve

I don’t think some of that will work out at all Lews. 2 point. Fstab sets where things are mounted, What I vaguely remember being called udev is now used and altering fstab isn’t as simple as it was. Also 2 /home’s may not work out.

Making the changes should be simple but must all be done at the same time. Firstly install the new disc. Identify it in partitioning and create a swap partition and a /home2 partition formatted ext4 for users. That will eventually become home. Personally before creating the home partition I would also create one for /tmp and /var. The partitioner may object to creating the swap partition as there is already one on the ssd so that may have to be changed 1st. That one is fairly simple. Assuming it has a boot partition, a / partition and a swap partition delete the swap and enlarge the / partition to fill the remaining space. Depending on where the other 2 are this may mean moving things about as well. As the partitioner may not work out the numbers remember the size of the swap partition that was deleted.

Then copy everything from the current home to home2 as a user to retain the current access rights. Use the partitioner again to set /home2 to /home. Some of the files are just set to user rather than a specific user. It varies. I suspect that there will be a console copy command that retains the existing user rights. Don’t know what it is but some one else should.

What isn’t clear then is the aspect I questioned earlier - what happens to the space on the ssd that was previously /home. If no one is sure it might be best to wait for some one who is sure. Maybe a trim command will allow it to be used.

As to not making use of all of the ssd that isn’t straight forwards either. Best docs I have seen were by red hat. It suggests that the space will get used as things are changed and it’s best to trim when the ssd is near full of used and unused.:\ What they don’t mention is just how one finds out that a trim is needed. Write speeds when an erase is needed are very slow. Effectively about 9mB/sec on a test I did. This test utility gets at true write speeds by writing a large file, erasing it and writing it again so in practice depending on what the ssd does with that the true write speed may only be 9/mB/sec in “normal” use… A hard drive is considerably quicker than that.

Really unless some one really does know what happens to old home the best option is a fresh install. Import current partitioning - edit it to what is wanted ie delete swap and create the new one and the other partitions on the hard drive.

John

You can still just edit fstab to point to the new home and swap partition on the new drive. Also can be done in Yast -Boot. You simply copy all inside old home to the new (Note do not copy the home name just file/folder in the home) to the new home. GO to yast make the changes or hand edit /etc/fstab. Re boot. You can then use the old home for anything else you might need.

Yep, exactly - just change which /home to mount in fstab will work. And (unless he’s re-partitioned the new 2TB drive since) he’s already cloned /home to it, and it’s been expanded in size.

I had a little play with Yast partitioner (don’t forget, if it doesn’t work, I’m doing a clean install anyway). I’m treating this as more of a learning exercise now.

Output of fstab

/dev/disk/by-id/ata-Corsair_Force_3_SSD_12126503000008951623-part2 /                    ext4       acl,user_xattr        1 1
proc                 /proc                proc       defaults              0 0
sysfs                /sys                 sysfs      noauto                0 0
debugfs              /sys/kernel/debug    debugfs    noauto                0 0
usbfs                /proc/bus/usb        usbfs      noauto                0 0
devpts               /dev/pts             devpts     mode=0620,gid=5       0 0
/dev/disk/by-id/ata-ST2000DM001-1CH164_Z1E3PYGJ-part1 swap                 swap       defaults              0 0
/dev/disk/by-id/ata-ST2000DM001-1CH164_Z1E3PYGJ-part3 /home                ext4       defaults              1 2



I’m assuming I managed to point the /home and swap to the new hard drive.

Question: Can I just delete the partitions I don’t need such as /root on the new hard drive and /home and swap on the SSD? Would I then be able to expand the /root on the SSD to take up the remaining space?

fdisk -l


Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders, total 234441648 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: 0x00042e96


   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048     4208639     2103296   82  Linux swap / Solaris
/dev/sda2   *     4208640    46153727    20972544   83  Linux
/dev/sda3        46153728   234440703    94143488   83  Linux


Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00042e96


   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     4208639     2103296   82  Linux swap / Solaris
/dev/sdb2   *     4208640    46153727    20972544   83  Linux
/dev/sdb3        46153728  3907029167  1930437720   83  Linux

You guys are great BTW. Thanks for all the help - learning a lot.

A second question springs to mind. On Johns listing of fstab it shows /var and /tmp partitions, how come I don’t have them or are they added manually?

On 2013-08-03 12:56, stevetommo101 wrote:
> This morning just took delivery of and installed a 2 Terabyte hard
> drive (on this machine)… now what???
>
>
> By reading some simmilar posts, I assume I’ll want to transfer my /home
> directory and swap file to the new spinny whirly thing
> but how? and is there anything else I need to do??

“Hard Disk Upgrade Mini How-To” at tldp.org. Just google the phrase.


Cheers / Saludos,

Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)

On 2013-08-04 10:56, stevetommo101 wrote:

> Question: Can I just delete the partitions I don’t need such as /root
> on the new hard drive and /home and swap on the SSD? Would I then be
> able to expand the /root on the SSD to take up the remaining space?

Yes. But do that only once you are sure you are booting correctly and
using the partitions you want.

On 2013-08-04 11:06, stevetommo101 wrote:>
> A second question springs to mind. On Johns listing of fstab it shows
> /var and /tmp partitions, how come I don’t have them or are they added
> manually?

Because you do not need them, only some people do.


Cheers / Saludos,

Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)

Steve’s fstab leaves me at a bit of a loss. I haven’t used a default install for a long time. I vaguely recollect seeing some mention of a change to boot but as I always use more than one disc I put things where I want and add a small fat32 boot partition. It looks like a default install doesn’t create a boot partition any more. :sarcastic: Must admit I have always wondered why it did other than maybe dual booting.

On the face of it swap and home need deleting on the ssd after the data has been saved, / moved and then expanding plus the work on the hard drive. BUT what happens at boot? Have to assume YAST will look after that as well. Alternatively swap could be deleted, a small boot partition created etc but there is still some doubt about the results. I suspect that will be the one most likely to work but have to assume the actual init file that runs is still the same as it was. SOMEONE should be able to comment on that. If that has changed I would just assume that YAST will look after it and forget the boot partition.

Looking at an install keeping user data there shouldn’t be any problem doing that as I suggested. Use YAST to format and create the new partitions on the hard drive using temporary names for the mount points. Then copy the current home content to what will be the new one. Assuming you mount the new home as /home2 copy the files across using cp -r -p /home /home2 as root in the consol. I don’t think there is a need for a -d option to preserve links. For info on this command type man cp in the console and select man 1. You can exit that by typing q.

Preparing the new disc with temporary mount points and copying data across is also your best option before deleting partitions etc on the ssd. Reboot and if things go awol you will have to re install. When you get to partitioning in that select import and rename the mount points as required. There is an option not to format a particular partition so that the data will be retained. When formatting is needed use ext4. Swap is just swap. /boot is fat32. So you might prepare the new disc like this

/swap2 10gb
/tmp2 10gb
/var2 10gb
/home2 - what ever is left.

When installing onto / on the ssd I assume that there is no need to have a boot partition as I have. As to space used I have most of my applications loaded and use about 13gb of it. Makes me wonder why I bought a 120gb one but as things change it seems that the space will be used up without erases which should extend it’s life. Ihave used 30gb discs for system files in the past and never filled one up. Swap used to go to another as did home. There is no reason why some one shouldn’t have another partition on the ssd and mount it where ever they like even /home/steve/Desktop/SSD or what ever. You could use the partition for virtualbox or wine installs but personally I would try and make windoze apps write to a disk as well. That may be difficult to do with virtualbox.

A few hundred mb of space is adequate for the boot partition if it is used. I have ended up with 195mb. if I remember correctly I asked for a larger number than that. It seems that using a boot partition can offer some extra features but I have never made any use of them.

My comments on udev came about because of comments from elsewhere relating to how it works - mainly concerning adding a new disk. As that has to be formatted may as well let yast do the work.

John