LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-26-2006, 01:12 PM   #1
sagar.1986
LQ Newbie
 
Registered: Nov 2006
Posts: 20

Rep: Reputation: 0
Will copying work?


Hi,
I have installed Ubuntu 6.06 on /dev/sda4....IS it possible to copy the files in this partition to /dev/sda1 and boot from it? I dont like to risk the data in /dev/sda4. can anyone help me on this issue?
 
Old 12-26-2006, 02:24 PM   #2
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 113Reputation: 113
Yes.

The steps are

(1) use Tar to move the entire partition across. See Post #23 of [url=http://justlinux.com/forum/showthread.php?threadid=96938&perpage=15&highlight=tar&pagenumber=2]this thread{/url] for its use.

(2) Amend the partition reference in the following

(a) The new partition reference for the Linux's root "/" in /etc/fstab. In your case change /dev/sda4 to /dev/sda1 should be enough.

(b) The new partition reference in /etc/lilo.conf if you use Lilo or /boot/grub/menu.lst if you use Grub. In lilo.conf edit the line with "boot=" and "root=". For Grub's menu.lst edit the "root" statement and the "kernel" statement where the root is defined by "root=/dev/???". Watchout for "root=LABEL" if you have a Red Hat distro. It can still be changed to device names.

(3) Restore the boot loader (see Task B3 & B5 for detailing of how to restore Lilo and Grub into the MBR).

Have to do this sort of thing all the time because many Linux installers wet their pants on seeing 140+ partitions in my 4-disks box. I therefore have to install them in a single disk with a few partitions and then import them back to their final homes.
 
Old 12-26-2006, 02:26 PM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by sagar.1986
Hi,
I have installed Ubuntu 6.06 on /dev/sda4....IS it possible to copy the files in this partition to /dev/sda1 and boot from it? I dont like to risk the data in /dev/sda4. can anyone help me on this issue?
How are you risking the data in sda4?

You can certainly move Linux to a different partition.. You will need to edit some config files so it will still boot, etc.

Please give more details on your setup--what distro, dual-booted, etc. Include the output of fdisk -l (run as root)
 
Old 12-27-2006, 12:31 AM   #4
sagar.1986
LQ Newbie
 
Registered: Nov 2006
Posts: 20

Original Poster
Rep: Reputation: 0
here is the output of fdisk -l:

Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 1 1698 13639153+ 83 Linux
/dev/sda2 1808 8417 53094825 f W95 Ext'd (LBA)
/dev/sda3 1699 1807 875542+ 82 Linux swap / Solaris
/dev/sda4 8418 9729 10538640 83 Linux
/dev/sda5 1913 3824 15358108+ 7 HPFS/NTFS
/dev/sda6 3825 6374 20482843+ 7 HPFS/NTFS
/dev/sda7 8287 8417 1052226 b W95 FAT32
/dev/sda8 1808 1912 843349+ 82 Linux swap / Solaris

I have two linux distros on my laptop, Suse in /dev/sda1 and Ubuntu in /dev/sda4. This is how the partitions are:
/dev/sda1 Suse ext3 13 GB
/dev/sda3 linux-swap 855 MB
/dev/sda2 extended 50 GB
/dev/sda4 ubuntu ext3 10 GB

What i want to do is remove Suse and copy ubuntu to /dev/sda1.That way i will have 15 GB for my ubuntu and it will be in the first sectors of the hard disk. i want to format /dev/sda4 and use it to save some data. My question is: is it possible to copy only files and boot? Since i will delete /dev/sda4 after copying, i will be risking that data if ubuntu doesnot boot...
 
Old 12-27-2006, 03:55 AM   #5
sagar.1986
LQ Newbie
 
Registered: Nov 2006
Posts: 20

Original Poster
Rep: Reputation: 0
Wow it works now! I followed the steps suggested by saikee:-
1) i mounted /dev/sda4 in /media/tmp and /dev/sda1 in /media/Suse.
>cd /media/Suse
>rm ./* -rf
>cd /media/tmp
>tar cf - .|(cd /media/Suse;tar xvf -)
It took a long time to copy those files.

2)i changed the entry in /etc/fstab

3) i changed all instances of (hd0,3) in menu.lst to (hd0,0). Wat is the necessity to restore the boot loader?

And by the way some logical partitions in extended partition (e.g /dev/sda5 ) show in fdisk -l as HPFS/NTFS eventhough they are ext3(Gparted shows /dev/sda5 as ext3). Why this difference?
 
Old 12-27-2006, 06:27 AM   #6
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 113Reputation: 113
sagar.1986,

The information in fdisk -l is known to be reliable.

Never mind what it says did you use tehm as NTFS partitions? If you do then I would worry.

The Partition ID is just a number in the partition to "help" an OS to identify if the partition is foreign and to select the right mechanism to read it. It can be unformatted inside. You only need to worry about the content after you have written stuff inside. In such a case you better remember the filing type.

You can change the partition ID by cfdisk program. Anything you do with the partition table does not alter the conent of the partition until you start writing onto it.

------------------------
On the necessity of restoring the boot loader

Although the Linux has been transfer but the boot loader would still try to pass the control to the vacant partition becuase that was the address stated in the MBR.

By restoring the boot loader you "alter" the address of the Linux to be booted in the MBR. Remember you had to do the "grub-install" inside the new partition (or address) and that is how the connection to the MBR was made.

Pretty logical I would say. If you move house you would go to the Post Office to ask them to re-direct the mails, would you not?

Last edited by saikee; 12-27-2006 at 06:35 AM.
 
Old 12-27-2006, 11:32 PM   #7
sagar.1986
LQ Newbie
 
Registered: Nov 2006
Posts: 20

Original Poster
Rep: Reputation: 0
got it. Thanks.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
copying to CD Murdock1979 Linux - Software 4 04-16-2006 04:03 PM
copying old HD to new? greenmeanie Debian 2 05-24-2005 12:44 PM
cd copying Pedroski Fedora 10 10-16-2004 01:15 AM
copying CD to HD theserge Linux - Software 5 11-30-2003 04:54 PM
copying a CD to a directory MrGardenHoseMan Linux - General 2 07-03-2003 06:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration