You are on page 1of 11

CLONING DEBIAN LINUX

Sometimes we need to clone a Linux system for the following reason :


Install new Linux server with the same software level as existing one.
Moving the Linux operating system to the server hardware.
Change the root disk to the bigger one.
This article will show you how to move a running Debian Linux system to larger disk. In this howto document I will use the following Debian version :
root@debian01:~#0lsb_release04a
No0LSB0modules0are0available.
Distributor0ID:0Debian
Description:0000Debian0GNU/Linux07.10(wheezy)
Release:00007.1
Codename:000wheezy
root@debian01:~#0

Lets start with examining the existing Linux system.


To check the hostname and kernel version we can use uname04a command as shown
below :
root@debian01:~#0uname04a
Linux0debian0103.2.04446864pae0#10SMP0Debian03.2.4641+deb7u10i6860GNU/Linux
root@debian01:~#0

To check mounted filesystem we can use df command as shown below :


root@debian01:~#0df04h
Filesystem0000000000000000000000000000000000000000000000Size00Used0Avail0Use%0Mounted0on
rootfs00000000000000000000000000000000000000000000000000019G001.3G00017G0007%0/
udev0000000000000000000000000000000000000000000000000000010M00000000010M0000%0/dev
tmpfs000000000000000000000000000000000000000000000000000406M00268K00406M0001%0/run
/dev/disk/by4uuid/9cd783974450544c804bddb4703543cdc46f00019G001.3G00017G0007%0/
tmpfs0000000000000000000000000000000000000000000000000005.0M000000005.0M0000%0/run/lock
tmpfs000000000000000000000000000000000000000000000000000987M00000000987M0000%0/run/shm
root@debian01:~#

From the output we can see that, all directory stored under root filesystem. It didnt separate
directory like /boot , /var , or even /home . This information will affect the way we clone
the disk to the new disks. We will talk about this later when we setup the partition on the
new disk.
To check the partition layout on the existing disk we can use fdisk command :
root@debian01:~#0fdisk04l

Disk0/dev/sda:021.50GB,0214748364800bytes
2550heads,0630sectors/track,026100cylinders,0total0419430400sectors
Units0=0sectors0of010*05120=05120bytes
Sector0size0(logical/physical):05120bytes0/05120bytes
I/O0size0(minimum/optimal):05120bytes0/05120bytes
Disk0identifier:00x00029de3
000Device0Boot000000Start000000000End000000Blocks000Id00System
/dev/sda1000*0000000020480000401367030000200673280008300Linux
/dev/sda200000000401387500000419409910000009011210000500Extended
/dev/sda500000000401387520000419409910000009011200008200Linux0swap0/0Solaris
root@debian01:~#0

To check the partition type on existing disk we can use blkid command. In the following
command, we can see that existing disk only consist of 2 partition : root & swap. Root
partition uses ext4 filesystem.
root@debian01:~#0blkid
/dev/sda5:0UUID="5e43e27b4038a445e24bf8442f31105b63a0"0TYPE="swap"0
/dev/sda1:0UUID="9cd783974450544c804bddb4703543cdc46f"0TYPE="ext4"0
root@debian01:~#

To check active network configuration we can use ifconfig command as shown below :
root@debian01:~#0ifconfig04a
eth0000000Link0encap:Ethernet00HWaddr008:00:27:10:f3:d200
0000000000inet0addr:192.168.10.6200Bcast:192.168.10.25500Mask:255.255.255.0
0000000000inet60addr:0fe80::a00:27ff:fe10:f3d2/640Scope:Link
0000000000UP0BROADCAST0RUNNING0MULTICAST00MTU:150000Metric:1
0000000000RX0packets:4330errors:00dropped:00overruns:00frame:0
0000000000TX0packets:1700errors:00dropped:00overruns:00carrier:0
0000000000collisions:00txqueuelen:10000
0000000000RX0bytes:943040(92.00KiB)00TX0bytes:233690(22.80KiB)
lo00000000Link0encap:Local0Loopback00
0000000000inet0addr:127.0.0.100Mask:255.0.0.0
0000000000inet60addr:0::1/1280Scope:Host
0000000000UP0LOOPBACK0RUNNING00MTU:1643600Metric:1
0000000000RX0packets:00errors:00dropped:00overruns:00frame:0
0000000000TX0packets:00errors:00dropped:00overruns:00carrier:0
0000000000collisions:00txqueuelen:00
0000000000RX0bytes:00(0.00B)00TX0bytes:00(0.00B)
root@debian01:~#

