6

I've got a new dedicated server that I want to use purely for backup purposes.

[root@dedi ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        20G  942M   18G   6% /
tmpfs           7.8G     0  7.8G   0% /dev/shm
/dev/sda1       283M   32M  236M  12% /boot
/dev/sda2       1.8T   68M  1.7T   1% /data
[root@dedi ~]# cat /proc/partitions
major minor  #blocks  name

   8        0 1953481816 sda
   8        1     307200 sda1
   8        2 1932167168 sda2
   8        3   20480000 sda3
   8        4     524288 sda4
   8       16 1953481816 sdb

I'd like to keep the tmpfs and /boot as they are, and create one big ~4TB partition out of the rest.

I know this is relatively straightforward stuff, but I'd really appreciate hand walking through it, as I've never done any linux partitioning stuff before, and don't want to make a mess of the brand new box...

Many thanks

Codemonkey
  • 1,086
  • 4
  • 19
  • 41
  • I take it you want to combine sda2 with sdb? With a raid 0 like that if either drive has issues all your backups are gone. – Mike May 18 '15 at 12:23
  • Correct. How can you tell it's RAID 0? I assumed it would be more "JBOD", which I'm fine with, I have no need for extra performance. I'm backuping to another location as well, and have RAID 1 on the main server, so I'm not overly concerned about not having RAID 1 on this box. – Codemonkey May 18 '15 at 12:29
  • @Mike: I don't read in the answer that RAID 0 is desired, and it's a bad idea for the reasons you indicated. But how else do you tell Linux to store files on one of two disks/partitions? It's of course unavoidable that you lose a file when the disk it's on crashes and you have no redundancy. The problem with Linux LVM RAID is that apparently it **also** loses the files on the **good** disk. That wouldn't be acceptable if it was designed today; it seems the behavior is tolerated only because RAID-0 is ancient. – MSalters May 18 '15 at 15:28
  • @MSalters Raid0 doesn't work in the way you seem to imply, it doesn't store some files on one disk and some files on the other, it stores alternating "stripes" on each disk, each stripe being usually much less than a file, so most files are on both disks, its meaningless to say that it could save the files on one disk, it just isn't like that. It is not designed for reliability and it should not be expected, it is purely for performance and if used for storing important data should be combined with redundancy and good backup. Raid0 is tolerated because of high read performance, not age. – Vality May 18 '15 at 16:33
  • @Vality: I know how RAID-0 works, that is **exactly** why I'm arguing for a non-striped **alternative**. That's especially relevant here as the read performance of RAID-0 isn't needed for backups (which is mostly writes) – MSalters May 18 '15 at 19:08
  • @MSalters I am not objecting to your suggestion that an alternative may be more appropriate here. Indeed my answer goes into that in more detail. I merely felt your criticism of raid 0 was much more universal and somewhat unwarranted. It certainly has its disadvantages but it does have a very useful niche and certainly is used for reasons other than being old. Line any system it has trade-offs between advantages and issues, but it certainly does have significant advantages. – Vality May 19 '15 at 00:19

3 Answers3

19

You need to use LVM (Logical Volume Manager)

First of all , you must be aware that if any of the physical disk fail , the Big 4TB volume will fail too. Backup your data first!

Basically , all you need to do is to partition your data (/dev/sda2 and /dev/sdb1) partition in lvm format then :

  • create two physical volumes (pvcreate /dev/sda2 /dev/sdb1)
  • create one volume group with the two physical volumes (vgcreate VG_DATA /dev/sda2 /dev/sdb1)
  • create one logical volume ( lvcreate -l 100%FREE -n DATA VG_DATA )
  • create the filesystem on your new volume (mkfs.ext3 /dev/VG_DATA/DATA)
  • mount the volume (mount /dev/VG_DATA/DATA /data )

There are dozen of sites with howtos lvm like this one.

Lvm is a lot more than these 4 commands , read the fine manual if you want advanced configuration. I hope it will help you

masegaloeh
  • 18,236
  • 10
  • 57
  • 106
Max
  • 482
  • 4
  • 10
2

I personally feel LVM is overkill for this simple task, I would suggest setting up mdadm to create a RAID array.

Now you have two options:

  • either a linear array, which will literally produce a concatenated partition based on two source partitions
  • or RAID-0, which has the additional limitation that the source partitions must be of the same size but provides a substantial performance boost to reading and writing.

However beware, if either disk fails at least half and possibly all of your data will be lost. If you use a linear array some may be recoverable, with RAID-0 it will all almost certainly be destroyed, decide which of these trade-offs you want when deciding the type of array you choose.

Next, you need to create a large partition on each disk, you can do this with fdisk or any other tool, and I wont go into detail here as there are better guides elsewhere.

Then you run mdadm in the form of:

# for a RAID-0 Array
mdadm --create --verbose /dev/md0 --level=stripe /dev/sda1 /dev/sdb2

# for a linear Array
mdadm --create --verbose /dev/md0 --level=linear /dev/sda1 /dev/sdb2

Where /dev/sda1 and /dev/sdb2 are replaced with the partitions we created in the previous step. I then suggest taking a quick browse of the mdadm man page to learn how you may need to maintain this array.

You may choose to use LVM instead as Max has suggested and that may well serve you better if you end up with an extremely complex configuration but I do not feel it is really needed for a simple case like yours, raid may also provide substantial performance improvements over LVM if configured correctly, however that goes beyond the scope of this answer.

webwurst
  • 392
  • 2
  • 6
Vality
  • 346
  • 4
  • 13
-1

Should point out that the above will wipe any data you have on /data.

You'll also have to create a new file system on the new RAID0 partition (as per LVM example) and update your fstab so it is mounted as /data (or whatever)

Tom Hallam
  • 405
  • 4
  • 6