Linux - GeneralThis 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
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.
Hi. This is what I want to conceptually accomplish. I have two identical servers - one called production, the other called test.
(1) I want to try apt-get update and other software patching and configuration changes on test, to make sure it works correctly.
(2) I then want to "ghost" the partition with all the files and config changes into some kind of image file of some sort
(3) I then want to be able to transfer this using a script from the production box using ftp? Maybe a cron job that checks and downloads any new tested update?
(4) ONce on the prouction box, this image file will need to be written onto an awaiting "empty" partition, then grub or lilo changes written so that the box reboots using the "new" version of the system.
(5) Final wish list idea - the programs running on the server (a CMS website) all write/read the databases and files on a /data partition, and this does not get overwritten. In effect, the system files and applications get updated with patches and stuff, but the data stays the same.
I appreciate any ideas on how to do this effectively
Sorry, I am not trying to break any rules. I am not sure how difficult my question really is. I started playing with dd command, but now I am all confused about if I am picking up the MBR along with the partition I am trying to copy, and if so, does it mess up my booting?
I use a program called Mondo to do this. It's a open source software that clones your system, ostensibly for backup purposes. It's really quite easy if you follow the steps in the how to. Of course you will need access to a CD burner, network drive, or Zip drive or something.
Originally posted by onmountain ...I started playing with dd command, but now I am all confused about if I am picking up the MBR along with the partition I am trying to copy, and if so, does it mess up my booting?
onmountain: If you are using dd as is shown in the following example and the destination drive (hdb) is at least as large as the source drive (hda), then you are copying everything, including the MBR.
dd if=/dev/hda of=/dev/hdb bs=64M
The hdb drive in this example will be a clone of the hda drive. You could remove hdb and substitute it for hda and the system would boot as before.
Please note that no partitions from either drive should be mounted during the transfer.
The dd command is an excellent tool to mirror an identical image including the boot loader. However it is only good if
(1) Both the target and source partitions are identical in size.
(2) To a lesser extent the partition number of both source and target should be ideally indentical too. i.e. from a hda6 to a sdb6.
Different partition numbers can be overcome by altering the partition number in the boot loader and /etc/fstab.
If the source and target partitions are diffierent in size the tar command is the best and produces a 100% copy. Assuming the source is /mnt/hda6 and the target is sdb6, just cd to /mnt/hda6 and type
tar cf - . | (cd /mnt/sdb6; tar xf -)
WhatsHisName suggested whole disk copy, with bs=64M, is also a sure fire method if both disks are identical in size. Haven't tried to use a larger target disk yet myself.
Would the tar command only copy the files that exist, verses the dd command copying the entire partition? If so, I would assume then that the tar would produce a smaller file size? I noticed that the dd command creates a 3GB file if the source partition is 3GB, even if the partition contained only a 2kB text file. The tar output would be potentially a better candidate if I wanted to eventually ftp this stuff around between machines? Or can I compress and decompress the output of dd?
dd copies the native information, in 1s and 0s, and therefore the entire partition is mirrored faithfully. Thus Linux can't write on a NTFS partition it can still dd a XP NTFS partition and has it bootable. There is no compression used in the dd command and the empty spaces are mirrored same as the stored data, but possibly faster.
Tar command retains the full structure of the filing systems (permissions, ownership etc) but doesn't copy the boot sector. The user has to replicate the boot sector separately afterward. The boot loader can be replicated by grub-install or lilo -b on the raw device /dev/hdax, where x is the partition number.
I move bootable Linux partitions between hard disks and also between machines. I would use dd first and tar as the second alternative only if I alter the partition size.
Both are reliable methods for moving "bootable" partitions.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.