So lets move on by attach the new disk to the system. In this case I use a disk with bigger size
than the existing root disk. Depends on the server itself, we can instantly attaching the new disk
or it probably require reboot to let the system recognize the new disk. To check whether the new
disk already attached we can use the fdisk command as shown below :
root@debian01:~#0fdisk04l
Disk0/dev/sda:021.50GB,0214748364800bytes
2550heads,0630sectors/track,026100cylinders,0total0419430400sectors
Units0=0sectors0of010*05120=05120bytes
Sector0size0(logical/physical):05120bytes0/05120bytes

I/O0size0(minimum/optimal):05120bytes0/05120bytes
Disk0identifier:00x00029de3
000Device0Boot000000Start000000000End000000Blocks000Id00System
/dev/sda1000*0000000020480000401367030000200673280008300Linux
/dev/sda200000000401387500000419409910000009011210000500Extended
/dev/sda500000000401387520000419409910000009011200008200Linux0swap0/0Solaris
Disk0/dev/sdb:042.90GB,0429496729600bytes
2550heads,0630sectors/track,052210cylinders,0total0838860800sectors
Units0=0sectors0of010*05120=05120bytes
Sector0size0(logical/physical):05120bytes0/05120bytes
I/O0size0(minimum/optimal):05120bytes0/05120bytes
Disk0identifier:00x00000000
Disk0/dev/sdb0doesn't0contain0a0valid0partition0table
root@debian01:~#

Before able to use new disk ( /dev/sdb ) as clone target, we need to prepare its partition first.
We will use fdisk command to prepare the partition, below is the step-by-step guide to use
fdisk :
1. Start by invoking the fdisk command on /dev/sdb as shown below :
root@debian01:~#0fdisk0/dev/sdb
Device0contains0neither0a0valid0DOS0partition0table,0nor0Sun,0SGI0or0OSF0disklabel
Building0a0new0DOS0disklabel0with0disk0identifier00x9c5d68fe.
Changes0will0remain0in0memory0only,0until0you0decide0to0write0them.
After0that,0of0course,0the0previous0content0won't0be0recoverable.
Warning:0invalid0flag00x00000of0partition0table040will0be0corrected0by0w(rite)
Command0(m0for0help):

2. Type p and press Enter to see the existing partition layout :


Command0(m0for0help):0p
Disk0/dev/sdb:042.90GB,0429496729600bytes
2550heads,0630sectors/track,052210cylinders,0total0838860800sectors
Units0=0sectors0of010*05120=05120bytes
Sector0size0(logical/physical):05120bytes0/05120bytes
I/O0size0(minimum/optimal):05120bytes0/05120bytes
Disk0identifier:00x9c5d68fe
000Device0Boot000000Start000000000End000000Blocks000Id00System
Command0(m0for0help):

Since the disk doesnt have any partition at all then it shows empty partition layout. If there is
any partition in the disk, we better delete it first by typing d (as for delete).
3. To start create a partition on the disk type n as in new partition. Then we must decide
whether we want to create primary or extended partition type. In this sample I choose to
create primary partition type.

Command0(m0for0help):0n
Partition0type:
000p000primary0(00primary,000extended,040free)
000e000extended
Select0(default0p):0p
Partition0number0(144,0default01):0
Using0default0value01
First0sector0(2048483886079,0default02048):0
Using0default0value02048
Last0sector,0+sectors0or0+size{K,M,G}0(2048483886079,0default083886079):0+15G
Command0(m0for0help):

We need to define 3 value for each partition, they are :


