Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have bought a new ssd (240GB). I'd like to copy my system there and start using it. So far I had only one 3TB disk, which is composed of (from gparted):
/dev/sda5 - unknown (977KiB) flags: bios_grub
/dev/sda1 - ntfs (1TiB)
/dev/sda2 - ext4 (1TiB)
/dev/sda3 - ntfs (766.58GiB)
/dev/sda4 - ext4 (27.94GiB, the system)
sdb - unallocated (no fs).
I'd like to copy the sytem to my new hard drive, which is /dev/sdb. I have initialized its new partition table with msdos, so it's ready to use I guess.
I am opened to suggestions as to how many partitions I should create, but I think one for everything (/) is enough, so I want the whole system to be copied to sdb and the rest of the space available there should be part of the new partition (so say, the system is currently using 12 of the 27GB available, and then on the ssd it would be 12 of the 250 available).
hi, thanks for the answer. Could you elaborate on the options please ? I knew dd was to be used (as hinted in the title) but not how to use it. bs is the block size, right? Does it matter if that's not the block size of /dev/sda ? Also, what is notrunc, noerror ? And more importantly, /dev/sda is larger than /dev/sdb. Is that not an issue ?
I knew dd was to be used so what I wanted is not just a copy-pasted answer but rather an answer that corresponds to my issue. I'm not a developer and I don't want to make a mistake, my system/data is at risk.
Oh the new disk is smaller, didn't pick up on that, well then you can't use this
You could just clone the sda4 and sda5 also using dd and in this case clone the partitions.
Create them on the SSD, at same size, then use dd for it: dd if=/dev/sda4 of=/dev/sdb4 bs=4096 conv=notrunc,noerror
So suming up, I have to create a new partition of sdb first, to the exact same size of sda4, and then use dd if=/dev/sda4 of=/dev/sdb1 bs=4096, right ?
What's the bs=4096, is it significant ? What if sdb1 or sda4 is not of size 4066?
And what is sda5, should it be copied too ?
Here a DD guide: http://www.linuxquestions.org/questi...ommand-362506/.
Also take a look at Clonezilla.
Do you have 2 systems installed? Windows and GNU/Linux? My suggestion is to use about 3 partitions(if you want to keep things really simple), if you do have dual boot, so for your GNU/Linux side, / and swap(same size of you RAM for swap, some people might think different on this one thou), still you could use the swap partition on your HDD(if you plan to keep both) also it is a good idea to have your temp directories mounted on tmpfs(or on your HDD), for your Windows just 1 partition.
Here one good reading about partitions: http://linuxmafia.com/~karsten/Linux...partition.html
Normally when I set up partitions I create 4: /boot, /, swap and /home, but that is me, some people like to have some other partitions for other things.
About its size, for /boot 300MB will normally be enough, for / well that depends on how much you plan to install and which distribution is in use, usually goes between 10MB and 50MB for a desktop computers, /home all the space left. Well this on a single hard drive, but it is possible to spread partitions to more than one drive, all just depends on what you want to do.
Yes, that dd resource is great. you should definitely read.
Now as far as your current setup, I didn't really pay attention to that until now. You have two extremely large ext4 partitions, and no swap. The impression I have is that you want to duel boot your systems, /dev/sdb1 would be you linux root. /dev/sda2 will stay where it is.
Is that your home directory?
here is what I would recommend if that is the case. You need a swap, that is going to make this a little tricky. You are also going to have to reconfigure grub.
Open gparted or whatever. Make two partitions
/sdb1 >28GB type technally doesn't matter
/sdb2 4-8GB SWAP(type 82) and that actually just my opinion but should have at least 2GB
start the machine with a boot disk. (you need to have /dev/sda4 unmounted)
double check your partition information to make sure it's the same with the boot disk
assuming it is:
Code:
dd if=/dev/sda4 of=/dev/sdb1 conv=notrunc
every person you talk to will give you a different recommendation about byte sizes. The bottom line is that the slower the read the longer the copy takes but the safer it is. There is also the opinion that it is better for your write to be slower than your read. The default options are pretty slow 512 bytes. Modern machine should be able to handle simultaneous read/writes without a problem.
Next you need to make your swap
Code:
mkswapfs /dev/sdb2
if this command doesn't work you may have to wait til you boot your system.
You are also going to have to modify grub so it knows where to find your kernel and root partition.
I'm hesitant to tell you how to do that because I don't like grub2, which I assume you are using.
So do it the old fashioned way. I know it's pretty easy, I'm sure you can find a tutorial on it.
you will also need to update /etc/fstab with your new partition information.
don't forget to include the swap
If you've managed to do all that you "should" be able to boot into your new system.
I actually have just one partition (/dev/sda4, of size roughly 30GB, of which 15 GB are used) that holds my whole system (/). I don't have extra partitions for /home, /boot or anything else. The 3 other partitions in my disk are just for data, they're not related to the linux system. I don't have a swap partition either, I have more memory than I will ever need (8GB).
So all I want is to copy these 15 GB into my new disk, and start using this new disk as my system. The system should then show that 15 out of 240 GB are used (as opposed to 15 out of 30 GB right now).
From what I understand (please tell me if I'm right), I have to:
1. create a new partition of size 240 GB in this new disk, with the same characteristics (file system type, block size, ...) as sda4 (the partition where my current system resides).
2. Use a live cd to issue the following command: dd if=/dev/sda4 of=/dev/sdb1 conv=notrunc
3. (??) I didn't really understand the grub/fstab part. What am I to do exactly ?
1. yes, you should create a new partition on sdb. it should be the first. Honestly the settings shouldn't really matter. dd overwrites everything in it's path including partition information. The only reason you are actually making sdb1 is so you can tell dd exactly where you want to put it.
Now that I realize you are copying a larger system to a smaller system, after you have made your 30G partition and loaded the system with a boot disk
I would issue your dd command like this.
Code:
dd if=/dev/sda4 of=/dev/sdb1 bs=1M count=16000
The extra entries tell dd to read and write exactly 1024 bytes at a time. Count tells it to repeat this process 16000 times. This way dd is only trying to copy 16GB
Another thing you may want to do after this step is run gparted and make sure /dev/sdb1 is flagged as bootable.
As for grub and fstab.
Grub is installed on your MBR of /dev/sda, but it looks for the configuration files on a hard drive. A hard drive which is about to move. You need to update this otherwise you will get an "operating system not found" message.
Depending on the version of grub you have the instructions are a bit different, but this will need to be updated.
/etc/fstab is a file that tells your system what to mount, where it is and how to do it. Once again, those files are about to move. This will need to be updated.
Ok thanks, but I still don't know how to 'update' grub and fstab. How can I do that ? I think I have grub2, if it matters.
And the systems are not of different sizes, because the system is in a partition of 30 GB, and the new disk has 250GB. So there is plenty of space for the system to be copied to the new disk. The other partitions of the first disk should remain still, they contain data.
hehe. I guess. But I would like to know how this dd works, I might want to do it some other time and it's good to know how it works. Besides, I don't want to have to reconfigure my whole system, reinstall the packages/software, etc. Can you please just tell me how to update grub2 and fstab ?
Unlike old grub, grub 2 requires a configuration script to be run. that will be a problem since you are updating it from a boot disk. Honestly, I'm not sure how to do it. That's why I stick with old grub. As for /etc/fstab, basically just change the entry that has /dev/sda4 to /dev/sdb1.
However, honestly, whatever you have configured it couldn't take that long to restore. you are much better off starting from scratch. and while you're at it, give yourself some swap.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.