One way to keep data around is to keep a second data disk on your system and periodically mount it and sync the data on your primary data disk. No this is not RAID. I wanted something so simple that I could not shoot myself in the foot. Basically, I have a 400GB data disk and a second data disk that I keep unmounted and then run a cron job each night to mount that drive and then run the rsync command against it and unmount it. My own way of keeping data somewhat backed up. Not fool proof, but better than nothing. that and every so often, burning lots of DVDs and then putting them in a safe offsite location.
Put in the disks and make sure that the host (Linux now…) can see them.
Run: fdisk -l
<em>root@blaster:/# <strong>fdisk -l</strong></em>
<em>Disk /dev/sda: 400.0 GB, 400088457216 bytes
255 heads, 63 sectors/track, 48641 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0×00000000</em>
<em><strong>Disk /dev/sdb: 400.0 GB, 400088457216 bytes <— our new disk</strong>
255 heads, 63 sectors/track, 48641 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0×00000000</em>
<em>Disk /dev/sdb doesn’t contain a valid partition table</em>
<em>Disk /dev/hda: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0×34943493</em>
<em>Device Boot Start End Blocks Id System
/dev/hda1 * 1 4660 37431418+ 83 Linux
/dev/hda2 4661 4865 1646662+ 5 Extended
/dev/hda5 4661 4865 1646631 82 Linux swap / Solaris
root@blaster:/# <strong>fdisk /dev/sdb <— running fdisk against /dev/sdb</strong>
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xd600a205.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won’t be recoverable.</em>
<em>The number of cylinders for this disk is set to 48641.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0×0000 of partition table 4 will be corrected by w(rite)</em>
<em>Command (m for help): <strong>m <—- menu</strong>
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition’s system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)</em>
<em>Command (m for help): <strong>p <— printing</strong></em>
<em>Disk /dev/sdb: 400.0 GB, 400088457216 bytes
255 heads, 63 sectors/track, 48641 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xd600a205</em>
<em>Device Boot Start End Blocks Id System</em>
<em>Command (m for help): n
Command action
e extended
p primary partition (1-4)
<strong>p <—- Making a primary partition</strong>
Partition number (1-4): <strong>1 </strong> <<strong>– Starting with partition 1</strong>
First cylinder (1-48641, default 1): <–<strong>- Using defaults from here on out</strong>
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-48641, default 48641):
Using default value 48641</em>
<em>Command (m for help): <strong>p <— Printing again</strong></em>
<em>Disk /dev/sdb: 400.0 GB, 400088457216 bytes
255 heads, 63 sectors/track, 48641 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xd600a205</em>
<em>Device Boot Start End Blocks Id System
/dev/sdb1 1 48641 390708801 83 Linux</em>
<em>Command (m for help): <strong>w <— Writing out the data</strong>
The partition table has been altered!</em>
<em>Calling ioctl() to re-read partition table.
Syncing disks.</em>
Done with the disk format
Now time to put a filesystem on the drive. Using the first partition of /dev/sdb1, journaling with ext3.
<em>root@blaster:/# <strong>mke2fs -j /dev/sdb1</strong>
mke2fs 1.40.2 (12-Jul-2007)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
48840704 inodes, 97677200 blocks
4883860 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
2981 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968</em>
<em>Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done</em>
<em>This filesystem will be automatically checked every 21 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.</em>
Now we add this to the /etc/fstab file:
<em>/dev/sdb1 /sync ext3 defaults 0 2</em>
We need a mount point.
<em>mkdir /sync</em>
Now mount it.
<em>/sbin/mount -a</em>
and look at it.
<em>df -h</em>
/dev/sda1 367G 295G 54G 85% /data
/dev/sdb1 367G 195M 348G 1% /sync
Now we want to sync the disks.
/dev/sda1 367G 295G 54G 85% /data
/dev/sdb1 367G 195M 348G 1% /sync
Here we are running the rsync command. This will copy all the data from /data to /sync
<em>/usr/bin/rsync -auvP /data/* /sync/</em>
I run this command each day and then at the end of the week, I run:
<em>/usr/bin/rsync -auvP –delete /data/* /sync/</em>
The reason that I do this is to keep new information flowing to the /sync disk but remember that there is no cleanup unless you invoke the –delete arguement. Pick your own clean up schedule. This help if you accidentley delete something, you just mount /sync and get it from the previous day.