Partition number : this will define the order of each partition, it define the name of
partition later ( /dev/sda1 , /dev/sdb2 , etc, etc).
First sector : this define the starting point of the partition. We can see that the whole
disk consist of number of sectors start from sector number 204883886079. Logically
we start from the beginning of the disk, sector 2048.
Last sector : last sector will define how big the partition will be. Since defining the
partition using sector unit will be difficult, fdisk will let us define the size using
human-readable size unit like K (for kilobyte), M (for Megabyte), or G (for Gigabyte).
Just remember to start the value with + sign. In the example above, I choose to create
15G partition.
4. Print the parition layout to verify the first partition created successfully :
Command0(m0for0help):0p
Disk0/dev/sdb:042.90GB,0429496729600bytes
2550heads,0630sectors/track,052210cylinders,0total0838860800sectors
Units0=0sectors0of010*05120=05120bytes
Sector0size0(logical/physical):05120bytes0/05120bytes
I/O0size0(minimum/optimal):05120bytes0/05120bytes
Disk0identifier:00x9c5d68fe
000Device0Boot000000Start000000000End000000Blocks000Id00System
/dev/sdb100000000000020480000314593270000157286400008300Linux
Command0(m0for0help):

5. Then we need to create second partition with 4GB size, we will use this partition as swap
partition.
Command0(m0for0help):0n
Partition0type:
000p000primary0(10primary,000extended,030free)
000e000extended
Select0(default0p):0
Using0default0response0p
Partition0number0(144,0default02):0
Using0default0value02
First0sector0(31459328483886079,0default031459328):0
Using0default0value031459328
Last0sector,0+sectors0or0+size{K,M,G}0(31459328483886079,0default083886079):0+4G

Command0(m0for0help):

See that the first sector now started from sector number 31459328. fdisk already know
that the first partition will ended on 31459327 so the next available space will start on
31459328.
6. Print the parition layout to verify the second partition created successfully :
Command0(m0for0help):0p
Disk0/dev/sdb:042.90GB,0429496729600bytes
2550heads,0630sectors/track,052210cylinders,0total0838860800sectors
Units0=0sectors0of010*05120=05120bytes
Sector0size0(logical/physical):05120bytes0/05120bytes
I/O0size0(minimum/optimal):05120bytes0/05120bytes
Disk0identifier:00x9c5d68fe
000Device0Boot000000Start000000000End000000Blocks000Id00System
/dev/sdb100000000000020480000314593270000157286400008300Linux
/dev/sdb200000000314593280000398479350000041943040008300Linux
Command0(m0for0help):

7. I want to separate the /home as separate partition, so I create the 3rd partition and assign
the rest available space to that.
Command0(m0for0help):0n
Partition0type:
000p000primary0(20primary,000extended,020free)
000e000extended
Select0(default0p):0p
Partition0number0(144,0default03):0
Using0default0value03
First0sector0(39847936483886079,0default039847936):0
Using0default0value039847936
Last0sector,0+sectors0or0+size{K,M,G}0(39847936483886079,0default083886079):0
Using0default0value083886079
Command0(m0for0help):0

8. Print the partition again to verify all partition already correct :


Command0(m0for0help):0p
Disk0/dev/sdb:042.90GB,0429496729600bytes
2550heads,0630sectors/track,052210cylinders,0total0838860800sectors
Units0=0sectors0of010*05120=05120bytes
Sector0size0(logical/physical):05120bytes0/05120bytes
I/O0size0(minimum/optimal):05120bytes0/05120bytes
Disk0identifier:00x9c5d68fe
000Device0Boot000000Start000000000End000000Blocks000Id00System
/dev/sdb100000000000020480000314593270000157286400008300Linux
/dev/sdb200000000314593280000398479350000041943040008300Linux
/dev/sdb300000000398479360000838860790000220190720008300Linux
Command0(m0for0help):

9. Then we need to toggle bootable flag on the 1st partition since it act as root partition which
contains /boot directory. Type a to start assign the bootable flag and then later type 1
to choose partition number 1.
Command0(m0for0help):0a
Partition0number0(144):01
Command0(m0for0help):0p
Disk0/dev/sdb:042.90GB,0429496729600bytes
2550heads,0630sectors/track,052210cylinders,0total0838860800sectors
Units0=0sectors0of010*05120=05120bytes
Sector0size0(logical/physical):05120bytes0/05120bytes
I/O0size0(minimum/optimal):05120bytes0/05120bytes
Disk0identifier:00x9c5d68fe
000Device0Boot000000Start000000000End000000Blocks000Id00System
/dev/sdb1000*0000000020480000314593270000157286400008300Linux
/dev/sdb200000000314593280000398479350000041943040008300Linux
/dev/sdb300000000398479360000838860790000220190720008300Linux
Command0(m0for0help):

If the partition already marked as bootable, then you can see the * sign in that partition.
10. To make the changes permanently we need to type w as in write into partition table :
Command0(m0for0help):0w
The0partition0table0has0been0altered!
Calling0ioctl()0to0re4read0partition0table.
Syncing0disks.
root@debian01:~#

After have the partition setup, we need to create the filesystem on top of it. In this example, we
will use ext3 filesystem on partition 1 & 3. Also we need to activate partition number 2 as swap
partition. To create the ext3 filesystem, we will use mkfs.ext3 command as shown in the
following sample :
root@debian01:~#0mkfs.ext30/dev/sdb1
mke2fs01.42.50(294Jul42012)
Filesystem0label=
OS0type:0Linux
Block0size=40960(log=2)
Fragment0size=40960(log=2)
Stride=00blocks,0Stripe0width=00blocks
9830400inodes,039321600blocks
1966080blocks0(5.00%)0reserved0for0the0super0user
First0data0block=0
Maximum0filesystem0blocks=4026531840
1200block0groups
327680blocks0per0group,0327680fragments0per0group
81920inodes0per0group
Superblock0backups0stored0on0blocks:0
000032768,098304,0163840,0229376,0294912,0819200,0884736,01605632,02654208

Allocating0group0tables:0done0000000000000000000000000000
Writing0inode0tables:0done0000000000000000000000000000
Creating0journal0(327680blocks):0done
Writing0superblocks0and0filesystem0accounting0information:0done000
root@debian01:~#0mkfs.ext30/dev/sdb3
mke2fs01.42.50(294Jul42012)
Filesystem0label=
OS0type:0Linux
Block0size=40960(log=2)
Fragment0size=40960(log=2)
Stride=00blocks,0Stripe0width=00blocks
13762560inodes,055047680blocks
2752380blocks0(5.00%)0reserved0for0the0super0user
First0data0block=0
Maximum0filesystem0blocks=0
1680block0groups
327680blocks0per0group,0327680fragments0per0group
81920inodes0per0group
Superblock0backups0stored0on0blocks:0
000032768,098304,0163840,0229376,0294912,0819200,0884736,01605632,02654208,0
00004096000
Allocating0group0tables:0done0000000000000000000000000000
Writing0inode0tables:0done0000000000000000000000000000
Creating0journal0(327680blocks):0done
Writing0superblocks0and0filesystem0accounting0information:0done000
root@debian01:~#

To activate the second partition as swap we will use mkswap command as shown below :
root@debian01:~#0mkswap0/dev/sdb2
Setting0up0swapspace0version01,0size0=041943000KiB
no0label,0UUID=c891f2234491244c4d4adbc40158c89b8aff
root@debian01:~#0

Once filesystem created, then we can mount the partition as shown on the following example :
root@debian01:~#0mkdir0/media/newroot
root@debian01:~#0mkdir0/media/newhome
root@debian01:~#0mount0/dev/sdb10/media/newroot/
root@debian01:~#0mount0/dev/sdb30/media/newhome/

We will use rsync command to do data synchronization between old disk to the new one. If you
dont have rsync installed on your system, then go install it first. Here is the sample installing
rsync in Debian-based Linux distribution :
root@debian01:~#0apt4get0install0rsync
Reading0package0lists...0Done
Building0dependency0tree0000000
Reading0state0information...0Done
The0following0NEW0packages0will0be0installed:
00rsync
00upgraded,010newly0installed,000to0remove0and000not0upgraded.
Need0to0get03570kB0of0archives.
After0this0operation,06390kB0of0additional0disk0space0will0be0used.
Get:10http://kambing.ui.ac.id/debian/0wheezy/main0rsync0i38603.0.9440[3570kB]
Fetched03570kB0in00s0(3970kB/s)

Selecting0previously0unselected0package0rsync.
(Reading0database0...0458740files0and0directories0currently0installed.)
Unpacking0rsync0(from0.../rsync_3.0.944_i386.deb)0...
Processing0triggers0for0man4db0...
Setting0up0rsync0(3.0.944)0...
update4rc.d:0using0dependency0based0boot0sequencing
root@debian01:~#0

Below is the sample how we use rsync to copy root partition to the new disk :
root@debian01:~#0rsync04ar044exclude0"/home"044exclude0"/media/newroot"044exclude0
"/media/newhome"044exclude0"/proc"044exclude0"/sys"0/*0/media/newroot
root@debian01:~#0

We will exclude some directory like /proc/ and /sys because both arent needed for this
cloning process. We also excluding the partition of new disk as well.
We will copy /home/ partition to dedicated partition as well :
root@debian01:~#0rsync04ar0/home/*0/media/newhome/
root@debian01:~#0

Here is the status after synchronization process finished :


root@debian01:~#0df04h
Filesystem0000000000000000000000000000000000000000000000Size00Used0Avail0Use%0Mounted0on
rootfs00000000000000000000000000000000000000000000000000019G001.3G00017G0008%0/
udev0000000000000000000000000000000000000000000000000000010M00000000010M0000%0/dev
tmpfs000000000000000000000000000000000000000000000000000406M00280K00406M0001%0/run
/dev/disk/by4uuid/9cd783974450544c804bddb4703543cdc46f00019G001.3G00017G0008%0/
tmpfs0000000000000000000000000000000000000000000000000005.0M000000005.0M0000%0/run/lock
tmpfs000000000000000000000000000000000000000000000000000987M00000000987M0000%0/run/shm
/dev/sdb100000000000000000000000000000000000000000000000015G001.3G00013G0010%0/media/newroot
/dev/sdb300000000000000000000000000000000000000000000000021G00173M00020G0001%0/media/newhome
root@debian01:~#0

Then we will chroot -ing to the new root partition ( /dev/sdb1 which mounted at
/media/newroot at the moment). There are some step should be executed before we can
chroot to the new root environment :
root@debian01:~#0mkdir0/media/newroot/proc
root@debian01:~#0mkdir0/media/newroot/dev
root@debian01:~#0mkdir0/media/newroot/sys
root@debian01:~#0mount04o0bind0/dev0/media/newroot/dev/
root@debian01:~#0mount04t0proc0none0/media/newroot/proc
root@debian01:~#0mount04t0sysfs0none0/media/newroot/sys
root@debian01:~#0chroot0/media/newroot

There are some steps will be executed from inside chroot environment :
1. Before begin we need to verify that we already inside the chroot environment. The
simplest task is using df04h command as shown below :

root@debian01:/#0df04h
df:0`/media/newhome':0No0such0file0or0directory
Filesystem0000000000000000000000000000000000000000000000Size00Used0Avail0Use%0Mounted0on
rootfs00000000000000000000000000000000000000000000000000015G001.3G00013G0010%0/
udev0000000000000000000000000000000000000000000000000000010M00000000010M0000%0/dev
devpts00000000000000000000000000000000000000000000000000010M00000000010M0000%0/dev/pts
tmpfs000000000000000000000000000000000000000000000000000015G001.3G00013G0010%0/run
/dev/disk/by4uuid/9cd783974450544c804bddb4703543cdc46f00015G001.3G00013G0010%0/
tmpfs000000000000000000000000000000000000000000000000000015G001.3G00013G0010%0/run/lock
tmpfs000000000000000000000000000000000000000000000000000015G001.3G00013G0010%0/run/shm
rpc_pipefs0000000000000000000000000000000000000000000000015G001.3G00013G0010%0
/var/lib/nfs/rpc_pipefs
/dev/sdb100000000000000000000000000000000000000000000000015G001.3G00013G0010%0/
udev0000000000000000000000000000000000000000000000000000010M00000000010M0000%0/dev
root@debian01:/#0
root@debian01:/#0pwd
/
root@debian01:/#

See that there is no /dev/sdb1 & /dev/sdb3 being mounted, since we are already inside
that /dev/sdb1 .
2. Then we need to modify /etc/fstab file. This file will define the list of partition that must
be mounted during boot process. Copy the existing fstab file as backup.
root@debian01:/#0cd0/etc/
root@debian01:/etc#0cp0fstab0fstab4orig

Once have the backup, we can safely edit the fstab file. We need to change the disk
identification so all partition information pointed to the new disk ( /dev/sdb1 ). We can use
blkid command to check the UUID of the new disk :
root@debian01:/etc#0blkid
/dev/sda5:0UUID="5e43e27b4038a445e24bf8442f31105b63a0"0TYPE="swap"0
/dev/sda1:0UUID="9cd783974450544c804bddb4703543cdc46f"0TYPE="ext4"0
/dev/sdb1:0UUID="d9e6bd2b4844644f614963649b078c0d966a"0SEC_TYPE="ext2"0TYPE="ext3"0
/dev/sdb2:0UUID="c891f2234491244c4d4adbc40158c89b8aff"0TYPE="swap"0
/dev/sdb3:0UUID="2cbe1cb34108444229492ff4847cd53e408a"0SEC_TYPE="ext2"0TYPE="ext3"0
root@debian01:/etc#0

Then we can change the UUID informatio inside the fdisk file :
root@debian01:/etc#0vi0fstab
#0/etc/fstab:0static0file0system0information.
#
#0Use0'blkid'0to0print0the0universally0unique0identifier0for0a
#0device;0this0may0be0used0with0UUID=0as0a0more0robust0way0to0name0devices
#0that0works0even0if0disks0are0added0and0removed.0See0fstab(5).
#
#0<file0system>0<mount0point>000<type>00<options>0000000<dump>00<pass>
#0/0was0on0/dev/sda10during0installation
UUID=d9e6bd2b4844644f614963649b078c0d966a0/000000000000000ext30000errors=remount4ro000000000
1
#0swap0was0on0/dev/sda50during0installation
UUID=c891f2234491244c4d4adbc40158c89b8aff0none000000000000swap0000sw0000000000000000000000
0

UUID=2cbe1cb34108444229492ff4847cd53e408a0/home000000000000000ext30000defaults000000000000
1
/dev/sr000000000/media/cdrom0000udf,iso96600user,noauto00000000000000
root@debian01:/etc#0

We can compare the backup fstab with the one we just modified :
root@debian01:/etc#0diff04u0fstab4orig0fstab
4440/etc/fstab002013409421011:03:34.0000000000+0700
+++0/etc/fstab4orig02013409421010:57:55.0000000000+0700
@@046,80+6,70@@
0#
0#0<file0system>0<mount0point>000<type>00<options>0000000<dump>00<pass>
0#0/0was0on0/dev/sda10during0installation
4UUID=d9e6bd2b4844644f614963649b078c0d966a0/000000000000000ext30000errors=remount4ro000000000
1
+UUID=9cd783974450544c804bddb4703543cdc46f0/000000000000000ext40000errors=remount4ro000000000
1
0#0swap0was0on0/dev/sda50during0installation
4UUID=c891f2234491244c4d4adbc40158c89b8aff0none000000000000swap0000sw0000000000000000000000
0
4UUID=2cbe1cb34108444229492ff4847cd53e408a0/home000000000000000ext30000defaults00000000000
1
+UUID=5e43e27b4038a445e24bf8442f31105b63a00none000000000000swap0000sw0000000000000000000000
0
0/dev/sr000000000/media/cdrom0000udf,iso96600user,noauto00000000000000
root@debian01:/etc#0

3. If we want to clone this new disk as new server then we probably need to modify the
hostname & IP configuration. We can do it now :
root@debian01:/etc#0cat0/etc/hostname0
debian01
root@debian01:/etc#0vi0/etc/hostname0
debian014new
root@debian01:/etc#0

4. In this step we need to reinstall the boot loader into new disks MBR. In this example,
system use GRUB boot loader so we will use the following command to reinstall the GRUB :
root@debian01:/etc#0update4grub
Generating0grub.cfg0...
Found0linux0image:0/boot/vmlinuz43.2.04446864pae
Found0initrd0image:0/boot/initrd.img43.2.04446864pae
done
root@debian01:/etc#0grub4install0/dev/sdb
Installation0finished.0No0error0reported.
root@debian01:/etc#0

5. Exit the chroot environment :


root@debian01:/etc#0exit
root@debian01:~#0df04h
Filesystem0000000000000000000000000000000000000000000000Size00Used0Avail0Use%0Mounted0on
rootfs00000000000000000000000000000000000000000000000000019G001.3G00017G0008%0/
udev0000000000000000000000000000000000000000000000000000010M00000000010M0000%0/dev
tmpfs000000000000000000000000000000000000000000000000000406M00280K00406M0001%0/run

/dev/disk/by4uuid/9cd783974450544c804bddb4703543cdc46f00019G001.3G00017G0008%0/
tmpfs0000000000000000000000000000000000000000000000000005.0M000000005.0M0000%0/run/lock
tmpfs000000000000000000000000000000000000000000000000000987M00000000987M0000%0/run/shm
/dev/sdb100000000000000000000000000000000000000000000000015G001.3G00013G0010%0
/media/newroot
/dev/sdb300000000000000000000000000000000000000000000000021G00173M00020G0001%0
/media/newhome
udev0000000000000000000000000000000000000000000000000000010M00000000010M0000%0
/media/newroot/dev
root@debian01:~#0

At this point we have successfully clone the complete Linux system to the new disk. We can
shutdown the server and swap the disk or we can use the second disk ( /dev/sdb ) to boot
another server.
root@debian01:~#0shutdown04h0now
Broadcast0message0from0root@debian010(pts/0)0(Sat0Sep021011:00:5702013):
The0system0is0going0down0for0system0halt0NOW!
root@debian01:~#0

If everything is right then system will be able to boot using the /dev/sdb :
$0ssh0root@192.168.10.62
root@192.168.10.62's0password:0
Linux0debian014new03.2.04446864pae0#10SMP0Debian03.2.4641+deb7u10i686
The0programs0included0with0the0Debian0GNU/Linux0system0are0free0software;
the0exact0distribution0terms0for0each0program0are0described0in0the
individual0files0in0/usr/share/doc/*/copyright.
Debian0GNU/Linux0comes0with0ABSOLUTELY0NO0WARRANTY,0to0the0extent
permitted0by0applicable0law.
Last0login:0Sat0Sep021011:06:5402013
root@debian014new:~#0uname04a
Linux0debian014new03.2.04446864pae0#10SMP0Debian03.2.4641+deb7u10i6860GNU/Linux
root@debian014new:~#0df04h
Filesystem0000000000000000000000000000000000000000000000Size00Used0Avail0Use%0Mounted0on
rootfs00000000000000000000000000000000000000000000000000015G001.3G00013G0010%0/
udev0000000000000000000000000000000000000000000000000000010M00000000010M0000%0/dev
tmpfs000000000000000000000000000000000000000000000000000406M00268K00406M0001%0/run
/dev/disk/by4uuid/d9e6bd2b4844644f614963649b078c0d966a00015G001.3G00013G0010%0/
tmpfs0000000000000000000000000000000000000000000000000005.0M000000005.0M0000%0/run/lock
tmpfs0000000000000000000000000000000000000000000000000001.6G000000001.6G0000%0/run/shm
/dev/sda300000000000000000000000000000000000000000000000021G00173M00020G0001%0/home
root@debian014new:~#0su040ttirtawi
ttirtawi@debian014new:~$0pwd
/home/ttirtawi
ttirtawi@debian014new:~$0

See that the disk with UUID d9e6bd2b4844644f614963649b078c0d966a is mounted as root


now.
Congratulation you have your Linux live on the new disk now.

You might also like